diff --git a/.gitattributes b/.gitattributes index 2c841920c1fcafdea40eac53ae1bcf8df6db138d..984f309a2b0eebeab7ad35b356cb2ebb6798dd5c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,137 @@ version https://git-lfs.github.com/spec/v1 oid sha256:c235fd2dca9067031676c053a0a02ffe365fcb7de0107c1653c927971f927e37 size 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 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220.zip" new file mode 100644 index 0000000000000000000000000000000000000000..f8c7bd57f7eecfb8c37e731c67cffb28d7f868a9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b618acd0a2be7fa7b0847b10de6d15aa0bc6a77bebfbd52a8ffcc4cec3b65bc6 +size 431855233 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-bin.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-bin.zip" new file mode 100644 index 0000000000000000000000000000000000000000..e2e2fe6ad9e8537b9abd6fe63f95507707776bfe --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-bin.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be9c78df26d2997bf4ab5b0f2ea7fcf80c265fba9d962e7f20255e8a811fead0 +size 1686431 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src.zip" new file mode 100644 index 0000000000000000000000000000000000000000..61606ce9981de89547002193c9760e78ef59ac51 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d44c461dc110e1bf6e8a5e74c38101544d41c6b6e379308e5420521271bcf279 +size 638391 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/LICENSE.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/LICENSE.txt" new file mode 100644 index 0000000000000000000000000000000000000000..6b0b1270ff0ca8f03867efcd09ba6ddb6392b1e1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/LICENSE.txt" @@ -0,0 +1,203 @@ + + 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. + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/NOTICE.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/NOTICE.txt" new file mode 100644 index 0000000000000000000000000000000000000000..18053bbe1a8e79d87fe357d053b55042d6699c06 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/NOTICE.txt" @@ -0,0 +1,5 @@ +Apache Commons IO +Copyright 2002-2016 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/PROPOSAL.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/PROPOSAL.html" new file mode 100644 index 0000000000000000000000000000000000000000..a96b3e6889a4b20029b57adeaac5bd30becd63a7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/PROPOSAL.html" @@ -0,0 +1,78 @@ + + + + + Proposal for IO Package + + + +
+

Proposal for IO Package

+
+ +

(0) Rationale

+ +

Many software projects have a need to perform I/O in various ways, and +the JDK class libraries provide a lot of functionality, but sometimes you +need just a little bit more. The io package seeks to encapsulate some of +the most popular i/o base classes into one easy to use package.

+ +

(1) Scope of the Package

+ +

This proposal is to create a package of Java utility classes for various +types of i/o related activity.

+ +

(1.5) Interaction With Other Packages

+ +

IO relies only on standard JDK 1.2 (or later) APIs for production +deployment. It utilizes the JUnit unit testing framework for developing +and executing unit tests, but this is of interest only to developers of the +component. IO will be a dependency for several existing components in the +open source world.

+ +

No external configuration files are utilized.

+ +

(2) Initial Source of the Package

+ +

The original Java classes are splashed around various Apache subprojects. + We intend to seek them out and integrate them.

+ +

The proposed package name for the new component is org.apache.commons.io.

+ +

(3) Required Jakarta-Commons Resources

+ + + +

(4) Initial Committers

+ +

The initial committers on the IO component shall be Scott Sanders and +Nicola Ken Barozzi and Henri Yandell

+
+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/RELEASE-NOTES.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/RELEASE-NOTES.txt" new file mode 100644 index 0000000000000000000000000000000000000000..5c0b9360f79022f8c842894281dcd29a57369a32 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/RELEASE-NOTES.txt" @@ -0,0 +1,993 @@ + +Apache Commons IO +Version 2.5 +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. + +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 to +sebb. +o IO-333: Export OSGi packages at version 1.x in addition to 2.x. Thanks +to fmeschbe. +o IO-320: Add XmlStreamReader support for UTF-32. Thanks to ggregory. +o IO-331: BOMInputStream wrongly detects UTF-32LE_BOM files as +UTF-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. Thanks +to raviprak. +o IO-324: Add missing Charset sister APIs to method that take a String +charset name. Thanks to raviprak. + +Fixed Bugs: +o IO-336: Yottabyte (YB) incorrectly defined in FileUtils. Thanks to +rleavelle. +o IO-279: Tailer erroneously considers file as new. Thanks to Sergio +Bossa, Chris Baron. +o IO-335: Tailer#readLines - incorrect CR handling. +o IO-334: FileUtils.toURLs throws NPE for null parameter; document the +behavior. +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 to +raviprak. + + +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: Yes +Source compatible: Yes +Semantic 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 for +those 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 JIRA +http://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 Team diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/build.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/build.xml" new file mode 100644 index 0000000000000000000000000000000000000000..525e9b6aaaa2f7d57161a76e1ff5738e571ee884 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/build.xml" @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/checkstyle.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/checkstyle.xml" new file mode 100644 index 0000000000000000000000000000000000000000..bd420ddd9174429886698fb557a084353cb0be12 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/checkstyle.xml" @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/findbugs-exclude-filter.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/findbugs-exclude-filter.xml" new file mode 100644 index 0000000000000000000000000000000000000000..506146ad9a0ea5b89919544481dacaa938fcf0ee --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/findbugs-exclude-filter.xml" @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/pom.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/pom.xml" new file mode 100644 index 0000000000000000000000000000000000000000..8ab814911e07e7a6449935b29174e068ce03abe8 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/pom.xml" @@ -0,0 +1,422 @@ + + + + + org.apache.commons + commons-parent + 39 + + 4.0.0 + commons-io + commons-io + 2.5 + Apache Commons IO + + 2002 + +The Apache Commons IO library contains utility classes, stream implementations, file filters, +file comparators, endian transformation classes, and much more. + + + http://commons.apache.org/proper/commons-io/ + + + jira + http://issues.apache.org/jira/browse/IO + + + + + apache.website + Apache Commons Site + scm:svn:https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-i/ + + + + + scm:svn:http://svn.apache.org/repos/asf/commons/proper/io/tags/commons-io-2.5 + scm:svn:https://svn.apache.org/repos/asf/commons/proper/io/tags/commons-io-2.5 + http://svn.apache.org/viewvc/commons/proper/io/tags/commons-io-2.5 + + + + + Scott Sanders + sanders + sanders@apache.org + + + Java Developer + + + + dIon Gillard + + dion + dion@apache.org + + + Java Developer + + + + Nicola Ken Barozzi + nicolaken + nicolaken@apache.org + + + Java Developer + + + + Henri Yandell + bayard + bayard@apache.org + + + Java Developer + + + + Stephen Colebourne + scolebourne + + + Java Developer + + 0 + + + Jeremias Maerki + jeremias + jeremias@apache.org + + + Java Developer + + +1 + + + Matthew Hawthorne + matth + matth@apache.org + + + Java Developer + + + + Martin Cooper + martinc + martinc@apache.org + + + Java Developer + + + + Rob Oxspring + roxspring + roxspring@apache.org + + + Java Developer + + + + Jochen Wiedmann + jochen + jochen.wiedmann@gmail.com + + + Niall Pemberton + niallp + + Java Developer + + + + Jukka Zitting + jukka + + Java Developer + + + + Gary Gregory + ggregory + ggregory@apache.org + http://www.garygregory.com + -5 + + + Kristian Rosenvold + krosenvold + krosenvold@apache.org + +1 + + + + + + Rahul Akolkar + + + Jason Anderson + + + Nathan Beyer + + + Emmanuel Bourg + + + Chris Eldredge + + + Magnus Grimsell + + + Jim Harrington + + + Thomas Ledoux + + + Andy Lehane + + + Marcelo Liberato + + + Alban Peignier + alban.peignier at free.fr + + + Ian Springer + + + Dominik Stadler + + + Masato Tezuka + + + James Urie + + + Frank W. Zammetti + + + + + + junit + junit + 4.12 + test + + + + + 1.6 + 1.6 + io + RC4 + 2.5 + (requires JDK 1.6+) + IO + 12310477 + + + 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, + + 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 + + + site-content + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.14.1 + + + xerces:xercesImpl + + pertest + + -Xmx25M + + + **/*Test*.class + + + **/*AbstractTestCase* + **/testtools/** + + **/*$* + + + + + maven-assembly-plugin + + + src/assembly/bin.xml + src/assembly/src.xml + + gnu + + + + org.apache.maven.plugins + maven-scm-publish-plugin + + + javadocs + + + + + + org.apache.rat + apache-rat-plugin + + + + src/test/resources/**/*.bin + test/** + + + site-content/** + .pmd + src/site/resources/download_*.cgi + + + + + + + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.7 + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.12.1 + + ${basedir}/checkstyle.xml + false + + + + org.codehaus.mojo + findbugs-maven-plugin + ${commons.findbugs.version} + + Normal + Default + ${basedir}/findbugs-exclude-filter.xml + + + + org.apache.rat + apache-rat-plugin + + + + src/test/resources/**/*.bin + test/** + + + site-content/** + .pmd + src/site/resources/download_*.cgi + + + + + + + + + setup-checkout + + + site-content + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + prepare-checkout + pre-site + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/assembly/bin.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/assembly/bin.xml" new file mode 100644 index 0000000000000000000000000000000000000000..cf3f0086997cc5b62c826dcbea6db18603b007b6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/assembly/bin.xml" @@ -0,0 +1,49 @@ + + + bin + + tar.gz + zip + + false + + + + LICENSE.txt + NOTICE.txt + RELEASE-NOTES.txt + + + + target + + + *.jar + + + + target/site/apidocs + docs + + **/customsorttypes.js + **/sortabletable.js + **/stringbuilder.js + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/assembly/src.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/assembly/src.xml" new file mode 100644 index 0000000000000000000000000000000000000000..453264d96fdb0586ab57e59954d56c5b91b057f7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/assembly/src.xml" @@ -0,0 +1,41 @@ + + + src + + tar.gz + zip + + ${artifactId}-${commons.release.version}-src + + + + build.xml + checkstyle.xml + findbugs-exclude-filter.xml + LICENSE.txt + NOTICE.txt + pom.xml + PROPOSAL.html + RELEASE-NOTES.txt + + + + src + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/changes/changes.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/changes/changes.xml" new file mode 100644 index 0000000000000000000000000000000000000000..348e8467b01101e944de45cc48407fe2182dd128 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/changes/changes.xml" @@ -0,0 +1,488 @@ + + + + + + + + Release Notes + + + + + + + Typo: In an IOUtils.java comment it says "focussed" instead of "focused". + + + Converted all testcases to JUnit 4 + + + Add ValidatingObjectInputStream for controlled deserialization + + + adds an endOfFileReached method to the TailerListener + + + FilenameUtils should handle embedded null bytes + + + Changed/Corrected algorithm for waitFor + + + Support for additional encodings in ReversedLinesFileReader + + + BOMInputStream.skip returns wrong count if stream contains no BOM + + + Setter method for threshold on ThresholdingOutputStream + + + FileUtils.waitFor(...) swallows thread interrupted status + + + Support for symlinks with missing target. Added support for JDK7 symlink features when present + + + Added testcase to show this was fixed with IO-423 + + + Correct exception message in FileUtils.getFile(File, String...) + + + Introduce new class AppendableOutputStream + + + Update to JUnit 4.12 + + + IOExceptionWithCause no longer needed + + + Add WindowsLineEndingInputStream and UnixLineEndingInputStream. + + + 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. + + + Regression in FileUtils.readFileToString from 2.0.1 + + + ant test fails - resources missing from test classpath + + + Document that FileUtils.deleteDirectory, directoryContains and cleanDirectory + may throw an IllegalArgumentException in case the passed directory does not + exist or is not a directory. + + + Add API IOUtils.closeQuietly(Closeable...) + + + Javadoc fixes, mostly to appease 1.8.0 + + + Deprecate Charsets Charset constants in favor of Java 7's java.nio.charset.StandardCharsets + + + Readfully() That Returns A Byte Array + + + Overload IOUtils buffer methods to accept buffer size + + + FileUtils.sizeOfDirectory can throw IllegalArgumentException + + + FileUtils.sizeOfDirectoryAsBigInteger can overflow. + Ensure that recursive calls all use BigInteger + + + Chunked IO for large arrays. + Added writeChunked(byte[], OutputStream) and writeChunked(char[] Writer) + Added ChunkedOutputStream, ChunkedWriter + + + FileUtils.doCopyFile can potentially loop for ever + Exit loop if no data to copy + + + FileUtils.doCopyFile caches the file size; needs to be documented + Added Javadoc; show file lengths in exception message + + + Convert IOCase to a Java 1.5+ Enumeration + [N.B. this is binary compatible] + + + Add Methods for Buffering Streams/Writers To IOUtils + Added overloaded buffer() methods - see also IO-330 + + + IOUtils#toBufferedOutputStream/toBufferedWriter to conditionally wrap the output + Added overloaded buffer() methods - see also IO-233 + + + Add FileUtils.copyInputStreamToFile API with option to leave the source open. + See copyInputStreamToFile(final InputStream source, final File destination, boolean closeSource) + + + FileUtils.copyInputStreamToFile should document it closes the input source + + + Tailer erroneously considers file as new. + Fix to use file.lastModified() rather than System.currentTimeMillis() + + + 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 + + + CharSequenceInputStream - add tests for available() + Fix code so it really does reflect a minimum available. + + + getPrefixLength returns null if filename has leading slashes + Javadoc: add examples to show correct behaviour; add unit tests + + + FileUtils.listFilesAndDirs includes original dir in results even when it doesn't match filter + Javadoc: clarify that original dir is included in the results + + + Add ByteArrayOutputStream.toInputStream() + + + ClassLoaderObjectInputStream does not handle primitive typed members + + + A constant for holding the BOM character (U+FEFF) + + + Deprecate all methods that use the default encoding + + + When a file is rotated, finish reading previous file prior to starting new one + + + Commons IO Tailer does not respect UTF-8 Charset. + + + What should happen in FileUtils.sizeOf[Directory] when an overflow takes place? + Added Javadoc. + + + FileUtils.moveDirectory can produce misleading error message on failiure + + + FilenameUtils.splitOnTokens(String text) check for '**' could be simplified + + + WildcardFileFilter ctors should not use null to mean IOCase.SENSITIVE when delegating to other ctors + + + IOUtils.contentEquals* methods returns false if input1 == input2, should return true. + + + Add API FileUtils.forceMkdirsParent(). + + + Add API Charsets.requiredCharsets(). + + + Add IOUtils.skip and skipFully(ReadableByteChannel, long). + + + Add IOUtils.read and readFully(ReadableByteChannel, ByteBuffer buffer). + + + [Tailer] InterruptedException while the thread is sleeping is silently ignored + + + Add API IOUtils.copy(InputStream, OutputStream, int) + + + Add API with array offset and length argument to FileUtils.writeByteArrayToFile. + + + Spelling fixes. + + + Missing information in IllegalArgumentException thrown by org.apache.commons.io.FileUtils#validateListFilesParameters. + + + Supply a hook method allowing Tailer actively determining stop condition. + + + Improper JavaDoc comment for FilenameUtils.indexOfExtension. + + + Make IOUtils.EOF public and reuse it in various classes. + + + + + + org.apache.commons.io.comparator Javadoc is inconsistent with real code. + + + Yottabyte (YB) incorrectly defined in FileUtils. + + + Tailer locks file from deletion/rename on Windows. + + + Tailer erroneously considers file as new. + + + Tailer#readLines - incorrect CR handling. + + + FileUtils.toURLs throws NPE for null parameter; document the behavior. + + + Export OSGi packages at version 1.x in addition to 2.x. + + + Add XmlStreamReader support for UTF-32. + + + BOMInputStream wrongly detects UTF-32LE_BOM files as UTF-16LE_BOM files in method getBOM(). + + + Improve tailer's reading performance. + + + Improve Tailer performance with buffered reads (see IO-332). + + + FileUtils.writeLines uses unbuffered IO. + + + Add byteCountToDisplaySize(BigInteger). + + + Add new FileUtils.sizeOf[Directory] APIs to return BigInteger. + + + Add IOUtils.toByteArray methods to work with URL and URI. + + + Add missing Charset sister APIs to method that take a String charset name. + + + FileUtils.sizeOfDirectory follows symbolic links. + + + + + + Add and use class Charsets. + + + ByteOrderMark UTF_32LE is incorrect. + + + Add Charset sister APIs to method that take a String charset name. + + + + + Add IOUTils.toBufferedReader(Reader) + + + + Allow applications to provide buffer (or size) for copyLarge methods. + + + IOUtils.read(InputStream/Reader) ignores the offset parameter + + + CharSequenceInputStream(CharSequence s, Charset charset, int bufferSize) ignores bufferSize + + + New copyLarge() method in IOUtils that takes additional offset, length arguments + + + FileUtils.moveDirectoryToDirectory removes source directory if destination is a sub-directory + + + ReaderInputStream#read(byte[] b, int off, int len) should check for valid parameters + + + Use terabyte (TB), petabyte (PB) and exabyte (EB) in FileUtils.byteCountToDisplaySize(long size) + + + ReaderInputStream#read(byte[] b, int off, int len) should always return 0 for length == 0 + + + FileUtils.listFiles() doesn't return directories + + + "FileUtils#deleteDirectoryOnExit(File)" does not work + + + BoundedInputStream.read() treats max differently from BoundedInputStream.read(byte[]...) + + + CharSequenceInputStream to efficiently stream content of a CharSequence + + + ReaderInputStream optimization: more efficient reading of small chunks of data + + + Various methods of class 'org.apache.commons.io.FileUtils' incorrectly suppress 'java.io.IOException' + + + The second constructor of Tailer class does not pass 'delay' to the third one + + + TeeOutputStream does not call branch.close() when main.close() throws an exception + + + ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times + + + Add IOUtils.closeQuietly(Selector) necessary + + + IOUtils.closeQuietly() should take a ServerSocket as a parameter + + + Add read/readFully methods to IOUtils + + + Supply a ReversedLinesFileReader + + + Add new function FileUtils.directoryContains. + + + FileUtils.contentEquals and IOUtils.contentEquals - Add option to ignore "line endings" + Added contentEqualsIgnoreEOL methods to both classes + + + + + Use standard Maven directory layout + + + Add IOUtils API toString for URL and URI to get contents + + + Add API FileUtils.copyFile(File input, OutputStream output) + + + Dubious use of mkdirs() return code + + + ReaderInputStream enters infinite loop when it encounters an unmappable character + + + FileUtils.moveFile() JavaDoc should specify FileExistsException thrown + + + FileAlterationObserver has no getter for FileFilter + + + Add FileUtils.getFile API with varargs parameter + + + ClassLoaderObjectInputStream does not handle Proxy classes + + + FileAlterationMonitor.stop(boolean allowIntervalToFinish) + + + Add new APPEND parameter for writing string into files + + + Tailer returning partial lines when reaching EOF before EOL + + + FileUtils.copyFile() throws IOException when copying large files to a shared directory (on Windows) + + + FileSystemUtils.freeSpaceKb throws exception for Windows volumes with no visible files. + Improve coverage by also looking for hidden files. + + + Add new read method "toByteArray" to handle InputStream with known size. + + + + + + + TODO: Convert RELEASE-NOTES.txt from 2.0.1? + + + + + + TODO: Convert RELEASE-NOTES.txt from 2.0? + + + + + + TODO: Convert RELEASE-NOTES.txt from 1.4? + + + + + + Some tests, which are implicitly assuming a Unix-like file + system, are now skipped on Windows. + + + Created the FileCleaningTracker, basically a non-static + version of the FileCleaner, which can be controlled by + the user. + + + EndianUtils - both readSwappedUnsignedInteger(...) methods could + return negative numbers due to int/long casting. + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/changes/release-notes.vm" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/changes/release-notes.vm" new file mode 100644 index 0000000000000000000000000000000000000000..b39b90a3f107ab54cedde0e11efbf779fe4c5217 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/changes/release-notes.vm" @@ -0,0 +1,1029 @@ +## 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("(?Wikipedia: Byte Order Mark + * @see W3C: Autodetection of Character Encodings + * (Non-Normative) + * @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 Byte Order Mark (BOM) FAQ + * @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(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/Charsets.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/Charsets.java" new file mode 100644 index 0000000000000000000000000000000000000000..6a0b23f89da22abc701fb1d84802ac40ec9df2dc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/Charsets.java" @@ -0,0 +1,192 @@ +/* + * 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 + * Standard charsets: + *

+ * 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. + *

+ * + *
    + *
  • US-ASCII
    + * Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.
  • + *
  • ISO-8859-1
    + * ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
  • + *
  • UTF-8
    + * Eight-bit Unicode Transformation Format.
  • + *
  • UTF-16BE
    + * Sixteen-bit Unicode Transformation Format, big-endian byte order.
  • + *
  • UTF-16LE
    + * Sixteen-bit Unicode Transformation Format, little-endian byte order.
  • + *
  • UTF-16
    + * 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.)
  • + *
+ * + * @see Standard charsets + * @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. + *

+ * From the Java documentation + * Standard charsets: + *

+ * + * @return An immutable, case-insensitive map from canonical charset names to charset objects. + * @see Charset#availableCharsets() + * @since 2.5 + */ + public static SortedMap requiredCharsets() { + // maybe cache? + // TODO Re-implement on Java 7 to use java.nio.charset.StandardCharsets + final TreeMap m = new TreeMap(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. + *

+ * Every implementation of the Java platform is required to support this character encoding. + *

+ * + * @see Standard charsets + * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} + */ + @Deprecated + public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1"); + + /** + *

+ * Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. + *

+ *

+ * Every implementation of the Java platform is required to support this character encoding. + *

+ * + * @see Standard charsets + * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} + */ + @Deprecated + public static final Charset US_ASCII = Charset.forName("US-ASCII"); + + /** + *

+ * 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) + *

+ *

+ * Every implementation of the Java platform is required to support this character encoding. + *

+ * + * @see Standard charsets + * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} + */ + @Deprecated + public static final Charset UTF_16 = Charset.forName("UTF-16"); + + /** + *

+ * Sixteen-bit Unicode Transformation Format, big-endian byte order. + *

+ *

+ * Every implementation of the Java platform is required to support this character encoding. + *

+ * + * @see Standard charsets + * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} + */ + @Deprecated + public static final Charset UTF_16BE = Charset.forName("UTF-16BE"); + + /** + *

+ * Sixteen-bit Unicode Transformation Format, little-endian byte order. + *

+ *

+ * Every implementation of the Java platform is required to support this character encoding. + *

+ * + * @see Standard charsets + * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} + */ + @Deprecated + public static final Charset UTF_16LE = Charset.forName("UTF-16LE"); + + /** + *

+ * Eight-bit Unicode Transformation Format. + *

+ *

+ * Every implementation of the Java platform is required to support this character encoding. + *

+ * + * @see Standard charsets + * @deprecated Use Java 7's {@link java.nio.charset.StandardCharsets} + */ + @Deprecated + public static final Charset UTF_8 = Charset.forName("UTF-8"); +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/CopyUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/CopyUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..e01917b7b866d7849fc14763305ceb88edf00271 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/CopyUtils.java" @@ -0,0 +1,392 @@ +/* + * 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 (InputStream, Reader, + * String and byte[]) and destinations + * (OutputStream, Writer, String and + * byte[]). + *

+ * Unless otherwise noted, these copy methods do not + * 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' close() 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 + * this + * UnixReview article. + *

+ * For byte-to-char methods, a copy 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. + *

+ * We don't provide special variants for the copy 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. + *

+ * The copy methods use an internal buffer when copying. It is + * therefore advisable not to deliberately wrap the stream arguments + * to the copy methods in Buffered* streams. For + * example, don't do the following: + *

+ *  copy( new BufferedInputStream( in ), new BufferedOutputStream( out ) );
+ *  
+ * The rationale is as follows: + *

+ * 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 + * read requests can inexpensively get their data (until the buffer + * runs out). + *

+ * However, the copy 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). + *

+ * Behold, intrepid explorers; a map of this class: + *

+ *       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)
+ * 
+ *

+ * 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. + *

+ * 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). + */ +@Deprecated +public 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 byte[] to an OutputStream. + * @param input the byte array to read from + * @param output the OutputStream 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 byte[] to chars on a + * Writer. + * The platform's default encoding is used for the byte-to-char conversion. + * @param input the byte array to read from + * @param output the Writer 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 byte[] to chars on a + * Writer, using the specified encoding. + * @param input the byte array to read from + * @param output the Writer to write to + * @param encoding The name of a supported character encoding. See the + * IANA + * Charset Registry 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 InputStream to an + * OutputStream. + * @param input the InputStream to read from + * @param output the OutputStream 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 Reader to a Writer. + * @param input the Reader to read from + * @param output the Writer 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 InputStream to chars on a + * Writer. + * The platform's default encoding is used for the byte-to-char conversion. + * @param input the InputStream to read from + * @param output the Writer 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 InputStream to chars on a + * Writer, using the specified encoding. + * @param input the InputStream to read from + * @param output the Writer to write to + * @param encoding The name of a supported character encoding. See the + * IANA + * Charset Registry 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 Reader to bytes on an + * OutputStream, and flush the OutputStream. + * Uses the default platform encoding. + * @param input the Reader to read from + * @param output the OutputStream 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 Reader to bytes on an + * OutputStream, and flush the OutputStream. + * @param input the Reader to read from + * @param output the OutputStream to write to + * @param encoding The name of a supported character encoding. See the + * IANA + * Charset Registry 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 String to bytes on an + * OutputStream, and + * flush the OutputStream. + * Uses the platform default encoding. + * @param input the String to read from + * @param output the OutputStream 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 String to bytes on an + * OutputStream, and + * flush the OutputStream. + * @param input the String to read from + * @param output the OutputStream to write to + * @param encoding The name of a supported character encoding. See the + * IANA + * Charset Registry 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 String to a Writer. + * @param input the String to read from + * @param output the Writer 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); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/DirectoryWalker.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/DirectoryWalker.java" new file mode 100644 index 0000000000000000000000000000000000000000..356e0b3b1f2fd62e74d5861086cec14d80b8c02a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/DirectoryWalker.java" @@ -0,0 +1,642 @@ +/* + * 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. + *

+ * 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 + * filefilter package. + *

+ * The following sections describe: + *

+ * + * + *

1. Example Implementation

+ * + * There are many possible extensions, for example, to delete all + * files and '.svn' directories, and return a list of deleted files: + *
+ *  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);
+ *    }
+ *  }
+ * 
+ * + * + *

2. Filter Example

+ * + * 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. + *

+ * The first option is to visit all directories and files. + * This is achieved via the no-args constructor. + *

+ * 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. + *

+ * For example, if you wanted all directories which are not hidden + * and files which end in ".txt": + *

+ *  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);
+ * 
+ *

+ * The third constructor option is to specify separate filters, one for + * directories and one for files. These are combined internally to form + * the correct FileFilter, something which is very easy to + * get wrong when attempted manually, particularly when trying to + * express constructs like 'any file in directories named docs'. + *

+ * For example, if you wanted all directories which are not hidden + * and files which end in ".txt": + *

+ *  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"),
+ *  );
+ * 
+ * This is much simpler than the previous example, and is why it is the preferred + * option for filtering. + * + * + *

3. Cancellation

+ * + * The DirectoryWalker contains some of the logic required for cancel processing. + * Subclasses must complete the implementation. + *

+ * What DirectoryWalker does provide for cancellation is: + *

    + *
  • {@link CancelException} which can be thrown in any of the + * lifecycle methods to stop processing.
  • + *
  • The walk() method traps thrown {@link CancelException} + * and calls the handleCancelled() method, providing + * a place for custom cancel processing.
  • + *
+ *

+ * Implementations need to provide: + *

    + *
  • The decision logic on whether to cancel processing or not.
  • + *
  • Constructing and throwing a {@link CancelException}.
  • + *
  • Custom cancel processing in the handleCancelled() method. + *
+ *

+ * Two possible scenarios are envisaged for cancellation: + *

    + *
  • 3.1 External / Mult-threaded - cancellation being + * decided/initiated by an external process.
  • + *
  • 3.2 Internal - cancellation being decided/initiated + * from within a DirectoryWalker implementation.
  • + *
+ *

+ * The following sections provide example implementations for these two different + * scenarios. + * + * + *

3.1 External / Multi-threaded

+ * + * This example provides a public cancel() 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 + * + * volatile flag to ensure it will work properly in a multi-threaded environment. + * The flag is returned by the handleIsCancelled() method, which + * will cause the walk to stop immediately. The handleCancelled() + * method will be the next, and last, callback method received once cancellation + * has occurred. + * + *
+ *  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
+ *    }
+ *  }
+ * 
+ * + * + *

3.2 Internal

+ * + * This shows an example of how internal cancellation processing could be implemented. + * Note the decision logic and throwing a {@link CancelException} could be implemented + * in any of the lifecycle methods. + * + *
+ *  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
+ *    }
+ *  }
+ * 
+ * + * @since 1.3 + * @version $Id: DirectoryWalker.java 1723627 2016-01-07 21:15:47Z niallp $ + */ +public abstract class DirectoryWalker { + + /** + * 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 depth. + */ + protected DirectoryWalker() { + this(null, -1); + } + + /** + * Construct an instance with a filter and limit the depth navigated to. + *

+ * 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 deep 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 depth navigated to. + *

+ * 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 deep 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. + *

+ * 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. + *

+ * 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 handle. + * + * @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 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 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 CancelException if it has. + *

+ * 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 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. + *

+ * This method should be implemented by those subclasses that want to + * provide a public cancel() method available from another + * thread. The design pattern for the subclass should be as follows: + *

+     *  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
+     *    }
+     *  }
+     * 
+ *

+ * If this method returns true, then the directory walk is immediately + * cancelled. The next callback method will be {@link #handleCancelled}. + *

+ * 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 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. + *

+ * 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 results, + final CancelException cancel) throws IOException { + // re-throw exception - overridable by subclass + throw cancel; + } + + //----------------------------------------------------------------------- + /** + * Overridable callback method invoked at the start of processing. + *

+ * 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 results) throws IOException { + // do nothing - overridable by subclass + } + + /** + * Overridable callback method invoked to determine if a directory should be processed. + *

+ * 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. + *

+ * 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 results) throws + IOException { + // do nothing - overridable by subclass + return true; // process directory + } + + /** + * Overridable callback method invoked at the start of processing each directory. + *

+ * 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 results) throws + IOException { + // do nothing - overridable by subclass + } + + /** + * Overridable callback method invoked with the contents of each directory. + *

+ * 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. + *

+ * 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 results) throws IOException { + // do nothing - overridable by subclass + } + + /** + * Overridable callback method invoked for each restricted directory. + *

+ * 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 results) throws + IOException { + // do nothing - overridable by subclass + } + + /** + * Overridable callback method invoked at the end of processing each directory. + *

+ * 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 results) throws + IOException { + // do nothing - overridable by subclass + } + + /** + * Overridable callback method invoked at the end of processing. + *

+ * 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 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 CancelException 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 CancelException 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; + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/EndianUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/EndianUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..dba2d9bf3256695ea423de2d9f883806e030a2da --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/EndianUtils.java" @@ -0,0 +1,482 @@ +/* + * 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. + *

+ * 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. + *

+ * 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; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaner.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaner.java" new file mode 100644 index 0000000000000000000000000000000000000000..d214e3400ab80baeb2fbb558912b84db4a5451a1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaner.java" @@ -0,0 +1,160 @@ +/* + * 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. + *

+ * 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. + *

+ * 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} + */ +@Deprecated +public 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. + *

+ * 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. + *

+ * 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. + *

+ * 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; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaningTracker.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaningTracker.java" new file mode 100644 index 0000000000000000000000000000000000000000..cda40e97f5f0276f104e011c1aee3fbd29a3f892 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileCleaningTracker.java" @@ -0,0 +1,288 @@ +/* + * 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. + *

+ * 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. + *

+ * 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 Tracker instances being watched. + */ + ReferenceQueue q = new ReferenceQueue(); + /** + * Collection of Tracker instances in existence. + */ + final Collection trackers = Collections.synchronizedSet(new HashSet()); // synchronized + /** + * Collection of File paths that failed to delete. + */ + final List deleteFailures = Collections.synchronizedList(new ArrayList()); + /** + * 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 getDeleteFailures() { + return deleteFailures; + } + + /** + * Call this method to cause the file cleaner thread to terminate when + * there are no more objects being tracked for deletion. + *

+ * 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. + *

+ * 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. + *

+ * 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 { + + /** + * 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 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)); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileDeleteStrategy.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileDeleteStrategy.java" new file mode 100644 index 0000000000000000000000000000000000000000..4bdc22dc153148b173a8de934221dcc8df958596 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileDeleteStrategy.java" @@ -0,0 +1,157 @@ +/* + * 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. + *

+ * 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. + *

+ * 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 IOExceptions are caught and false returned instead. + * If the file does not exist or is null, true is returned. + *

+ * 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. + *

+ * 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. + *

+ * This method is designed for subclasses to override. + * The implementation may return either false or an IOException + * 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. + *

+ * 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. + *

+ * This implementation uses FileUtils.forceDelete() + * 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; + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileExistsException.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileExistsException.java" new file mode 100644 index 0000000000000000000000000000000000000000..d886efe3f1be2b344b6f628bc9c5deac54800bf3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileExistsException.java" @@ -0,0 +1,60 @@ +/* + * 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"); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileSystemUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileSystemUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..cefd2901b994ad2d92f795ad3492b6c2b84cbf62 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileSystemUtils.java" @@ -0,0 +1,541 @@ +/* + * 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. + *

+ * This class provides static utility methods for general file system + * functions not provided via the JDK {@link java.io.File File} class. + *

+ * The current functions provided are: + *

    + *
  • Get the free space on a drive + *
+ * + * @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. + *

+ * Note that some OS's are NOT currently supported, including OS/390, + * OpenVMS. + *

+     * FileSystemUtils.freeSpace("C:");       // Windows
+     * FileSystemUtils.freeSpace("/volume");  // *nix
+     * 
+ * 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. + *
+     * FileSystemUtils.freeSpaceKb("C:");       // Windows
+     * FileSystemUtils.freeSpaceKb("/volume");  // *nix
+     * 
+ * 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. + *

+ * 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. + *

+     * FileSystemUtils.freeSpaceKb("C:");       // Windows
+     * FileSystemUtils.freeSpaceKb("/volume");  // *nix
+     * 
+ * 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. + *

+ * 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. + *

+ * Identical to: + *

+     * freeSpaceKb(new File(".").getAbsolutePath())
+     * 
+ * @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. + *

+ * Identical to: + *

+     * freeSpaceKb(new File(".").getAbsolutePath())
+     * 
+ * @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. + *
+     * FileSystemUtils.freeSpace("C:");  // Windows
+     * FileSystemUtils.freeSpace("/volume");  // *nix
+     * 
+ * 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 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 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 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 lines = new ArrayList(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); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..ddd80ffcb5e37cd765e4b556dc25d21941f9dc4b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FileUtils.java" @@ -0,0 +1,3146 @@ +/* + * 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.BufferedOutputStream; +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.Reader; +import java.math.BigInteger; +import java.net.URL; +import java.net.URLConnection; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.zip.CRC32; +import java.util.zip.CheckedInputStream; +import java.util.zip.Checksum; + +import org.apache.commons.io.filefilter.DirectoryFileFilter; +import org.apache.commons.io.filefilter.FalseFileFilter; +import org.apache.commons.io.filefilter.FileFilterUtils; +import org.apache.commons.io.filefilter.IOFileFilter; +import org.apache.commons.io.filefilter.SuffixFileFilter; +import org.apache.commons.io.filefilter.TrueFileFilter; +import org.apache.commons.io.output.NullOutputStream; + +/** + * General file manipulation utilities. + *

+ * Facilities are provided in the following areas: + *

    + *
  • writing to a file + *
  • reading from a file + *
  • make a directory including parent directories + *
  • copying files and directories + *
  • deleting files and directories + *
  • converting to and from a URL + *
  • listing files and directories by filter and extension + *
  • comparing file content + *
  • file last changed date + *
  • calculating a checksum + *
+ *

+ * Origin of code: Excalibur, Alexandria, Commons-Utils + * + * @version $Id: FileUtils.java 1722481 2016-01-01 01:42:04Z dbrosius $ + */ +public class FileUtils { + + /** + * Instances should NOT be constructed in standard programming. + */ + public FileUtils() { + super(); + } + + /** + * The number of bytes in a kilobyte. + */ + public static final long ONE_KB = 1024; + + /** + * The number of bytes in a kilobyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_KB_BI = BigInteger.valueOf(ONE_KB); + + /** + * The number of bytes in a megabyte. + */ + public static final long ONE_MB = ONE_KB * ONE_KB; + + /** + * The number of bytes in a megabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_MB_BI = ONE_KB_BI.multiply(ONE_KB_BI); + + /** + * The file copy buffer size (30 MB) + */ + private static final long FILE_COPY_BUFFER_SIZE = ONE_MB * 30; + + /** + * The number of bytes in a gigabyte. + */ + public static final long ONE_GB = ONE_KB * ONE_MB; + + /** + * The number of bytes in a gigabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_GB_BI = ONE_KB_BI.multiply(ONE_MB_BI); + + /** + * The number of bytes in a terabyte. + */ + public static final long ONE_TB = ONE_KB * ONE_GB; + + /** + * The number of bytes in a terabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_TB_BI = ONE_KB_BI.multiply(ONE_GB_BI); + + /** + * The number of bytes in a petabyte. + */ + public static final long ONE_PB = ONE_KB * ONE_TB; + + /** + * The number of bytes in a petabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_PB_BI = ONE_KB_BI.multiply(ONE_TB_BI); + + /** + * The number of bytes in an exabyte. + */ + public static final long ONE_EB = ONE_KB * ONE_PB; + + /** + * The number of bytes in an exabyte. + * + * @since 2.4 + */ + public static final BigInteger ONE_EB_BI = ONE_KB_BI.multiply(ONE_PB_BI); + + /** + * The number of bytes in a zettabyte. + */ + public static final BigInteger ONE_ZB = BigInteger.valueOf(ONE_KB).multiply(BigInteger.valueOf(ONE_EB)); + + /** + * The number of bytes in a yottabyte. + */ + public static final BigInteger ONE_YB = ONE_KB_BI.multiply(ONE_ZB); + + /** + * An empty array of type File. + */ + public static final File[] EMPTY_FILE_ARRAY = new File[0]; + + //----------------------------------------------------------------------- + /** + * Construct a file from the set of name elements. + * + * @param directory the parent directory + * @param names the name elements + * @return the file + * @since 2.1 + */ + public static File getFile(final File directory, final String... names) { + if (directory == null) { + throw new NullPointerException("directory must not be null"); + } + if (names == null) { + throw new NullPointerException("names must not be null"); + } + File file = directory; + for (final String name : names) { + file = new File(file, name); + } + return file; + } + + /** + * Construct a file from the set of name elements. + * + * @param names the name elements + * @return the file + * @since 2.1 + */ + public static File getFile(final String... names) { + if (names == null) { + throw new NullPointerException("names must not be null"); + } + File file = null; + for (final String name : names) { + if (file == null) { + file = new File(name); + } else { + file = new File(file, name); + } + } + return file; + } + + /** + * Returns the path to the system temporary directory. + * + * @return the path to the system temporary directory. + * + * @since 2.0 + */ + public static String getTempDirectoryPath() { + return System.getProperty("java.io.tmpdir"); + } + + /** + * Returns a {@link File} representing the system temporary directory. + * + * @return the system temporary directory. + * + * @since 2.0 + */ + public static File getTempDirectory() { + return new File(getTempDirectoryPath()); + } + + /** + * Returns the path to the user's home directory. + * + * @return the path to the user's home directory. + * + * @since 2.0 + */ + public static String getUserDirectoryPath() { + return System.getProperty("user.home"); + } + + /** + * Returns a {@link File} representing the user's home directory. + * + * @return the user's home directory. + * + * @since 2.0 + */ + public static File getUserDirectory() { + return new File(getUserDirectoryPath()); + } + + //----------------------------------------------------------------------- + /** + * Opens a {@link FileInputStream} for the specified file, providing better + * error messages than simply calling new FileInputStream(file). + *

+ * At the end of the method either the stream will be successfully opened, + * or an exception will have been thrown. + *

+ * An exception is thrown if the file does not exist. + * An exception is thrown if the file object exists but is a directory. + * An exception is thrown if the file exists but cannot be read. + * + * @param file the file to open for input, must not be {@code null} + * @return a new {@link FileInputStream} for the specified file + * @throws FileNotFoundException if the file does not exist + * @throws IOException if the file object is a directory + * @throws IOException if the file cannot be read + * @since 1.3 + */ + public static FileInputStream openInputStream(final File file) throws IOException { + if (file.exists()) { + if (file.isDirectory()) { + throw new IOException("File '" + file + "' exists but is a directory"); + } + if (file.canRead() == false) { + throw new IOException("File '" + file + "' cannot be read"); + } + } else { + throw new FileNotFoundException("File '" + file + "' does not exist"); + } + return new FileInputStream(file); + } + + //----------------------------------------------------------------------- + /** + * Opens a {@link FileOutputStream} for the specified file, checking and + * creating the parent directory if it does not exist. + *

+ * At the end of the method either the stream will be successfully opened, + * or an exception will have been thrown. + *

+ * The parent directory will be created if it does not exist. + * The file will be created if it does not exist. + * An exception is thrown if the file object exists but is a directory. + * An exception is thrown if the file exists but cannot be written to. + * An exception is thrown if the parent directory cannot be created. + * + * @param file the file to open for output, must not be {@code null} + * @return a new {@link FileOutputStream} for the specified file + * @throws IOException if the file object is a directory + * @throws IOException if the file cannot be written to + * @throws IOException if a parent directory needs creating but that fails + * @since 1.3 + */ + public static FileOutputStream openOutputStream(final File file) throws IOException { + return openOutputStream(file, false); + } + + /** + * Opens a {@link FileOutputStream} for the specified file, checking and + * creating the parent directory if it does not exist. + *

+ * At the end of the method either the stream will be successfully opened, + * or an exception will have been thrown. + *

+ * The parent directory will be created if it does not exist. + * The file will be created if it does not exist. + * An exception is thrown if the file object exists but is a directory. + * An exception is thrown if the file exists but cannot be written to. + * An exception is thrown if the parent directory cannot be created. + * + * @param file the file to open for output, must not be {@code null} + * @param append if {@code true}, then bytes will be added to the + * end of the file rather than overwriting + * @return a new {@link FileOutputStream} for the specified file + * @throws IOException if the file object is a directory + * @throws IOException if the file cannot be written to + * @throws IOException if a parent directory needs creating but that fails + * @since 2.1 + */ + public static FileOutputStream openOutputStream(final File file, final boolean append) throws IOException { + if (file.exists()) { + if (file.isDirectory()) { + throw new IOException("File '" + file + "' exists but is a directory"); + } + if (file.canWrite() == false) { + throw new IOException("File '" + file + "' cannot be written to"); + } + } else { + final File parent = file.getParentFile(); + if (parent != null) { + if (!parent.mkdirs() && !parent.isDirectory()) { + throw new IOException("Directory '" + parent + "' could not be created"); + } + } + } + return new FileOutputStream(file, append); + } + + //----------------------------------------------------------------------- + /** + * Returns a human-readable version of the file size, where the input represents a specific number of bytes. + *

+ * If the size is over 1GB, the size is returned as the number of whole GB, i.e. the size is rounded down to the + * nearest GB boundary. + *

+ *

+ * Similarly for the 1MB and 1KB boundaries. + *

+ * + * @param size the number of bytes + * @return a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes) + * @see IO-226 - should the rounding be changed? + * @since 2.4 + */ + // See https://issues.apache.org/jira/browse/IO-226 - should the rounding be changed? + public static String byteCountToDisplaySize(final BigInteger size) { + String displaySize; + + if (size.divide(ONE_EB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_EB_BI)) + " EB"; + } else if (size.divide(ONE_PB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_PB_BI)) + " PB"; + } else if (size.divide(ONE_TB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_TB_BI)) + " TB"; + } else if (size.divide(ONE_GB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_GB_BI)) + " GB"; + } else if (size.divide(ONE_MB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_MB_BI)) + " MB"; + } else if (size.divide(ONE_KB_BI).compareTo(BigInteger.ZERO) > 0) { + displaySize = String.valueOf(size.divide(ONE_KB_BI)) + " KB"; + } else { + displaySize = String.valueOf(size) + " bytes"; + } + return displaySize; + } + + /** + * Returns a human-readable version of the file size, where the input represents a specific number of bytes. + *

+ * If the size is over 1GB, the size is returned as the number of whole GB, i.e. the size is rounded down to the + * nearest GB boundary. + *

+ *

+ * Similarly for the 1MB and 1KB boundaries. + *

+ * + * @param size the number of bytes + * @return a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes) + * @see IO-226 - should the rounding be changed? + */ + // See https://issues.apache.org/jira/browse/IO-226 - should the rounding be changed? + public static String byteCountToDisplaySize(final long size) { + return byteCountToDisplaySize(BigInteger.valueOf(size)); + } + + //----------------------------------------------------------------------- + /** + * Implements the same behaviour as the "touch" utility on Unix. It creates + * a new file with size 0 or, if the file exists already, it is opened and + * closed without modifying it, but updating the file date and time. + *

+ * NOTE: As from v1.3, this method throws an IOException if the last + * modified date of the file cannot be set. Also, as from v1.3 this method + * creates parent directories if they do not exist. + * + * @param file the File to touch + * @throws IOException If an I/O problem occurs + */ + public static void touch(final File file) throws IOException { + if (!file.exists()) { + final OutputStream out = openOutputStream(file); + IOUtils.closeQuietly(out); + } + final boolean success = file.setLastModified(System.currentTimeMillis()); + if (!success) { + throw new IOException("Unable to set the last modification time for " + file); + } + } + + //----------------------------------------------------------------------- + /** + * Converts a Collection containing java.io.File instanced into array + * representation. This is to account for the difference between + * File.listFiles() and FileUtils.listFiles(). + * + * @param files a Collection containing java.io.File instances + * @return an array of java.io.File + */ + public static File[] convertFileCollectionToFileArray(final Collection files) { + return files.toArray(new File[files.size()]); + } + + //----------------------------------------------------------------------- + /** + * Finds files within a given directory (and optionally its + * subdirectories). All files found are filtered by an IOFileFilter. + * + * @param files the collection of files found. + * @param directory the directory to search in. + * @param filter the filter to apply to files and directories. + * @param includeSubDirectories indicates if will include the subdirectories themselves + */ + private static void innerListFiles(final Collection files, final File directory, + final IOFileFilter filter, final boolean includeSubDirectories) { + final File[] found = directory.listFiles((FileFilter) filter); + + if (found != null) { + for (final File file : found) { + if (file.isDirectory()) { + if (includeSubDirectories) { + files.add(file); + } + innerListFiles(files, file, filter, includeSubDirectories); + } else { + files.add(file); + } + } + } + } + + /** + * Finds files within a given directory (and optionally its + * subdirectories). All files found are filtered by an IOFileFilter. + *

+ * If your search should recurse into subdirectories you can pass in + * an IOFileFilter for directories. You don't need to bind a + * DirectoryFileFilter (via logical AND) to this filter. This method does + * that for you. + *

+ * An example: If you want to search through all directories called + * "temp" you pass in FileFilterUtils.NameFileFilter("temp") + *

+ * Another common usage of this method is find files in a directory + * tree but ignoring the directories generated CVS. You can simply pass + * in FileFilterUtils.makeCVSAware(null). + * + * @param directory the directory to search in + * @param fileFilter filter to apply when finding files. + * @param dirFilter optional filter to apply when finding subdirectories. + * If this parameter is {@code null}, subdirectories will not be included in the + * search. Use TrueFileFilter.INSTANCE to match all directories. + * @return an collection of java.io.File with the matching files + * @see org.apache.commons.io.filefilter.FileFilterUtils + * @see org.apache.commons.io.filefilter.NameFileFilter + */ + public static Collection listFiles( + final File directory, final IOFileFilter fileFilter, final IOFileFilter dirFilter) { + validateListFilesParameters(directory, fileFilter); + + final IOFileFilter effFileFilter = setUpEffectiveFileFilter(fileFilter); + final IOFileFilter effDirFilter = setUpEffectiveDirFilter(dirFilter); + + //Find files + final Collection files = new java.util.LinkedList(); + innerListFiles(files, directory, + FileFilterUtils.or(effFileFilter, effDirFilter), false); + return files; + } + + /** + * Validates the given arguments. + *

    + *
  • Throws {@link IllegalArgumentException} if {@code directory} is not a directory
  • + *
  • Throws {@link NullPointerException} if {@code fileFilter} is null
  • + *
+ * + * @param directory The File to test + * @param fileFilter The IOFileFilter to test + */ + private static void validateListFilesParameters(final File directory, final IOFileFilter fileFilter) { + if (!directory.isDirectory()) { + throw new IllegalArgumentException("Parameter 'directory' is not a directory: " + directory); + } + if (fileFilter == null) { + throw new NullPointerException("Parameter 'fileFilter' is null"); + } + } + + /** + * Returns a filter that accepts files in addition to the {@link File} objects accepted by the given filter. + * + * @param fileFilter a base filter to add to + * @return a filter that accepts files + */ + private static IOFileFilter setUpEffectiveFileFilter(final IOFileFilter fileFilter) { + return FileFilterUtils.and(fileFilter, FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE)); + } + + /** + * Returns a filter that accepts directories in addition to the {@link File} objects accepted by the given filter. + * + * @param dirFilter a base filter to add to + * @return a filter that accepts directories + */ + private static IOFileFilter setUpEffectiveDirFilter(final IOFileFilter dirFilter) { + return dirFilter == null ? FalseFileFilter.INSTANCE : FileFilterUtils.and(dirFilter, + DirectoryFileFilter.INSTANCE); + } + + /** + * Finds files within a given directory (and optionally its + * subdirectories). All files found are filtered by an IOFileFilter. + *

+ * The resulting collection includes the starting directory and + * any subdirectories that match the directory filter. + *

+ * + * @param directory the directory to search in + * @param fileFilter filter to apply when finding files. + * @param dirFilter optional filter to apply when finding subdirectories. + * If this parameter is {@code null}, subdirectories will not be included in the + * search. Use TrueFileFilter.INSTANCE to match all directories. + * @return an collection of java.io.File with the matching files + * @see org.apache.commons.io.FileUtils#listFiles + * @see org.apache.commons.io.filefilter.FileFilterUtils + * @see org.apache.commons.io.filefilter.NameFileFilter + * @since 2.2 + */ + public static Collection listFilesAndDirs( + final File directory, final IOFileFilter fileFilter, final IOFileFilter dirFilter) { + validateListFilesParameters(directory, fileFilter); + + final IOFileFilter effFileFilter = setUpEffectiveFileFilter(fileFilter); + final IOFileFilter effDirFilter = setUpEffectiveDirFilter(dirFilter); + + //Find files + final Collection files = new java.util.LinkedList(); + if (directory.isDirectory()) { + files.add(directory); + } + innerListFiles(files, directory, + FileFilterUtils.or(effFileFilter, effDirFilter), true); + return files; + } + + /** + * Allows iteration over the files in given directory (and optionally + * its subdirectories). + *

+ * All files found are filtered by an IOFileFilter. This method is + * based on {@link #listFiles(File, IOFileFilter, IOFileFilter)}, + * which supports Iterable ('foreach' loop). + *

+ * @param directory the directory to search in + * @param fileFilter filter to apply when finding files. + * @param dirFilter optional filter to apply when finding subdirectories. + * If this parameter is {@code null}, subdirectories will not be included in the + * search. Use TrueFileFilter.INSTANCE to match all directories. + * @return an iterator of java.io.File for the matching files + * @see org.apache.commons.io.filefilter.FileFilterUtils + * @see org.apache.commons.io.filefilter.NameFileFilter + * @since 1.2 + */ + public static Iterator iterateFiles( + final File directory, final IOFileFilter fileFilter, final IOFileFilter dirFilter) { + return listFiles(directory, fileFilter, dirFilter).iterator(); + } + + /** + * Allows iteration over the files in given directory (and optionally + * its subdirectories). + *

+ * All files found are filtered by an IOFileFilter. This method is + * based on {@link #listFilesAndDirs(File, IOFileFilter, IOFileFilter)}, + * which supports Iterable ('foreach' loop). + *

+ * The resulting iterator includes the subdirectories themselves. + * + * @param directory the directory to search in + * @param fileFilter filter to apply when finding files. + * @param dirFilter optional filter to apply when finding subdirectories. + * If this parameter is {@code null}, subdirectories will not be included in the + * search. Use TrueFileFilter.INSTANCE to match all directories. + * @return an iterator of java.io.File for the matching files + * @see org.apache.commons.io.filefilter.FileFilterUtils + * @see org.apache.commons.io.filefilter.NameFileFilter + * @since 2.2 + */ + public static Iterator iterateFilesAndDirs(final File directory, final IOFileFilter fileFilter, + final IOFileFilter dirFilter) { + return listFilesAndDirs(directory, fileFilter, dirFilter).iterator(); + } + + //----------------------------------------------------------------------- + /** + * Converts an array of file extensions to suffixes for use + * with IOFileFilters. + * + * @param extensions an array of extensions. Format: {"java", "xml"} + * @return an array of suffixes. Format: {".java", ".xml"} + */ + private static String[] toSuffixes(final String[] extensions) { + final String[] suffixes = new String[extensions.length]; + for (int i = 0; i < extensions.length; i++) { + suffixes[i] = "." + extensions[i]; + } + return suffixes; + } + + + /** + * Finds files within a given directory (and optionally its subdirectories) + * which match an array of extensions. + * + * @param directory the directory to search in + * @param extensions an array of extensions, ex. {"java","xml"}. If this + * parameter is {@code null}, all files are returned. + * @param recursive if true all subdirectories are searched as well + * @return an collection of java.io.File with the matching files + */ + public static Collection listFiles( + final File directory, final String[] extensions, final boolean recursive) { + IOFileFilter filter; + if (extensions == null) { + filter = TrueFileFilter.INSTANCE; + } else { + final String[] suffixes = toSuffixes(extensions); + filter = new SuffixFileFilter(suffixes); + } + return listFiles(directory, filter, + recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE); + } + + /** + * Allows iteration over the files in a given directory (and optionally + * its subdirectories) which match an array of extensions. This method + * is based on {@link #listFiles(File, String[], boolean)}, + * which supports Iterable ('foreach' loop). + * + * @param directory the directory to search in + * @param extensions an array of extensions, ex. {"java","xml"}. If this + * parameter is {@code null}, all files are returned. + * @param recursive if true all subdirectories are searched as well + * @return an iterator of java.io.File with the matching files + * @since 1.2 + */ + public static Iterator iterateFiles( + final File directory, final String[] extensions, final boolean recursive) { + return listFiles(directory, extensions, recursive).iterator(); + } + + //----------------------------------------------------------------------- + /** + * Compares the contents of two files to determine if they are equal or not. + *

+ * This method checks to see if the two files are different lengths + * or if they point to the same file, before resorting to byte-by-byte + * comparison of the contents. + *

+ * Code origin: Avalon + * + * @param file1 the first file + * @param file2 the second file + * @return true if the content of the files are equal or they both don't + * exist, false otherwise + * @throws IOException in case of an I/O error + */ + public static boolean contentEquals(final File file1, final File file2) throws IOException { + final boolean file1Exists = file1.exists(); + if (file1Exists != file2.exists()) { + return false; + } + + if (!file1Exists) { + // two not existing files are equal + return true; + } + + if (file1.isDirectory() || file2.isDirectory()) { + // don't want to compare directory contents + throw new IOException("Can't compare directories, only files"); + } + + if (file1.length() != file2.length()) { + // lengths differ, cannot be equal + return false; + } + + if (file1.getCanonicalFile().equals(file2.getCanonicalFile())) { + // same file + return true; + } + + InputStream input1 = null; + InputStream input2 = null; + try { + input1 = new FileInputStream(file1); + input2 = new FileInputStream(file2); + return IOUtils.contentEquals(input1, input2); + + } finally { + IOUtils.closeQuietly(input1); + IOUtils.closeQuietly(input2); + } + } + + //----------------------------------------------------------------------- + /** + * Compares the contents of two files to determine if they are equal or not. + *

+ * This method checks to see if the two files point to the same file, + * before resorting to line-by-line comparison of the contents. + *

+ * + * @param file1 the first file + * @param file2 the second file + * @param charsetName the character encoding to be used. + * May be null, in which case the platform default is used + * @return true if the content of the files are equal or neither exists, + * false otherwise + * @throws IOException in case of an I/O error + * @see IOUtils#contentEqualsIgnoreEOL(Reader, Reader) + * @since 2.2 + */ + public static boolean contentEqualsIgnoreEOL(final File file1, final File file2, final String charsetName) + throws IOException { + final boolean file1Exists = file1.exists(); + if (file1Exists != file2.exists()) { + return false; + } + + if (!file1Exists) { + // two not existing files are equal + return true; + } + + if (file1.isDirectory() || file2.isDirectory()) { + // don't want to compare directory contents + throw new IOException("Can't compare directories, only files"); + } + + if (file1.getCanonicalFile().equals(file2.getCanonicalFile())) { + // same file + return true; + } + + Reader input1 = null; + Reader input2 = null; + try { + if (charsetName == null) { + // N.B. make explicit the use of the default charset + input1 = new InputStreamReader(new FileInputStream(file1), Charset.defaultCharset()); + input2 = new InputStreamReader(new FileInputStream(file2), Charset.defaultCharset()); + } else { + input1 = new InputStreamReader(new FileInputStream(file1), charsetName); + input2 = new InputStreamReader(new FileInputStream(file2), charsetName); + } + return IOUtils.contentEqualsIgnoreEOL(input1, input2); + + } finally { + IOUtils.closeQuietly(input1); + IOUtils.closeQuietly(input2); + } + } + + //----------------------------------------------------------------------- + /** + * Convert from a URL to a File. + *

+ * From version 1.1 this method will decode the URL. + * Syntax such as file:///my%20docs/file.txt will be + * correctly decoded to /my docs/file.txt. Starting with version + * 1.5, this method uses UTF-8 to decode percent-encoded octets to characters. + * Additionally, malformed percent-encoded octets are handled leniently by + * passing them through literally. + * + * @param url the file URL to convert, {@code null} returns {@code null} + * @return the equivalent File object, or {@code null} + * if the URL's protocol is not file + */ + public static File toFile(final URL url) { + if (url == null || !"file".equalsIgnoreCase(url.getProtocol())) { + return null; + } else { + String filename = url.getFile().replace('/', File.separatorChar); + filename = decodeUrl(filename); + return new File(filename); + } + } + + /** + * Decodes the specified URL as per RFC 3986, i.e. transforms + * percent-encoded octets to characters by decoding with the UTF-8 character + * set. This function is primarily intended for usage with + * {@link java.net.URL} which unfortunately does not enforce proper URLs. As + * such, this method will leniently accept invalid characters or malformed + * percent-encoded octets and simply pass them literally through to the + * result string. Except for rare edge cases, this will make unencoded URLs + * pass through unaltered. + * + * @param url The URL to decode, may be {@code null}. + * @return The decoded URL or {@code null} if the input was + * {@code null}. + */ + @SuppressWarnings("deprecation") // unavoidable until Java 7 + static String decodeUrl(final String url) { + String decoded = url; + if (url != null && url.indexOf('%') >= 0) { + final int n = url.length(); + final StringBuilder buffer = new StringBuilder(); + final ByteBuffer bytes = ByteBuffer.allocate(n); + for (int i = 0; i < n; ) { + if (url.charAt(i) == '%') { + try { + do { + final byte octet = (byte) Integer.parseInt(url.substring(i + 1, i + 3), 16); + bytes.put(octet); + i += 3; + } while (i < n && url.charAt(i) == '%'); + continue; + } catch (final RuntimeException e) { + // malformed percent-encoded octet, fall through and + // append characters literally + } finally { + if (bytes.position() > 0) { + bytes.flip(); + buffer.append(Charsets.UTF_8.decode(bytes).toString()); + bytes.clear(); + } + } + } + buffer.append(url.charAt(i++)); + } + decoded = buffer.toString(); + } + return decoded; + } + + /** + * Converts each of an array of URL to a File. + *

+ * Returns an array of the same size as the input. + * If the input is {@code null}, an empty array is returned. + * If the input contains {@code null}, the output array contains {@code null} at the same + * index. + *

+ * This method will decode the URL. + * Syntax such as file:///my%20docs/file.txt will be + * correctly decoded to /my docs/file.txt. + * + * @param urls the file URLs to convert, {@code null} returns empty array + * @return a non-{@code null} array of Files matching the input, with a {@code null} item + * if there was a {@code null} at that index in the input array + * @throws IllegalArgumentException if any file is not a URL file + * @throws IllegalArgumentException if any file is incorrectly encoded + * @since 1.1 + */ + public static File[] toFiles(final URL[] urls) { + if (urls == null || urls.length == 0) { + return EMPTY_FILE_ARRAY; + } + final File[] files = new File[urls.length]; + for (int i = 0; i < urls.length; i++) { + final URL url = urls[i]; + if (url != null) { + if (url.getProtocol().equals("file") == false) { + throw new IllegalArgumentException( + "URL could not be converted to a File: " + url); + } + files[i] = toFile(url); + } + } + return files; + } + + /** + * Converts each of an array of File to a URL. + *

+ * Returns an array of the same size as the input. + * + * @param files the files to convert, must not be {@code null} + * @return an array of URLs matching the input + * @throws IOException if a file cannot be converted + * @throws NullPointerException if the parameter is null + */ + public static URL[] toURLs(final File[] files) throws IOException { + final URL[] urls = new URL[files.length]; + + for (int i = 0; i < urls.length; i++) { + urls[i] = files[i].toURI().toURL(); + } + + return urls; + } + + //----------------------------------------------------------------------- + /** + * Copies a file to a directory preserving the file date. + *

+ * This method copies the contents of the specified source file + * to a file of the same name in the specified destination directory. + * The destination directory is created if it does not exist. + * If the destination file exists, then this method will overwrite it. + *

+ * Note: This method tries to preserve the file's last + * modified date/times using {@link File#setLastModified(long)}, however + * it is not guaranteed that the operation will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcFile an existing file to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} + * + * @throws NullPointerException if source or destination is null + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @see #copyFile(File, File, boolean) + */ + public static void copyFileToDirectory(final File srcFile, final File destDir) throws IOException { + copyFileToDirectory(srcFile, destDir, true); + } + + /** + * Copies a file to a directory optionally preserving the file date. + *

+ * This method copies the contents of the specified source file + * to a file of the same name in the specified destination directory. + * The destination directory is created if it does not exist. + * If the destination file exists, then this method will overwrite it. + *

+ * Note: Setting preserveFileDate to + * {@code true} tries to preserve the file's last modified + * date/times using {@link File#setLastModified(long)}, however it is + * not guaranteed that the operation will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcFile an existing file to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} + * @param preserveFileDate true if the file date of the copy + * should be the same as the original + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @throws IOException if the output file length is not the same as the input file length after the copy + * completes + * @see #copyFile(File, File, boolean) + * @since 1.3 + */ + public static void copyFileToDirectory(final File srcFile, final File destDir, final boolean preserveFileDate) + throws IOException { + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); + } + if (destDir.exists() && destDir.isDirectory() == false) { + throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory"); + } + final File destFile = new File(destDir, srcFile.getName()); + copyFile(srcFile, destFile, preserveFileDate); + } + + /** + * Copies a file to a new location preserving the file date. + *

+ * This method copies the contents of the specified source file to the + * specified destination file. The directory holding the destination file is + * created if it does not exist. If the destination file exists, then this + * method will overwrite it. + *

+ * Note: This method tries to preserve the file's last + * modified date/times using {@link File#setLastModified(long)}, however + * it is not guaranteed that the operation will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcFile an existing file to copy, must not be {@code null} + * @param destFile the new file, must not be {@code null} + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @throws IOException if the output file length is not the same as the input file length after the copy + * completes + * @see #copyFileToDirectory(File, File) + * @see #copyFile(File, File, boolean) + */ + public static void copyFile(final File srcFile, final File destFile) throws IOException { + copyFile(srcFile, destFile, true); + } + + /** + * Copies a file to a new location. + *

+ * This method copies the contents of the specified source file + * to the specified destination file. + * The directory holding the destination file is created if it does not exist. + * If the destination file exists, then this method will overwrite it. + *

+ * Note: Setting preserveFileDate to + * {@code true} tries to preserve the file's last modified + * date/times using {@link File#setLastModified(long)}, however it is + * not guaranteed that the operation will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcFile an existing file to copy, must not be {@code null} + * @param destFile the new file, must not be {@code null} + * @param preserveFileDate true if the file date of the copy + * should be the same as the original + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @throws IOException if the output file length is not the same as the input file length after the copy + * completes + * @see #copyFileToDirectory(File, File, boolean) + * @see #doCopyFile(File, File, boolean) + */ + public static void copyFile(final File srcFile, final File destFile, + final boolean preserveFileDate) throws IOException { + checkFileRequirements(srcFile, destFile); + if (srcFile.isDirectory()) { + throw new IOException("Source '" + srcFile + "' exists but is a directory"); + } + if (srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) { + throw new IOException("Source '" + srcFile + "' and destination '" + destFile + "' are the same"); + } + final File parentFile = destFile.getParentFile(); + if (parentFile != null) { + if (!parentFile.mkdirs() && !parentFile.isDirectory()) { + throw new IOException("Destination '" + parentFile + "' directory cannot be created"); + } + } + if (destFile.exists() && destFile.canWrite() == false) { + throw new IOException("Destination '" + destFile + "' exists but is read-only"); + } + doCopyFile(srcFile, destFile, preserveFileDate); + } + + /** + * Copy bytes from a File to an OutputStream. + *

+ * This method buffers the input internally, so there is no need to use a BufferedInputStream. + *

+ * + * @param input the File to read from + * @param output the OutputStream to write to + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.1 + */ + public static long copyFile(final File input, final OutputStream output) throws IOException { + final FileInputStream fis = new FileInputStream(input); + try { + return IOUtils.copyLarge(fis, output); + } finally { + fis.close(); + } + } + + /** + * Internal copy file method. + * This caches the original file length, and throws an IOException + * if the output file length is different from the current input file length. + * So it may fail if the file changes size. + * It may also fail with "IllegalArgumentException: Negative size" if the input file is truncated part way + * through copying the data and the new file size is less than the current position. + * + * @param srcFile the validated source file, must not be {@code null} + * @param destFile the validated destination file, must not be {@code null} + * @param preserveFileDate whether to preserve the file date + * @throws IOException if an error occurs + * @throws IOException if the output file length is not the same as the input file length after the + * copy completes + * @throws IllegalArgumentException "Negative size" if the file is truncated so that the size is less than the + * position + */ + private static void doCopyFile(final File srcFile, final File destFile, final boolean preserveFileDate) + throws IOException { + if (destFile.exists() && destFile.isDirectory()) { + throw new IOException("Destination '" + destFile + "' exists but is a directory"); + } + + FileInputStream fis = null; + FileOutputStream fos = null; + FileChannel input = null; + FileChannel output = null; + try { + fis = new FileInputStream(srcFile); + fos = new FileOutputStream(destFile); + input = fis.getChannel(); + output = fos.getChannel(); + final long size = input.size(); // TODO See IO-386 + long pos = 0; + long count = 0; + while (pos < size) { + final long remain = size - pos; + count = remain > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : remain; + final long bytesCopied = output.transferFrom(input, pos, count); + if (bytesCopied == 0) { // IO-385 - can happen if file is truncated after caching the size + break; // ensure we don't loop forever + } + pos += bytesCopied; + } + } finally { + IOUtils.closeQuietly(output, fos, input, fis); + } + + final long srcLen = srcFile.length(); // TODO See IO-386 + final long dstLen = destFile.length(); // TODO See IO-386 + if (srcLen != dstLen) { + throw new IOException("Failed to copy full contents from '" + + srcFile + "' to '" + destFile + "' Expected length: " + srcLen + " Actual: " + dstLen); + } + if (preserveFileDate) { + destFile.setLastModified(srcFile.lastModified()); + } + } + + //----------------------------------------------------------------------- + /** + * Copies a directory to within another directory preserving the file dates. + *

+ * This method copies the source directory and all its contents to a + * directory of the same name in the specified destination directory. + *

+ * The destination directory is created if it does not exist. + * If the destination directory did exist, then this method merges + * the source with the destination, with the source taking precedence. + *

+ * Note: This method tries to preserve the files' last + * modified date/times using {@link File#setLastModified(long)}, however + * it is not guaranteed that those operations will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the directory to place the copy in, must not be {@code null} + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since 1.2 + */ + public static void copyDirectoryToDirectory(final File srcDir, final File destDir) throws IOException { + if (srcDir == null) { + throw new NullPointerException("Source must not be null"); + } + if (srcDir.exists() && srcDir.isDirectory() == false) { + throw new IllegalArgumentException("Source '" + destDir + "' is not a directory"); + } + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); + } + if (destDir.exists() && destDir.isDirectory() == false) { + throw new IllegalArgumentException("Destination '" + destDir + "' is not a directory"); + } + copyDirectory(srcDir, new File(destDir, srcDir.getName()), true); + } + + /** + * Copies a whole directory to a new location preserving the file dates. + *

+ * This method copies the specified directory and all its child + * directories and files to the specified destination. + * The destination is the new location and name of the directory. + *

+ * The destination directory is created if it does not exist. + * If the destination directory did exist, then this method merges + * the source with the destination, with the source taking precedence. + *

+ * Note: This method tries to preserve the files' last + * modified date/times using {@link File#setLastModified(long)}, however + * it is not guaranteed that those operations will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since 1.1 + */ + public static void copyDirectory(final File srcDir, final File destDir) throws IOException { + copyDirectory(srcDir, destDir, true); + } + + /** + * Copies a whole directory to a new location. + *

+ * This method copies the contents of the specified source directory + * to within the specified destination directory. + *

+ * The destination directory is created if it does not exist. + * If the destination directory did exist, then this method merges + * the source with the destination, with the source taking precedence. + *

+ * Note: Setting preserveFileDate to + * {@code true} tries to preserve the files' last modified + * date/times using {@link File#setLastModified(long)}, however it is + * not guaranteed that those operations will succeed. + * If the modification operation fails, no indication is provided. + * + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} + * @param preserveFileDate true if the file date of the copy + * should be the same as the original + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since 1.1 + */ + public static void copyDirectory(final File srcDir, final File destDir, + final boolean preserveFileDate) throws IOException { + copyDirectory(srcDir, destDir, null, preserveFileDate); + } + + /** + * Copies a filtered directory to a new location preserving the file dates. + *

+ * This method copies the contents of the specified source directory + * to within the specified destination directory. + *

+ * The destination directory is created if it does not exist. + * If the destination directory did exist, then this method merges + * the source with the destination, with the source taking precedence. + *

+ * Note: This method tries to preserve the files' last + * modified date/times using {@link File#setLastModified(long)}, however + * it is not guaranteed that those operations will succeed. + * If the modification operation fails, no indication is provided. + *

+ *

Example: Copy directories only

+ *
+     *  // only copy the directory structure
+     *  FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY);
+     *  
+ * + *

Example: Copy directories and txt files

+ *
+     *  // Create a filter for ".txt" files
+     *  IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".txt");
+     *  IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter);
+     *
+     *  // Create a filter for either directories or ".txt" files
+     *  FileFilter filter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, txtFiles);
+     *
+     *  // Copy using the filter
+     *  FileUtils.copyDirectory(srcDir, destDir, filter);
+     *  
+ * + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} + * @param filter the filter to apply, null means copy all directories and files + * should be the same as the original + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since 1.4 + */ + public static void copyDirectory(final File srcDir, final File destDir, + final FileFilter filter) throws IOException { + copyDirectory(srcDir, destDir, filter, true); + } + + /** + * Copies a filtered directory to a new location. + *

+ * This method copies the contents of the specified source directory + * to within the specified destination directory. + *

+ * The destination directory is created if it does not exist. + * If the destination directory did exist, then this method merges + * the source with the destination, with the source taking precedence. + *

+ * Note: Setting preserveFileDate to + * {@code true} tries to preserve the files' last modified + * date/times using {@link File#setLastModified(long)}, however it is + * not guaranteed that those operations will succeed. + * If the modification operation fails, no indication is provided. + *

+ *

Example: Copy directories only

+ *
+     *  // only copy the directory structure
+     *  FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY, false);
+     *  
+ * + *

Example: Copy directories and txt files

+ *
+     *  // Create a filter for ".txt" files
+     *  IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".txt");
+     *  IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter);
+     *
+     *  // Create a filter for either directories or ".txt" files
+     *  FileFilter filter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, txtFiles);
+     *
+     *  // Copy using the filter
+     *  FileUtils.copyDirectory(srcDir, destDir, filter, false);
+     *  
+ * + * @param srcDir an existing directory to copy, must not be {@code null} + * @param destDir the new directory, must not be {@code null} + * @param filter the filter to apply, null means copy all directories and files + * @param preserveFileDate true if the file date of the copy + * should be the same as the original + * + * @throws NullPointerException if source or destination is {@code null} + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs during copying + * @since 1.4 + */ + public static void copyDirectory(final File srcDir, final File destDir, + final FileFilter filter, final boolean preserveFileDate) throws IOException { + checkFileRequirements(srcDir, destDir); + if (!srcDir.isDirectory()) { + throw new IOException("Source '" + srcDir + "' exists but is not a directory"); + } + if (srcDir.getCanonicalPath().equals(destDir.getCanonicalPath())) { + throw new IOException("Source '" + srcDir + "' and destination '" + destDir + "' are the same"); + } + + // Cater for destination being directory within the source directory (see IO-141) + List exclusionList = null; + if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) { + final File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter); + if (srcFiles != null && srcFiles.length > 0) { + exclusionList = new ArrayList(srcFiles.length); + for (final File srcFile : srcFiles) { + final File copiedFile = new File(destDir, srcFile.getName()); + exclusionList.add(copiedFile.getCanonicalPath()); + } + } + } + doCopyDirectory(srcDir, destDir, filter, preserveFileDate, exclusionList); + } + + /** + * checks requirements for file copy + * @param src the source file + * @param dest the destination + * @throws FileNotFoundException if the destination does not exist + */ + private static void checkFileRequirements(File src, File dest) throws FileNotFoundException { + if (src == null) { + throw new NullPointerException("Source must not be null"); + } + if (dest == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!src.exists()) { + throw new FileNotFoundException("Source '" + src + "' does not exist"); + } + } + + /** + * Internal copy directory method. + * + * @param srcDir the validated source directory, must not be {@code null} + * @param destDir the validated destination directory, must not be {@code null} + * @param filter the filter to apply, null means copy all directories and files + * @param preserveFileDate whether to preserve the file date + * @param exclusionList List of files and directories to exclude from the copy, may be null + * @throws IOException if an error occurs + * @since 1.1 + */ + private static void doCopyDirectory(final File srcDir, final File destDir, final FileFilter filter, + final boolean preserveFileDate, final List exclusionList) + throws IOException { + // recurse + final File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter); + if (srcFiles == null) { // null if abstract pathname does not denote a directory, or if an I/O error occurs + throw new IOException("Failed to list contents of " + srcDir); + } + if (destDir.exists()) { + if (destDir.isDirectory() == false) { + throw new IOException("Destination '" + destDir + "' exists but is not a directory"); + } + } else { + if (!destDir.mkdirs() && !destDir.isDirectory()) { + throw new IOException("Destination '" + destDir + "' directory cannot be created"); + } + } + if (destDir.canWrite() == false) { + throw new IOException("Destination '" + destDir + "' cannot be written to"); + } + for (final File srcFile : srcFiles) { + final File dstFile = new File(destDir, srcFile.getName()); + if (exclusionList == null || !exclusionList.contains(srcFile.getCanonicalPath())) { + if (srcFile.isDirectory()) { + doCopyDirectory(srcFile, dstFile, filter, preserveFileDate, exclusionList); + } else { + doCopyFile(srcFile, dstFile, preserveFileDate); + } + } + } + + // Do this last, as the above has probably affected directory metadata + if (preserveFileDate) { + destDir.setLastModified(srcDir.lastModified()); + } + } + + //----------------------------------------------------------------------- + /** + * Copies bytes from the URL source to a file + * destination. The directories up to destination + * will be created if they don't already exist. destination + * will be overwritten if it already exists. + *

+ * Warning: this method does not set a connection or read timeout and thus + * might block forever. Use {@link #copyURLToFile(URL, File, int, int)} + * with reasonable timeouts to prevent this. + * + * @param source the URL to copy bytes from, must not be {@code null} + * @param destination the non-directory File to write bytes to + * (possibly overwriting), must not be {@code null} + * @throws IOException if source URL cannot be opened + * @throws IOException if destination is a directory + * @throws IOException if destination cannot be written + * @throws IOException if destination needs creating but can't be + * @throws IOException if an IO error occurs during copying + */ + public static void copyURLToFile(final URL source, final File destination) throws IOException { + copyInputStreamToFile(source.openStream(), destination); + } + + /** + * Copies bytes from the URL source to a file + * destination. The directories up to destination + * will be created if they don't already exist. destination + * will be overwritten if it already exists. + * + * @param source the URL to copy bytes from, must not be {@code null} + * @param destination the non-directory File to write bytes to + * (possibly overwriting), must not be {@code null} + * @param connectionTimeout the number of milliseconds until this method + * will timeout if no connection could be established to the source + * @param readTimeout the number of milliseconds until this method will + * timeout if no data could be read from the source + * @throws IOException if source URL cannot be opened + * @throws IOException if destination is a directory + * @throws IOException if destination cannot be written + * @throws IOException if destination needs creating but can't be + * @throws IOException if an IO error occurs during copying + * @since 2.0 + */ + public static void copyURLToFile(final URL source, final File destination, + final int connectionTimeout, final int readTimeout) throws IOException { + final URLConnection connection = source.openConnection(); + connection.setConnectTimeout(connectionTimeout); + connection.setReadTimeout(readTimeout); + copyInputStreamToFile(connection.getInputStream(), destination); + } + + /** + * Copies bytes from an {@link InputStream} source to a file + * destination. The directories up to destination + * will be created if they don't already exist. destination + * will be overwritten if it already exists. + * The {@code source} stream is closed. + * See {@link #copyToFile(InputStream, File)} for a method that does not close the input stream. + * + * @param source the InputStream to copy bytes from, must not be {@code null}, will be closed + * @param destination the non-directory File to write bytes to + * (possibly overwriting), must not be {@code null} + * @throws IOException if destination is a directory + * @throws IOException if destination cannot be written + * @throws IOException if destination needs creating but can't be + * @throws IOException if an IO error occurs during copying + * @since 2.0 + */ + public static void copyInputStreamToFile(final InputStream source, final File destination) throws IOException { + try { + copyToFile(source, destination); + } finally { + IOUtils.closeQuietly(source); + } + } + + /** + * Copies bytes from an {@link InputStream} source to a file + * destination. The directories up to destination + * will be created if they don't already exist. destination + * will be overwritten if it already exists. + * The {@code source} stream is left open, e.g. for use with {@link java.util.zip.ZipInputStream ZipInputStream}. + * See {@link #copyInputStreamToFile(InputStream, File)} for a method that closes the input stream. + * + * @param source the InputStream to copy bytes from, must not be {@code null} + * @param destination the non-directory File to write bytes to + * (possibly overwriting), must not be {@code null} + * @throws IOException if destination is a directory + * @throws IOException if destination cannot be written + * @throws IOException if destination needs creating but can't be + * @throws IOException if an IO error occurs during copying + * @since 2.5 + */ + public static void copyToFile(final InputStream source, final File destination) throws IOException { + final FileOutputStream output = openOutputStream(destination); + try { + IOUtils.copy(source, output); + output.close(); // don't swallow close Exception if copy completes normally + } finally { + IOUtils.closeQuietly(output); + } + } + + //----------------------------------------------------------------------- + /** + * Deletes a directory recursively. + * + * @param directory directory to delete + * @throws IOException in case deletion is unsuccessful + * @throws IllegalArgumentException if {@code directory} does not exist or is not a directory + */ + public static void deleteDirectory(final File directory) throws IOException { + if (!directory.exists()) { + return; + } + + if (!isSymlink(directory)) { + cleanDirectory(directory); + } + + if (!directory.delete()) { + final String message = + "Unable to delete directory " + directory + "."; + throw new IOException(message); + } + } + + /** + * Deletes a file, never throwing an exception. If file is a directory, delete it and all sub-directories. + *

+ * The difference between File.delete() and this method are: + *

    + *
  • A directory to be deleted does not have to be empty.
  • + *
  • No exceptions are thrown when a file or directory cannot be deleted.
  • + *
+ * + * @param file file or directory to delete, can be {@code null} + * @return {@code true} if the file or directory was deleted, otherwise + * {@code false} + * + * @since 1.4 + */ + public static boolean deleteQuietly(final File file) { + if (file == null) { + return false; + } + try { + if (file.isDirectory()) { + cleanDirectory(file); + } + } catch (final Exception ignored) { + } + + try { + return file.delete(); + } catch (final Exception ignored) { + return false; + } + } + + /** + * Determines whether the {@code parent} directory contains the {@code child} element (a file or directory). + *

+ * Files are normalized before comparison. + *

+ * + * Edge cases: + *
    + *
  • A {@code directory} must not be null: if null, throw IllegalArgumentException
  • + *
  • A {@code directory} must be a directory: if not a directory, throw IllegalArgumentException
  • + *
  • A directory does not contain itself: return false
  • + *
  • A null child file is not contained in any parent: return false
  • + *
+ * + * @param directory the file to consider as the parent. + * @param child 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. + * @throws IllegalArgumentException if {@code directory} is null or not a directory. + * @see FilenameUtils#directoryContains(String, String) + * @since 2.2 + */ + public static boolean directoryContains(final File directory, final File child) throws IOException { + + // Fail fast against NullPointerException + if (directory == null) { + throw new IllegalArgumentException("Directory must not be null"); + } + + if (!directory.isDirectory()) { + throw new IllegalArgumentException("Not a directory: " + directory); + } + + if (child == null) { + return false; + } + + if (!directory.exists() || !child.exists()) { + return false; + } + + // Canonicalize paths (normalizes relative paths) + final String canonicalParent = directory.getCanonicalPath(); + final String canonicalChild = child.getCanonicalPath(); + + return FilenameUtils.directoryContains(canonicalParent, canonicalChild); + } + + /** + * Cleans a directory without deleting it. + * + * @param directory directory to clean + * @throws IOException in case cleaning is unsuccessful + * @throws IllegalArgumentException if {@code directory} does not exist or is not a directory + */ + public static void cleanDirectory(final File directory) throws IOException { + final File[] files = verifiedListFiles(directory); + + IOException exception = null; + for (final File file : files) { + try { + forceDelete(file); + } catch (final IOException ioe) { + exception = ioe; + } + } + + if (null != exception) { + throw exception; + } + } + + /** + * Lists files in a directory, asserting that the supplied directory satisfies exists and is a directory + * @param directory The directory to list + * @return The files in the directory, never null. + * @throws IOException if an I/O error occurs + */ + private static File[] verifiedListFiles(File directory) throws IOException { + if (!directory.exists()) { + final String message = directory + " does not exist"; + throw new IllegalArgumentException(message); + } + + if (!directory.isDirectory()) { + final String message = directory + " is not a directory"; + throw new IllegalArgumentException(message); + } + + final File[] files = directory.listFiles(); + if (files == null) { // null if security restricted + throw new IOException("Failed to list contents of " + directory); + } + return files; + } + + //----------------------------------------------------------------------- + /** + * Waits for NFS to propagate a file creation, imposing a timeout. + *

+ * This method repeatedly tests {@link File#exists()} until it returns + * true up to the maximum time specified in seconds. + * + * @param file the file to check, must not be {@code null} + * @param seconds the maximum time in seconds to wait + * @return true if file exists + * @throws NullPointerException if the file is {@code null} + */ + public static boolean waitFor(final File file, final int seconds) { + long finishAt = System.currentTimeMillis() + (seconds * 1000L); + boolean wasInterrupted = false; + try { + while (!file.exists()) { + long remaining = finishAt - System.currentTimeMillis(); + if (remaining < 0){ + return false; + } + try { + Thread.sleep(Math.min(100, remaining)); + } catch (final InterruptedException ignore) { + wasInterrupted = true; + } catch (final Exception ex) { + break; + } + } + } finally { + if (wasInterrupted) { + Thread.currentThread().interrupt(); + } + } + return true; + } + + //----------------------------------------------------------------------- + /** + * Reads the contents of a file into a String. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return the file contents, never {@code null} + * @throws IOException in case of an I/O error + * @since 2.3 + */ + public static String readFileToString(final File file, final Charset encoding) throws IOException { + InputStream in = null; + try { + in = openInputStream(file); + return IOUtils.toString(in, Charsets.toCharset(encoding)); + } finally { + IOUtils.closeQuietly(in); + } + } + + /** + * Reads the contents of a file into a String. The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return the file contents, never {@code null} + * @throws IOException in case of an I/O error + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. + * @since 2.3 + */ + public static String readFileToString(final File file, final String encoding) throws IOException { + return readFileToString(file, Charsets.toCharset(encoding)); + } + + + /** + * Reads the contents of a file into a String using the default encoding for the VM. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @return the file contents, never {@code null} + * @throws IOException in case of an I/O error + * @since 1.3.1 + * @deprecated 2.5 use {@link #readFileToString(File, Charset)} instead + */ + @Deprecated + public static String readFileToString(final File file) throws IOException { + return readFileToString(file, Charset.defaultCharset()); + } + + /** + * Reads the contents of a file into a byte array. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @return the file contents, never {@code null} + * @throws IOException in case of an I/O error + * @since 1.1 + */ + public static byte[] readFileToByteArray(final File file) throws IOException { + InputStream in = null; + try { + in = openInputStream(file); + return IOUtils.toByteArray(in); // Do NOT use file.length() - see IO-453 + } finally { + IOUtils.closeQuietly(in); + } + } + + /** + * Reads the contents of a file line by line to a List of Strings. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return the list of Strings representing each line in the file, never {@code null} + * @throws IOException in case of an I/O error + * @since 2.3 + */ + public static List readLines(final File file, final Charset encoding) throws IOException { + InputStream in = null; + try { + in = openInputStream(file); + return IOUtils.readLines(in, Charsets.toCharset(encoding)); + } finally { + IOUtils.closeQuietly(in); + } + } + + /** + * Reads the contents of a file line by line to a List of Strings. The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return the list of Strings representing each line in the file, never {@code null} + * @throws IOException in case of an I/O error + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. + * @since 1.1 + */ + public static List readLines(final File file, final String encoding) throws IOException { + return readLines(file, Charsets.toCharset(encoding)); + } + + /** + * Reads the contents of a file line by line to a List of Strings using the default encoding for the VM. + * The file is always closed. + * + * @param file the file to read, must not be {@code null} + * @return the list of Strings representing each line in the file, never {@code null} + * @throws IOException in case of an I/O error + * @since 1.3 + * @deprecated 2.5 use {@link #readLines(File, Charset)} instead + */ + @Deprecated + public static List readLines(final File file) throws IOException { + return readLines(file, Charset.defaultCharset()); + } + + /** + * Returns an Iterator for the lines in a File. + *

+ * This method opens an InputStream for the file. + * When you have finished with the iterator you should close the stream + * to free internal resources. This can be done by calling the + * {@link LineIterator#close()} or + * {@link LineIterator#closeQuietly(LineIterator)} method. + *

+ * The recommended usage pattern is: + *

+     * LineIterator it = FileUtils.lineIterator(file, "UTF-8");
+     * try {
+     *   while (it.hasNext()) {
+     *     String line = it.nextLine();
+     *     /// do something with line
+     *   }
+     * } finally {
+     *   LineIterator.closeQuietly(iterator);
+     * }
+     * 
+ *

+ * If an exception occurs during the creation of the iterator, the + * underlying stream is closed. + * + * @param file the file to open for input, must not be {@code null} + * @param encoding the encoding to use, {@code null} means platform default + * @return an Iterator of the lines in the file, never {@code null} + * @throws IOException in case of an I/O error (file closed) + * @since 1.2 + */ + public static LineIterator lineIterator(final File file, final String encoding) throws IOException { + InputStream in = null; + try { + in = openInputStream(file); + return IOUtils.lineIterator(in, encoding); + } catch (final IOException ex) { + IOUtils.closeQuietly(in); + throw ex; + } catch (final RuntimeException ex) { + IOUtils.closeQuietly(in); + throw ex; + } + } + + /** + * Returns an Iterator for the lines in a File using the default encoding for the VM. + * + * @param file the file to open for input, must not be {@code null} + * @return an Iterator of the lines in the file, never {@code null} + * @throws IOException in case of an I/O error (file closed) + * @see #lineIterator(File, String) + * @since 1.3 + */ + public static LineIterator lineIterator(final File file) throws IOException { + return lineIterator(file, null); + } + + //----------------------------------------------------------------------- + + /** + * Writes a String to a file creating the file if it does not exist. + *

+ * NOTE: As from v1.3, the parent directories of the file will be created + * if they do not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 2.4 + */ + public static void writeStringToFile(final File file, final String data, final Charset encoding) + throws IOException { + writeStringToFile(file, data, encoding, false); + } + + /** + * Writes a String to a file creating the file if it does not exist. + *

+ * NOTE: As from v1.3, the parent directories of the file will be created + * if they do not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + */ + public static void writeStringToFile(final File file, final String data, final String encoding) throws IOException { + writeStringToFile(file, data, encoding, false); + } + + /** + * Writes a String to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the String will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.3 + */ + public static void writeStringToFile(final File file, final String data, final Charset encoding, final boolean + append) throws IOException { + OutputStream out = null; + try { + out = openOutputStream(file, append); + IOUtils.write(data, out, encoding); + out.close(); // don't swallow close Exception if copy completes normally + } finally { + IOUtils.closeQuietly(out); + } + } + + /** + * Writes a String to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the String will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported by the VM + * @since 2.1 + */ + public static void writeStringToFile(final File file, final String data, final String encoding, + final boolean append) throws IOException { + writeStringToFile(file, data, Charsets.toCharset(encoding), append); + } + + /** + * Writes a String to a file creating the file if it does not exist using the default encoding for the VM. + * + * @param file the file to write + * @param data the content to write to the file + * @throws IOException in case of an I/O error + * @deprecated 2.5 use {@link #writeStringToFile(File, String, Charset)} instead + */ + @Deprecated + public static void writeStringToFile(final File file, final String data) throws IOException { + writeStringToFile(file, data, Charset.defaultCharset(), false); + } + + /** + * Writes a String to a file creating the file if it does not exist using the default encoding for the VM. + * + * @param file the file to write + * @param data the content to write to the file + * @param append if {@code true}, then the String will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.1 + * @deprecated 2.5 use {@link #writeStringToFile(File, String, Charset, boolean)} instead + */ + @Deprecated + public static void writeStringToFile(final File file, final String data, final boolean append) throws IOException { + writeStringToFile(file, data, Charset.defaultCharset(), append); + } + + /** + * Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM. + * + * @param file the file to write + * @param data the content to write to the file + * @throws IOException in case of an I/O error + * @since 2.0 + * @deprecated 2.5 use {@link #write(File, CharSequence, Charset)} instead + */ + @Deprecated + public static void write(final File file, final CharSequence data) throws IOException { + write(file, data, Charset.defaultCharset(), false); + } + + /** + * Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM. + * + * @param file the file to write + * @param data the content to write to the file + * @param append if {@code true}, then the data will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.1 + * @deprecated 2.5 use {@link #write(File, CharSequence, Charset, boolean)} instead + */ + @Deprecated + public static void write(final File file, final CharSequence data, final boolean append) throws IOException { + write(file, data, Charset.defaultCharset(), append); + } + + /** + * Writes a CharSequence to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @throws IOException in case of an I/O error + * @since 2.3 + */ + public static void write(final File file, final CharSequence data, final Charset encoding) throws IOException { + write(file, data, encoding, false); + } + + /** + * Writes a CharSequence to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 2.0 + */ + public static void write(final File file, final CharSequence data, final String encoding) throws IOException { + write(file, data, encoding, false); + } + + /** + * Writes a CharSequence to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the data will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.3 + */ + public static void write(final File file, final CharSequence data, final Charset encoding, final boolean append) + throws IOException { + final String str = data == null ? null : data.toString(); + writeStringToFile(file, str, encoding, append); + } + + /** + * Writes a CharSequence to a file creating the file if it does not exist. + * + * @param file the file to write + * @param data the content to write to the file + * @param encoding the encoding to use, {@code null} means platform default + * @param append if {@code true}, then the data will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported by the VM + * @since 2.1 + */ + public static void write(final File file, final CharSequence data, final String encoding, final boolean append) + throws IOException { + write(file, data, Charsets.toCharset(encoding), append); + } + + /** + * Writes a byte array to a file creating the file if it does not exist. + *

+ * NOTE: As from v1.3, the parent directories of the file will be created + * if they do not exist. + * + * @param file the file to write to + * @param data the content to write to the file + * @throws IOException in case of an I/O error + * @since 1.1 + */ + public static void writeByteArrayToFile(final File file, final byte[] data) throws IOException { + writeByteArrayToFile(file, data, false); + } + + /** + * Writes a byte array to a file creating the file if it does not exist. + * + * @param file the file to write to + * @param data the content to write to the file + * @param append if {@code true}, then bytes will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.1 + */ + public static void writeByteArrayToFile(final File file, final byte[] data, final boolean append) + throws IOException { + writeByteArrayToFile(file, data, 0, data.length, append); + } + + /** + * Writes {@code len} bytes from the specified byte array starting + * at offset {@code off} to a file, creating the file if it does + * not exist. + * + * @param file the file to write to + * @param data the content to write to the file + * @param off the start offset in the data + * @param len the number of bytes to write + * @throws IOException in case of an I/O error + * @since 2.5 + */ + public static void writeByteArrayToFile(final File file, final byte[] data, final int off, final int len) + throws IOException { + writeByteArrayToFile(file, data, off, len, false); + } + + /** + * Writes {@code len} bytes from the specified byte array starting + * at offset {@code off} to a file, creating the file if it does + * not exist. + * + * @param file the file to write to + * @param data the content to write to the file + * @param off the start offset in the data + * @param len the number of bytes to write + * @param append if {@code true}, then bytes will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.5 + */ + public static void writeByteArrayToFile(final File file, final byte[] data, final int off, final int len, + final boolean append) throws IOException { + OutputStream out = null; + try { + out = openOutputStream(file, append); + out.write(data, off, len); + out.close(); // don't swallow close Exception if copy completes normally + } finally { + IOUtils.closeQuietly(out); + } + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line. + * The specified character encoding and the default line ending will be used. + *

+ * NOTE: As from v1.3, the parent directories of the file will be created + * if they do not exist. + * + * @param file the file to write to + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 1.1 + */ + public static void writeLines(final File file, final String encoding, final Collection lines) + throws IOException { + writeLines(file, encoding, lines, null, false); + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line, optionally appending. + * The specified character encoding and the default line ending will be used. + * + * @param file the file to write to + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines + * @param append if {@code true}, then the lines will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 2.1 + */ + public static void writeLines(final File file, final String encoding, final Collection lines, + final boolean append) throws IOException { + writeLines(file, encoding, lines, null, append); + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line. + * The default VM encoding and the default line ending will be used. + * + * @param file the file to write to + * @param lines the lines to write, {@code null} entries produce blank lines + * @throws IOException in case of an I/O error + * @since 1.3 + */ + public static void writeLines(final File file, final Collection lines) throws IOException { + writeLines(file, null, lines, null, false); + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line. + * The default VM encoding and the default line ending will be used. + * + * @param file the file to write to + * @param lines the lines to write, {@code null} entries produce blank lines + * @param append if {@code true}, then the lines will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.1 + */ + public static void writeLines(final File file, final Collection lines, final boolean append) throws IOException { + writeLines(file, null, lines, null, append); + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line. + * The specified character encoding and the line ending will be used. + *

+ * NOTE: As from v1.3, the parent directories of the file will be created + * if they do not exist. + * + * @param file the file to write to + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 1.1 + */ + public static void writeLines(final File file, final String encoding, final Collection lines, + final String lineEnding) throws IOException { + writeLines(file, encoding, lines, lineEnding, false); + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line. + * The specified character encoding and the line ending will be used. + * + * @param file the file to write to + * @param encoding the encoding to use, {@code null} means platform default + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default + * @param append if {@code true}, then the lines will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @throws java.io.UnsupportedEncodingException if the encoding is not supported by the VM + * @since 2.1 + */ + public static void writeLines(final File file, final String encoding, final Collection lines, + final String lineEnding, final boolean append) throws IOException { + FileOutputStream out = null; + try { + out = openOutputStream(file, append); + final BufferedOutputStream buffer = new BufferedOutputStream(out); + IOUtils.writeLines(lines, lineEnding, buffer, encoding); + buffer.flush(); + out.close(); // don't swallow close Exception if copy completes normally + } finally { + IOUtils.closeQuietly(out); + } + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line. + * The default VM encoding and the specified line ending will be used. + * + * @param file the file to write to + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default + * @throws IOException in case of an I/O error + * @since 1.3 + */ + public static void writeLines(final File file, final Collection lines, final String lineEnding) + throws IOException { + writeLines(file, null, lines, lineEnding, false); + } + + /** + * Writes the toString() value of each item in a collection to + * the specified File line by line. + * The default VM encoding and the specified line ending will be used. + * + * @param file the file to write to + * @param lines the lines to write, {@code null} entries produce blank lines + * @param lineEnding the line separator to use, {@code null} is system default + * @param append if {@code true}, then the lines will be added to the + * end of the file rather than overwriting + * @throws IOException in case of an I/O error + * @since 2.1 + */ + public static void writeLines(final File file, final Collection lines, final String lineEnding, + final boolean append) throws IOException { + writeLines(file, null, lines, lineEnding, append); + } + + //----------------------------------------------------------------------- + /** + * Deletes a file. If file is a directory, delete it and all sub-directories. + *

+ * The difference between File.delete() and this method are: + *

    + *
  • A directory to be deleted does not have to be empty.
  • + *
  • You get exceptions when a file or directory cannot be deleted. + * (java.io.File methods returns a boolean)
  • + *
+ * + * @param file file or directory to delete, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} + * @throws FileNotFoundException if the file was not found + * @throws IOException in case deletion is unsuccessful + */ + public static void forceDelete(final File file) throws IOException { + if (file.isDirectory()) { + deleteDirectory(file); + } else { + final boolean filePresent = file.exists(); + if (!file.delete()) { + if (!filePresent) { + throw new FileNotFoundException("File does not exist: " + file); + } + final String message = + "Unable to delete file: " + file; + throw new IOException(message); + } + } + } + + /** + * Schedules a file to be deleted when JVM exits. + * If file is directory delete it and all sub-directories. + * + * @param file file or directory to delete, must not be {@code null} + * @throws NullPointerException if the file is {@code null} + * @throws IOException in case deletion is unsuccessful + */ + public static void forceDeleteOnExit(final File file) throws IOException { + if (file.isDirectory()) { + deleteDirectoryOnExit(file); + } else { + file.deleteOnExit(); + } + } + + /** + * Schedules a directory recursively for deletion on JVM exit. + * + * @param directory directory to delete, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} + * @throws IOException in case deletion is unsuccessful + */ + private static void deleteDirectoryOnExit(final File directory) throws IOException { + if (!directory.exists()) { + return; + } + + directory.deleteOnExit(); + if (!isSymlink(directory)) { + cleanDirectoryOnExit(directory); + } + } + + /** + * Cleans a directory without deleting it. + * + * @param directory directory to clean, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} + * @throws IOException in case cleaning is unsuccessful + */ + private static void cleanDirectoryOnExit(final File directory) throws IOException { + final File[] files = verifiedListFiles(directory); + + IOException exception = null; + for (final File file : files) { + try { + forceDeleteOnExit(file); + } catch (final IOException ioe) { + exception = ioe; + } + } + + if (null != exception) { + throw exception; + } + } + + /** + * Makes a directory, including any necessary but nonexistent parent + * directories. If a file already exists with specified name but it is + * not a directory then an IOException is thrown. + * If the directory cannot be created (or does not already exist) + * then an IOException is thrown. + * + * @param directory directory to create, must not be {@code null} + * @throws NullPointerException if the directory is {@code null} + * @throws IOException if the directory cannot be created or the file already exists but is not a directory + */ + public static void forceMkdir(final File directory) throws IOException { + if (directory.exists()) { + if (!directory.isDirectory()) { + final String message = + "File " + + directory + + " exists and is " + + "not a directory. Unable to create directory."; + throw new IOException(message); + } + } else { + if (!directory.mkdirs()) { + // Double-check that some other thread or process hasn't made + // the directory in the background + if (!directory.isDirectory()) { + final String message = + "Unable to create directory " + directory; + throw new IOException(message); + } + } + } + } + + /** + * Makes any necessary but nonexistent parent directories for a given File. If the parent directory cannot be + * created then an IOException is thrown. + * + * @param file file with parent to create, must not be {@code null} + * @throws NullPointerException if the file is {@code null} + * @throws IOException if the parent directory cannot be created + * @since 2.5 + */ + public static void forceMkdirParent(final File file) throws IOException { + final File parent = file.getParentFile(); + if (parent == null) { + return; + } + forceMkdir(parent); + } + + //----------------------------------------------------------------------- + /** + * Returns the size of the specified file or directory. If the provided + * {@link File} is a regular file, then the file's length is returned. + * If the argument is a directory, then the size of the directory is + * calculated recursively. If a directory or subdirectory is security + * restricted, its size will not be included. + *

+ * Note that overflow is not detected, and the return value may be negative if + * overflow occurs. See {@link #sizeOfAsBigInteger(File)} for an alternative + * method that does not overflow. + * + * @param file the regular file or directory to return the size + * of (must not be {@code null}). + * + * @return the length of the file, or recursive size of the directory, + * provided (in bytes). + * + * @throws NullPointerException if the file is {@code null} + * @throws IllegalArgumentException if the file does not exist. + * + * @since 2.0 + */ + public static long sizeOf(final File file) { + + if (!file.exists()) { + final String message = file + " does not exist"; + throw new IllegalArgumentException(message); + } + + if (file.isDirectory()) { + return sizeOfDirectory0(file); // private method; expects directory + } else { + return file.length(); + } + + } + + /** + * Returns the size of the specified file or directory. If the provided + * {@link File} is a regular file, then the file's length is returned. + * If the argument is a directory, then the size of the directory is + * calculated recursively. If a directory or subdirectory is security + * restricted, its size will not be included. + * + * @param file the regular file or directory to return the size + * of (must not be {@code null}). + * + * @return the length of the file, or recursive size of the directory, + * provided (in bytes). + * + * @throws NullPointerException if the file is {@code null} + * @throws IllegalArgumentException if the file does not exist. + * + * @since 2.4 + */ + public static BigInteger sizeOfAsBigInteger(final File file) { + + if (!file.exists()) { + final String message = file + " does not exist"; + throw new IllegalArgumentException(message); + } + + if (file.isDirectory()) { + return sizeOfDirectoryBig0(file); // internal method + } else { + return BigInteger.valueOf(file.length()); + } + + } + + /** + * Counts the size of a directory recursively (sum of the length of all files). + *

+ * Note that overflow is not detected, and the return value may be negative if + * overflow occurs. See {@link #sizeOfDirectoryAsBigInteger(File)} for an alternative + * method that does not overflow. + * + * @param directory directory to inspect, must not be {@code null} + * @return size of directory in bytes, 0 if directory is security restricted, a negative number when the real total + * is greater than {@link Long#MAX_VALUE}. + * @throws NullPointerException if the directory is {@code null} + */ + public static long sizeOfDirectory(final File directory) { + checkDirectory(directory); + return sizeOfDirectory0(directory); + } + + // Private method, must be invoked will a directory parameter + + /** + * the size of a director + * @param directory the directory to check + * @return the size + */ + private static long sizeOfDirectory0(final File directory) { + final File[] files = directory.listFiles(); + if (files == null) { // null if security restricted + return 0L; + } + long size = 0; + + for (final File file : files) { + try { + if (!isSymlink(file)) { + size += sizeOf0(file); // internal method + if (size < 0) { + break; + } + } + } catch (final IOException ioe) { + // Ignore exceptions caught when asking if a File is a symlink. + } + } + + return size; + } + + // Internal method - does not check existence + + /** + * the size of a file + * @param file the file to check + * @return the size of the fil + */ + private static long sizeOf0(File file) { + if (file.isDirectory()) { + return sizeOfDirectory0(file); + } else { + return file.length(); // will be 0 if file does not exist + } + } + + /** + * Counts the size of a directory recursively (sum of the length of all files). + * + * @param directory directory to inspect, must not be {@code null} + * @return size of directory in bytes, 0 if directory is security restricted. + * @throws NullPointerException if the directory is {@code null} + * @since 2.4 + */ + public static BigInteger sizeOfDirectoryAsBigInteger(final File directory) { + checkDirectory(directory); + return sizeOfDirectoryBig0(directory); + } + + // Must be called with a directory + + /** + * Finds the size of a directory + * + * @param directory The directory + * @return the size + */ + private static BigInteger sizeOfDirectoryBig0(final File directory) { + final File[] files = directory.listFiles(); + if (files == null) { // null if security restricted + return BigInteger.ZERO; + } + BigInteger size = BigInteger.ZERO; + + for (final File file : files) { + try { + if (!isSymlink(file)) { + size = size.add(sizeOfBig0(file)); + } + } catch (final IOException ioe) { + // Ignore exceptions caught when asking if a File is a symlink. + } + } + + return size; + } + + // internal method; if file does not exist will return 0 + + /** + * Returns the sid of a file + * @param fileOrDir The file + * @return the size + */ + private static BigInteger sizeOfBig0(final File fileOrDir) { + if (fileOrDir.isDirectory()) { + return sizeOfDirectoryBig0(fileOrDir); + } else { + return BigInteger.valueOf(fileOrDir.length()); + } + } + + /** + * Checks that the given {@code File} exists and is a directory. + * + * @param directory The {@code File} to check. + * @throws IllegalArgumentException if the given {@code File} does not exist or is not a directory. + */ + private static void checkDirectory(final File directory) { + if (!directory.exists()) { + throw new IllegalArgumentException(directory + " does not exist"); + } + if (!directory.isDirectory()) { + throw new IllegalArgumentException(directory + " is not a directory"); + } + } + + //----------------------------------------------------------------------- + /** + * Tests if the specified File is newer than the reference + * File. + * + * @param file the File of which the modification date must + * be compared, must not be {@code null} + * @param reference the File of which the modification date + * is used, must not be {@code null} + * @return true if the File exists and has been modified more + * recently than the reference File + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist + */ + public static boolean isFileNewer(final File file, final File reference) { + if (reference == null) { + throw new IllegalArgumentException("No specified reference file"); + } + if (!reference.exists()) { + throw new IllegalArgumentException("The reference file '" + + reference + "' doesn't exist"); + } + return isFileNewer(file, reference.lastModified()); + } + + /** + * Tests if the specified File is newer than the specified + * Date. + * + * @param file the File of which the modification date + * must be compared, must not be {@code null} + * @param date the date reference, must not be {@code null} + * @return true if the File exists and has been modified + * after the given Date. + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the date is {@code null} + */ + public static boolean isFileNewer(final File file, final Date date) { + if (date == null) { + throw new IllegalArgumentException("No specified date"); + } + return isFileNewer(file, date.getTime()); + } + + /** + * Tests if the specified File is newer than the specified + * time reference. + * + * @param file the File of which the modification date must + * be compared, must not be {@code null} + * @param timeMillis the time reference measured in milliseconds since the + * epoch (00:00:00 GMT, January 1, 1970) + * @return true if the File exists and has been modified after + * the given time reference. + * @throws IllegalArgumentException if the file is {@code null} + */ + public static boolean isFileNewer(final File file, final long timeMillis) { + if (file == null) { + throw new IllegalArgumentException("No specified file"); + } + if (!file.exists()) { + return false; + } + return file.lastModified() > timeMillis; + } + + + //----------------------------------------------------------------------- + /** + * Tests if the specified File is older than the reference + * File. + * + * @param file the File of which the modification date must + * be compared, must not be {@code null} + * @param reference the File of which the modification date + * is used, must not be {@code null} + * @return true if the File exists and has been modified before + * the reference File + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist + */ + public static boolean isFileOlder(final File file, final File reference) { + if (reference == null) { + throw new IllegalArgumentException("No specified reference file"); + } + if (!reference.exists()) { + throw new IllegalArgumentException("The reference file '" + + reference + "' doesn't exist"); + } + return isFileOlder(file, reference.lastModified()); + } + + /** + * Tests if the specified File is older than the specified + * Date. + * + * @param file the File of which the modification date + * must be compared, must not be {@code null} + * @param date the date reference, must not be {@code null} + * @return true if the File exists and has been modified + * before the given Date. + * @throws IllegalArgumentException if the file is {@code null} + * @throws IllegalArgumentException if the date is {@code null} + */ + public static boolean isFileOlder(final File file, final Date date) { + if (date == null) { + throw new IllegalArgumentException("No specified date"); + } + return isFileOlder(file, date.getTime()); + } + + /** + * Tests if the specified File is older than the specified + * time reference. + * + * @param file the File of which the modification date must + * be compared, must not be {@code null} + * @param timeMillis the time reference measured in milliseconds since the + * epoch (00:00:00 GMT, January 1, 1970) + * @return true if the File exists and has been modified before + * the given time reference. + * @throws IllegalArgumentException if the file is {@code null} + */ + public static boolean isFileOlder(final File file, final long timeMillis) { + if (file == null) { + throw new IllegalArgumentException("No specified file"); + } + if (!file.exists()) { + return false; + } + return file.lastModified() < timeMillis; + } + + //----------------------------------------------------------------------- + /** + * Computes the checksum of a file using the CRC32 checksum routine. + * The value of the checksum is returned. + * + * @param file the file to checksum, must not be {@code null} + * @return the checksum value + * @throws NullPointerException if the file or checksum is {@code null} + * @throws IllegalArgumentException if the file is a directory + * @throws IOException if an IO error occurs reading the file + * @since 1.3 + */ + public static long checksumCRC32(final File file) throws IOException { + final CRC32 crc = new CRC32(); + checksum(file, crc); + return crc.getValue(); + } + + /** + * Computes the checksum of a file using the specified checksum object. + * Multiple files may be checked using one Checksum instance + * if desired simply by reusing the same checksum object. + * For example: + *

+     *   long csum = FileUtils.checksum(file, new CRC32()).getValue();
+     * 
+ * + * @param file the file to checksum, must not be {@code null} + * @param checksum the checksum object to be used, must not be {@code null} + * @return the checksum specified, updated with the content of the file + * @throws NullPointerException if the file or checksum is {@code null} + * @throws IllegalArgumentException if the file is a directory + * @throws IOException if an IO error occurs reading the file + * @since 1.3 + */ + public static Checksum checksum(final File file, final Checksum checksum) throws IOException { + if (file.isDirectory()) { + throw new IllegalArgumentException("Checksums can't be computed on directories"); + } + InputStream in = null; + try { + in = new CheckedInputStream(new FileInputStream(file), checksum); + IOUtils.copy(in, new NullOutputStream()); + } finally { + IOUtils.closeQuietly(in); + } + return checksum; + } + + /** + * Moves a directory. + *

+ * When the destination directory is on another file system, do a "copy and delete". + * + * @param srcDir the directory to be moved + * @param destDir the destination directory + * @throws NullPointerException if source or destination is {@code null} + * @throws FileExistsException if the destination directory exists + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs moving the file + * @since 1.4 + */ + public static void moveDirectory(final File srcDir, final File destDir) throws IOException { + if (srcDir == null) { + throw new NullPointerException("Source must not be null"); + } + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!srcDir.exists()) { + throw new FileNotFoundException("Source '" + srcDir + "' does not exist"); + } + if (!srcDir.isDirectory()) { + throw new IOException("Source '" + srcDir + "' is not a directory"); + } + if (destDir.exists()) { + throw new FileExistsException("Destination '" + destDir + "' already exists"); + } + final boolean rename = srcDir.renameTo(destDir); + if (!rename) { + if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath() + File.separator)) { + throw new IOException("Cannot move directory: " + srcDir + " to a subdirectory of itself: " + destDir); + } + copyDirectory(srcDir, destDir); + deleteDirectory(srcDir); + if (srcDir.exists()) { + throw new IOException("Failed to delete original directory '" + srcDir + + "' after copy to '" + destDir + "'"); + } + } + } + + /** + * Moves a directory to another directory. + * + * @param src the file to be moved + * @param destDir the destination file + * @param createDestDir If {@code true} create the destination directory, + * otherwise if {@code false} throw an IOException + * @throws NullPointerException if source or destination is {@code null} + * @throws FileExistsException if the directory exists in the destination directory + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs moving the file + * @since 1.4 + */ + public static void moveDirectoryToDirectory(final File src, final File destDir, final boolean createDestDir) + throws IOException { + if (src == null) { + throw new NullPointerException("Source must not be null"); + } + if (destDir == null) { + throw new NullPointerException("Destination directory must not be null"); + } + if (!destDir.exists() && createDestDir) { + destDir.mkdirs(); + } + if (!destDir.exists()) { + throw new FileNotFoundException("Destination directory '" + destDir + + "' does not exist [createDestDir=" + createDestDir + "]"); + } + if (!destDir.isDirectory()) { + throw new IOException("Destination '" + destDir + "' is not a directory"); + } + moveDirectory(src, new File(destDir, src.getName())); + + } + + /** + * Moves a file. + *

+ * When the destination file is on another file system, do a "copy and delete". + * + * @param srcFile the file to be moved + * @param destFile the destination file + * @throws NullPointerException if source or destination is {@code null} + * @throws FileExistsException if the destination file exists + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs moving the file + * @since 1.4 + */ + public static void moveFile(final File srcFile, final File destFile) throws IOException { + if (srcFile == null) { + throw new NullPointerException("Source must not be null"); + } + if (destFile == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!srcFile.exists()) { + throw new FileNotFoundException("Source '" + srcFile + "' does not exist"); + } + if (srcFile.isDirectory()) { + throw new IOException("Source '" + srcFile + "' is a directory"); + } + if (destFile.exists()) { + throw new FileExistsException("Destination '" + destFile + "' already exists"); + } + if (destFile.isDirectory()) { + throw new IOException("Destination '" + destFile + "' is a directory"); + } + final boolean rename = srcFile.renameTo(destFile); + if (!rename) { + copyFile(srcFile, destFile); + if (!srcFile.delete()) { + FileUtils.deleteQuietly(destFile); + throw new IOException("Failed to delete original file '" + srcFile + + "' after copy to '" + destFile + "'"); + } + } + } + + /** + * Moves a file to a directory. + * + * @param srcFile the file to be moved + * @param destDir the destination file + * @param createDestDir If {@code true} create the destination directory, + * otherwise if {@code false} throw an IOException + * @throws NullPointerException if source or destination is {@code null} + * @throws FileExistsException if the destination file exists + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs moving the file + * @since 1.4 + */ + public static void moveFileToDirectory(final File srcFile, final File destDir, final boolean createDestDir) + throws IOException { + if (srcFile == null) { + throw new NullPointerException("Source must not be null"); + } + if (destDir == null) { + throw new NullPointerException("Destination directory must not be null"); + } + if (!destDir.exists() && createDestDir) { + destDir.mkdirs(); + } + if (!destDir.exists()) { + throw new FileNotFoundException("Destination directory '" + destDir + + "' does not exist [createDestDir=" + createDestDir + "]"); + } + if (!destDir.isDirectory()) { + throw new IOException("Destination '" + destDir + "' is not a directory"); + } + moveFile(srcFile, new File(destDir, srcFile.getName())); + } + + /** + * Moves a file or directory to the destination directory. + *

+ * When the destination is on another file system, do a "copy and delete". + * + * @param src the file or directory to be moved + * @param destDir the destination directory + * @param createDestDir If {@code true} create the destination directory, + * otherwise if {@code false} throw an IOException + * @throws NullPointerException if source or destination is {@code null} + * @throws FileExistsException if the directory or file exists in the destination directory + * @throws IOException if source or destination is invalid + * @throws IOException if an IO error occurs moving the file + * @since 1.4 + */ + public static void moveToDirectory(final File src, final File destDir, final boolean createDestDir) + throws IOException { + if (src == null) { + throw new NullPointerException("Source must not be null"); + } + if (destDir == null) { + throw new NullPointerException("Destination must not be null"); + } + if (!src.exists()) { + throw new FileNotFoundException("Source '" + src + "' does not exist"); + } + if (src.isDirectory()) { + moveDirectoryToDirectory(src, destDir, createDestDir); + } else { + moveFileToDirectory(src, destDir, createDestDir); + } + } + + /** + * Determines whether the specified file is a Symbolic Link rather than an actual file. + *

+ * Will not return true if there is a Symbolic Link anywhere in the path, + * only if the specific file is. + *

+ * When using jdk1.7, this method delegates to {@code boolean java.nio.file.Files.isSymbolicLink(Path path)} + * + * Note: the current implementation always returns {@code false} if running on + * jkd1.6 and the system is detected as Windows using {@link FilenameUtils#isSystemWindows()} + *

+ * For code that runs on Java 1.7 or later, use the following method instead: + *
+ * {@code boolean java.nio.file.Files.isSymbolicLink(Path path)} + * @param file the file to check + * @return true if the file is a Symbolic Link + * @throws IOException if an IO error occurs while checking the file + * @since 2.0 + */ + public static boolean isSymlink(final File file) throws IOException { + if ( Java7Support.isAtLeastJava7() ) + { + return Java7Support.isSymLink( file ); + } + + if (file == null) { + throw new NullPointerException("File must not be null"); + } + if (FilenameUtils.isSystemWindows()) { + return false; + } + File fileInCanonicalDir = null; + if (file.getParent() == null) { + fileInCanonicalDir = file; + } else { + final File canonicalDir = file.getParentFile().getCanonicalFile(); + fileInCanonicalDir = new File(canonicalDir, file.getName()); + } + + if (fileInCanonicalDir.getCanonicalFile().equals(fileInCanonicalDir.getAbsoluteFile())) { + return isBrokenSymlink(file); + } else { + return true; + } + } + + /** + * Determines if the specified file is possibly a broken symbolic link. + * + * @param file the file to check + + * @return true if the file is a Symbolic Link + * @throws IOException if an IO error occurs while checking the file + */ + private static boolean isBrokenSymlink(final File file) throws IOException { + // if file exists then if it is a symlink it's not broken + if (file.exists()) { + return false; + } + // a broken symlink will show up in the list of files of its parent directory + final File canon = file.getCanonicalFile(); + File parentDir = canon.getParentFile(); + if (parentDir == null || !parentDir.exists()) { + return false; + } + + // is it worthwhile to create a FileFilterUtil method for this? + // is it worthwhile to create an "identity" IOFileFilter for this? + File[] fileInDir = parentDir.listFiles( + new FileFilter() { + public boolean accept(File aFile) { + return aFile.equals(canon); + } + } + ); + return fileInDir != null && fileInDir.length > 0; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FilenameUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FilenameUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..0ccbe31516142b0b4cd09cdcabe42b0e868042a0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/FilenameUtils.java" @@ -0,0 +1,1452 @@ +/* + * 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. + *

+ * 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. + *

+ * NOTE: 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)}. + *

+ * 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. + *

+ * Most methods recognise both separators (forward and back), and both + * sets of prefixes. See the javadoc of each method for details. + *

+ * This class defines six components within a filename + * (example C:\dev\project\file.txt): + *

    + *
  • the prefix - C:\
  • + *
  • the path - dev\project\
  • + *
  • the full path - C:\dev\project\
  • + *
  • the name - file.txt
  • + *
  • the base name - file
  • + *
  • the extension - txt
  • + *
+ * 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. + *

+ * This class only supports Unix and Windows style names. + * Prefixes are matched as follows: + *

+ * 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)
+ * 
+ * Both prefix styles are matched always, irrespective of the machine that you are + * currently running on. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * The output will be the same on both Unix and Windows except + * for the separator character. + *

+     * /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
+     * 
+ * (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. + *

+ * 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. + *

+ * 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. + *

+ * The output will be the same on both Unix and Windows except + * for the separator character. + *

+     * /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
+     * 
+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * The output will be the same on both Unix and Windows except + * for the separator character. + *

+     * /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
+     * 
+ * (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. + *

+ * 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. + *

+ * 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. + *

+ * The output will be the same on both Unix and Windows including + * the separator character. + *

+     * /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
+     * 
+ * + * @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. + *

+ * The effect is equivalent to resultant directory after changing + * directory to the first argument, followed by changing directory to + * the second argument. + *

+ * 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 .. is handled. + *

+ * If pathToAdd is absolute (has an absolute prefix), then + * it will be normalized and returned. + * Otherwise, the paths will be joined, normalized and returned. + *

+ * The output will be the same on both Unix and Windows except + * for the separator character. + *

+     * /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 (!)
+     * 
+ * (*) 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). + *

+ * The files names are expected to be normalized. + *

+ * + * Edge cases: + *
    + *
  • A {@code directory} must not be null: if null, throw IllegalArgumentException
  • + *
  • A directory does not contain itself: return false
  • + *
  • A null child file is not contained in any parent: return false
  • + *
+ * + * @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 C:/ or ~/. + *

+ * This method will handle a file in either Unix or Windows format. + *

+ * 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. + *

+     * 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
+     * 
+ *

+ * 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. + *

+ * This method will handle a file in either Unix or Windows format. + * The position of the last forward or backslash is returned. + *

+ * 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. + *

+ * 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. + *

+ *

+ * The output will be the same irrespective of the machine that the code is running on. + *

+ * + * @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 C:/ + * or ~/. + *

+ * This method will handle a file in either Unix or Windows format. + * The prefix includes the first slash in the full filename where applicable. + *

+     * 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)
+     * 
+ *

+ * 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. + *

+ * 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. + *

+     * 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/
+     * 
+ *

+ * The output will be the same irrespective of the machine that the code is running on. + *

+ * 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. + *

+ * 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. + *

+     * 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
+     * 
+ *

+ * The output will be the same irrespective of the machine that the code is running on. + *

+ * 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. + *

+ * 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. + *

+     * 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/
+     * 
+ *

+ * 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. + *

+ * 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. + *

+     * 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
+     * 
+ *

+ * 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. + *

+ * This method will handle a file in either Unix or Windows format. + * The text after the last forward or backslash is returned. + *

+     * a/b/c.txt --> c.txt
+     * a.txt     --> a.txt
+     * a/b/c     --> c
+     * a/b/c/    --> ""
+     * 
+ *

+ * 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. + *

+ * 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. + *

+     * a/b/c.txt --> c
+     * a.txt     --> a
+     * a/b/c     --> c
+     * a/b/c/    --> ""
+     * 
+ *

+ * 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. + *

+ * This method returns the textual part of the filename after the last dot. + * There must be no directory separator after the dot. + *

+     * foo.txt      --> "txt"
+     * a/b/c.jpg    --> "jpg"
+     * a/b.txt/c    --> ""
+     * a/b/c        --> ""
+     * 
+ *

+ * 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. + *

+ * This method returns the textual part of the filename before the last dot. + * There must be no directory separator after the dot. + *

+     * foo.txt    --> foo
+     * a\b\c.jpg  --> a\b\c
+     * a\b\c      --> a\b\c
+     * a.b\c      --> a.b\c
+     * 
+ *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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 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. + *

+ * 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. + *

+     * 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
+     * 
+ * 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. + *

+ * 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. + *

+     * 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
+     * 
+ * 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. + *

+ * 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 backtrack = new Stack(); + + // 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 list = new ArrayList(); + 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() ] ); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/HexDump.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/HexDump.java" new file mode 100644 index 0000000000000000000000000000000000000000..7199ae206deb87cb3d80467687949dd041b521b9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/HexDump.java" @@ -0,0 +1,163 @@ +/* + * 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. + *

+ * Provides a single function to take an array of bytes and display it + * in hexadecimal form. + *

+ * 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. + *

+ * 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. + *

+ * 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; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..f9c823db0ccf8714cbc065771f5ecffc7dacda91 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOCase.java" @@ -0,0 +1,254 @@ +/* + * 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. + *

+ * Different filing systems have different rules for case-sensitivity. + * Windows is case-insensitive, Unix is case-sensitive. + *

+ * 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. + *

+ * Wherever possible, you should use the check 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. + *

+ * Note: 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}). + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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. + *

+ * 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; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOExceptionWithCause.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOExceptionWithCause.java" new file mode 100644 index 0000000000000000000000000000000000000000..ad652943e7f5559a14fce19d67271096bc56d418 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOExceptionWithCause.java" @@ -0,0 +1,67 @@ +/* + * 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 + */ +@Deprecated +public 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. + *

+ * As specified in {@link Throwable}, the message in the given cause is not used in this instance's + * message. + *

+ * + * @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. + *

+ * The message is set to cause==null ? null : cause.toString(), which by default contains the class + * and message of cause. This constructor is useful for call sites that just wrap another throwable. + *

+ * + * @param cause + * the cause (see {@link #getCause()}). A {@code null} value is allowed. + */ + public IOExceptionWithCause(final Throwable cause) { + super(cause); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..9da6933d7977be3a8bacd20c463235d5b812d120 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/IOUtils.java" @@ -0,0 +1,3078 @@ +/* + * 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.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayInputStream; +import java.io.CharArrayWriter; +import java.io.Closeable; +import java.io.EOFException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.Reader; +import java.io.Writer; +import java.net.HttpURLConnection; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.nio.ByteBuffer; +import java.nio.channels.ReadableByteChannel; +import java.nio.channels.Selector; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.io.output.StringBuilderWriter; + +/** + * General IO stream manipulation utilities. + *

+ * This class provides static utility methods for input/output operations. + *

    + *
  • closeQuietly - these methods close a stream ignoring nulls and exceptions + *
  • toXxx/read - these methods read data from a stream + *
  • write - these methods write data to a stream + *
  • copy - these methods copy all the data from one stream to another + *
  • contentEquals - these methods compare the content of two streams + *
+ *

+ * The byte-to-char methods and char-to-byte methods involve a conversion step. + * Two methods are provided in each case, one that uses the platform default + * encoding and the other which allows you to specify an encoding. You are + * encouraged to always specify an encoding because relying on the platform + * default can lead to unexpected results, for example when moving from + * development to production. + *

+ * All the methods in this class that read a stream are buffered internally. + * This means that there is no cause to use a BufferedInputStream + * or BufferedReader. The default buffer size of 4K has been shown + * to be efficient in tests. + *

+ * The various copy methods all delegate the actual copying to one of the following methods: + *

    + *
  • {@link #copyLarge(InputStream, OutputStream, byte[])}
  • + *
  • {@link #copyLarge(InputStream, OutputStream, long, long, byte[])}
  • + *
  • {@link #copyLarge(Reader, Writer, char[])}
  • + *
  • {@link #copyLarge(Reader, Writer, long, long, char[])}
  • + *
+ * For example, {@link #copy(InputStream, OutputStream)} calls {@link #copyLarge(InputStream, OutputStream)} + * which calls {@link #copy(InputStream, OutputStream, int)} which creates the buffer and calls + * {@link #copyLarge(InputStream, OutputStream, byte[])}. + *

+ * Applications can re-use buffers by using the underlying methods directly. + * This may improve performance for applications that need to do a lot of copying. + *

+ * Wherever possible, the methods in this class do not flush or close + * the stream. This is to avoid making non-portable assumptions about the + * streams' origin and further use. Thus the caller is still responsible for + * closing streams after use. + *

+ * Origin of code: Excalibur. + * + * @version $Id: IOUtils.java 1722156 2015-12-29 15:40:07Z ggregory $ + */ +public class IOUtils { + // NOTE: This class is focused on InputStream, OutputStream, Reader and + // Writer. Each method should take at least one of these as a parameter, + // or return one of them. + + /** + * Represents the end-of-file (or stream). + * @since 2.5 (made public) + */ + public static final int EOF = -1; + + /** + * The Unix directory separator character. + */ + public static final char DIR_SEPARATOR_UNIX = '/'; + /** + * The Windows directory separator character. + */ + public static final char DIR_SEPARATOR_WINDOWS = '\\'; + /** + * The system directory separator character. + */ + public static final char DIR_SEPARATOR = File.separatorChar; + /** + * The Unix line separator string. + */ + public static final String LINE_SEPARATOR_UNIX = "\n"; + /** + * The Windows line separator string. + */ + public static final String LINE_SEPARATOR_WINDOWS = "\r\n"; + /** + * The system line separator string. + */ + public static final String LINE_SEPARATOR; + + static { + // avoid security issues + final StringBuilderWriter buf = new StringBuilderWriter(4); + final PrintWriter out = new PrintWriter(buf); + out.println(); + LINE_SEPARATOR = buf.toString(); + out.close(); + } + + /** + * The default buffer size ({@value}) to use for + * {@link #copyLarge(InputStream, OutputStream)} + * and + * {@link #copyLarge(Reader, Writer)} + */ + private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; + + /** + * The default buffer size to use for the skip() methods. + */ + private static final int SKIP_BUFFER_SIZE = 2048; + + // Allocated in the relevant skip method if necessary. + /* + * These buffers are static and are shared between threads. + * This is possible because the buffers are write-only - the contents are never read. + * + * N.B. there is no need to synchronize when creating these because: + * - we don't care if the buffer is created multiple times (the data is ignored) + * - we always use the same size buffer, so if it it is recreated it will still be OK + * (if the buffer size were variable, we would need to synch. to ensure some other thread + * did not create a smaller one) + */ + private static char[] SKIP_CHAR_BUFFER; + private static byte[] SKIP_BYTE_BUFFER; + + /** + * Instances should NOT be constructed in standard programming. + */ + public IOUtils() { + super(); + } + + //----------------------------------------------------------------------- + + /** + * Closes a URLConnection. + * + * @param conn the connection to close. + * @since 2.4 + */ + public static void close(final URLConnection conn) { + if (conn instanceof HttpURLConnection) { + ((HttpURLConnection) conn).disconnect(); + } + } + + /** + * Closes an Reader unconditionally. + *

+ * Equivalent to {@link Reader#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

+ * Example code: + *

+     *   char[] data = new char[1024];
+     *   Reader in = null;
+     *   try {
+     *       in = new FileReader("foo.txt");
+     *       in.read(data);
+     *       in.close(); //close errors are handled
+     *   } catch (Exception e) {
+     *       // error handling
+     *   } finally {
+     *       IOUtils.closeQuietly(in);
+     *   }
+     * 
+ * + * @param input the Reader to close, may be null or already closed + */ + public static void closeQuietly(final Reader input) { + closeQuietly((Closeable) input); + } + + /** + * Closes an Writer unconditionally. + *

+ * Equivalent to {@link Writer#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

+ * Example code: + *

+     *   Writer out = null;
+     *   try {
+     *       out = new StringWriter();
+     *       out.write("Hello World");
+     *       out.close(); //close errors are handled
+     *   } catch (Exception e) {
+     *       // error handling
+     *   } finally {
+     *       IOUtils.closeQuietly(out);
+     *   }
+     * 
+ * + * @param output the Writer to close, may be null or already closed + */ + public static void closeQuietly(final Writer output) { + closeQuietly((Closeable) output); + } + + /** + * Closes an InputStream unconditionally. + *

+ * Equivalent to {@link InputStream#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

+ * Example code: + *

+     *   byte[] data = new byte[1024];
+     *   InputStream in = null;
+     *   try {
+     *       in = new FileInputStream("foo.txt");
+     *       in.read(data);
+     *       in.close(); //close errors are handled
+     *   } catch (Exception e) {
+     *       // error handling
+     *   } finally {
+     *       IOUtils.closeQuietly(in);
+     *   }
+     * 
+ * + * @param input the InputStream to close, may be null or already closed + */ + public static void closeQuietly(final InputStream input) { + closeQuietly((Closeable) input); + } + + /** + * Closes an OutputStream unconditionally. + *

+ * Equivalent to {@link OutputStream#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

+ * Example code: + *

+     * byte[] data = "Hello, World".getBytes();
+     *
+     * OutputStream out = null;
+     * try {
+     *     out = new FileOutputStream("foo.txt");
+     *     out.write(data);
+     *     out.close(); //close errors are handled
+     * } catch (IOException e) {
+     *     // error handling
+     * } finally {
+     *     IOUtils.closeQuietly(out);
+     * }
+     * 
+ * + * @param output the OutputStream to close, may be null or already closed + */ + public static void closeQuietly(final OutputStream output) { + closeQuietly((Closeable) output); + } + + /** + * Closes a Closeable unconditionally. + *

+ * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. This is typically used in + * finally blocks. + *

+ * Example code: + *

+ *
+     * Closeable closeable = null;
+     * try {
+     *     closeable = new FileReader("foo.txt");
+     *     // process closeable
+     *     closeable.close();
+     * } catch (Exception e) {
+     *     // error handling
+     * } finally {
+     *     IOUtils.closeQuietly(closeable);
+     * }
+     * 
+ *

+ * Closing all streams: + *

+ *
+     * try {
+     *     return IOUtils.copy(inputStream, outputStream);
+     * } finally {
+     *     IOUtils.closeQuietly(inputStream);
+     *     IOUtils.closeQuietly(outputStream);
+     * }
+     * 
+ * + * @param closeable the objects to close, may be null or already closed + * @since 2.0 + */ + public static void closeQuietly(final Closeable closeable) { + try { + if (closeable != null) { + closeable.close(); + } + } catch (final IOException ioe) { + // ignore + } + } + + /** + * Closes a Closeable unconditionally. + *

+ * Equivalent to {@link Closeable#close()}, except any exceptions will be ignored. + *

+ * This is typically used in finally blocks to ensure that the closeable is closed + * even if an Exception was thrown before the normal close statement was reached. + *
+ * It should not be used to replace the close statement(s) + * which should be present for the non-exceptional case. + *
+ * It is only intended to simplify tidying up where normal processing has already failed + * and reporting close failure as well is not necessary or useful. + *

+ * Example code: + *

+ *
+     * Closeable closeable = null;
+     * try {
+     *     closeable = new FileReader("foo.txt");
+     *     // processing using the closeable; may throw an Exception
+     *     closeable.close(); // Normal close - exceptions not ignored
+     * } catch (Exception e) {
+     *     // error handling
+     * } finally {
+     *     IOUtils.closeQuietly(closeable); // In case normal close was skipped due to Exception
+     * }
+     * 
+ *

+ * Closing all streams: + *
+ *

+     * try {
+     *     return IOUtils.copy(inputStream, outputStream);
+     * } finally {
+     *     IOUtils.closeQuietly(inputStream, outputStream);
+     * }
+     * 
+ * + * @param closeables the objects to close, may be null or already closed + * @see #closeQuietly(Closeable) + * @since 2.5 + */ + public static void closeQuietly(final Closeable... closeables) { + if (closeables == null) { + return; + } + for (final Closeable closeable : closeables) { + closeQuietly(closeable); + } + } + + /** + * Closes a Socket unconditionally. + *

+ * Equivalent to {@link Socket#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

+ * Example code: + *

+     *   Socket socket = null;
+     *   try {
+     *       socket = new Socket("http://www.foo.com/", 80);
+     *       // process socket
+     *       socket.close();
+     *   } catch (Exception e) {
+     *       // error handling
+     *   } finally {
+     *       IOUtils.closeQuietly(socket);
+     *   }
+     * 
+ * + * @param sock the Socket to close, may be null or already closed + * @since 2.0 + */ + public static void closeQuietly(final Socket sock) { + if (sock != null) { + try { + sock.close(); + } catch (final IOException ioe) { + // ignored + } + } + } + + /** + * Closes a Selector unconditionally. + *

+ * Equivalent to {@link Selector#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

+ * Example code: + *

+     *   Selector selector = null;
+     *   try {
+     *       selector = Selector.open();
+     *       // process socket
+     *
+     *   } catch (Exception e) {
+     *       // error handling
+     *   } finally {
+     *       IOUtils.closeQuietly(selector);
+     *   }
+     * 
+ * + * @param selector the Selector to close, may be null or already closed + * @since 2.2 + */ + public static void closeQuietly(final Selector selector) { + if (selector != null) { + try { + selector.close(); + } catch (final IOException ioe) { + // ignored + } + } + } + + /** + * Closes a ServerSocket unconditionally. + *

+ * Equivalent to {@link ServerSocket#close()}, except any exceptions will be ignored. + * This is typically used in finally blocks. + *

+ * Example code: + *

+     *   ServerSocket socket = null;
+     *   try {
+     *       socket = new ServerSocket();
+     *       // process socket
+     *       socket.close();
+     *   } catch (Exception e) {
+     *       // error handling
+     *   } finally {
+     *       IOUtils.closeQuietly(socket);
+     *   }
+     * 
+ * + * @param sock the ServerSocket to close, may be null or already closed + * @since 2.2 + */ + public static void closeQuietly(final ServerSocket sock) { + if (sock != null) { + try { + sock.close(); + } catch (final IOException ioe) { + // ignored + } + } + } + + /** + * Fetches entire contents of an InputStream and represent + * same data as result InputStream. + *

+ * This method is useful where, + *

    + *
  • Source InputStream is slow.
  • + *
  • It has network resources associated, so we cannot keep it open for + * long time.
  • + *
  • It has network timeout associated.
  • + *
+ * It can be used in favor of {@link #toByteArray(InputStream)}, since it + * avoids unnecessary allocation and copy of byte[].
+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input Stream to be fully buffered. + * @return A fully buffered stream. + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + public static InputStream toBufferedInputStream(final InputStream input) throws IOException { + return ByteArrayOutputStream.toBufferedInputStream(input); + } + + /** + * Fetches entire contents of an InputStream and represent + * same data as result InputStream. + *

+ * This method is useful where, + *

    + *
  • Source InputStream is slow.
  • + *
  • It has network resources associated, so we cannot keep it open for + * long time.
  • + *
  • It has network timeout associated.
  • + *
+ * It can be used in favor of {@link #toByteArray(InputStream)}, since it + * avoids unnecessary allocation and copy of byte[].
+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input Stream to be fully buffered. + * @param size the initial buffer size + * @return A fully buffered stream. + * @throws IOException if an I/O error occurs + * @since 2.5 + */ + public static InputStream toBufferedInputStream(final InputStream input, int size) throws IOException { + return ByteArrayOutputStream.toBufferedInputStream(input, size); + } + + /** + * Returns the given reader if it is a {@link BufferedReader}, otherwise creates a BufferedReader from the given + * reader. + * + * @param reader the reader to wrap or return (not null) + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null + * @see #buffer(Reader) + * @since 2.2 + */ + public static BufferedReader toBufferedReader(final Reader reader) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); + } + + /** + * Returns the given reader if it is a {@link BufferedReader}, otherwise creates a BufferedReader from the given + * reader. + * + * @param reader the reader to wrap or return (not null) + * @param size the buffer size, if a new BufferedReader is created. + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null + * @see #buffer(Reader) + * @since 2.5 + */ + public static BufferedReader toBufferedReader(final Reader reader, int size) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader, size); + } + + /** + * Returns the given reader if it is already a {@link BufferedReader}, otherwise creates a BufferedReader from + * the given reader. + * + * @param reader the reader to wrap or return (not null) + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedReader buffer(final Reader reader) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader); + } + + /** + * Returns the given reader if it is already a {@link BufferedReader}, otherwise creates a BufferedReader from the + * given reader. + * + * @param reader the reader to wrap or return (not null) + * @param size the buffer size, if a new BufferedReader is created. + * @return the given reader or a new {@link BufferedReader} for the given reader + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedReader buffer(final Reader reader, int size) { + return reader instanceof BufferedReader ? (BufferedReader) reader : new BufferedReader(reader, size); + } + + /** + * Returns the given Writer if it is already a {@link BufferedWriter}, otherwise creates a BufferedWriter from the + * given Writer. + * + * @param writer the Writer to wrap or return (not null) + * @return the given Writer or a new {@link BufferedWriter} for the given Writer + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedWriter buffer(final Writer writer) { + return writer instanceof BufferedWriter ? (BufferedWriter) writer : new BufferedWriter(writer); + } + + /** + * Returns the given Writer if it is already a {@link BufferedWriter}, otherwise creates a BufferedWriter from the + * given Writer. + * + * @param writer the Writer to wrap or return (not null) + * @param size the buffer size, if a new BufferedWriter is created. + * @return the given Writer or a new {@link BufferedWriter} for the given Writer + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedWriter buffer(final Writer writer, int size) { + return writer instanceof BufferedWriter ? (BufferedWriter) writer : new BufferedWriter(writer, size); + } + + /** + * Returns the given OutputStream if it is already a {@link BufferedOutputStream}, otherwise creates a + * BufferedOutputStream from the given OutputStream. + * + * @param outputStream the OutputStream to wrap or return (not null) + * @return the given OutputStream or a new {@link BufferedOutputStream} for the given OutputStream + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedOutputStream buffer(final OutputStream outputStream) { + // reject null early on rather than waiting for IO operation to fail + if (outputStream == null) { // not checked by BufferedOutputStream + throw new NullPointerException(); + } + return outputStream instanceof BufferedOutputStream ? + (BufferedOutputStream) outputStream : new BufferedOutputStream(outputStream); + } + + /** + * Returns the given OutputStream if it is already a {@link BufferedOutputStream}, otherwise creates a + * BufferedOutputStream from the given OutputStream. + * + * @param outputStream the OutputStream to wrap or return (not null) + * @param size the buffer size, if a new BufferedOutputStream is created. + * @return the given OutputStream or a new {@link BufferedOutputStream} for the given OutputStream + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedOutputStream buffer(final OutputStream outputStream, int size) { + // reject null early on rather than waiting for IO operation to fail + if (outputStream == null) { // not checked by BufferedOutputStream + throw new NullPointerException(); + } + return outputStream instanceof BufferedOutputStream ? + (BufferedOutputStream) outputStream : new BufferedOutputStream(outputStream, size); + } + + /** + * Returns the given InputStream if it is already a {@link BufferedInputStream}, otherwise creates a + * BufferedInputStream from the given InputStream. + * + * @param inputStream the InputStream to wrap or return (not null) + * @return the given InputStream or a new {@link BufferedInputStream} for the given InputStream + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedInputStream buffer(final InputStream inputStream) { + // reject null early on rather than waiting for IO operation to fail + if (inputStream == null) { // not checked by BufferedInputStream + throw new NullPointerException(); + } + return inputStream instanceof BufferedInputStream ? + (BufferedInputStream) inputStream : new BufferedInputStream(inputStream); + } + + /** + * Returns the given InputStream if it is already a {@link BufferedInputStream}, otherwise creates a + * BufferedInputStream from the given InputStream. + * + * @param inputStream the InputStream to wrap or return (not null) + * @param size the buffer size, if a new BufferedInputStream is created. + * @return the given InputStream or a new {@link BufferedInputStream} for the given InputStream + * @throws NullPointerException if the input parameter is null + * @since 2.5 + */ + public static BufferedInputStream buffer(final InputStream inputStream, int size) { + // reject null early on rather than waiting for IO operation to fail + if (inputStream == null) { // not checked by BufferedInputStream + throw new NullPointerException(); + } + return inputStream instanceof BufferedInputStream ? + (BufferedInputStream) inputStream : new BufferedInputStream(inputStream, size); + } + + // read toByteArray + //----------------------------------------------------------------------- + + /** + * Gets the contents of an InputStream as a byte[]. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from + * @return the requested byte array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + */ + public static byte[] toByteArray(final InputStream input) throws IOException { + final ByteArrayOutputStream output = new ByteArrayOutputStream(); + copy(input, output); + return output.toByteArray(); + } + + /** + * Gets contents of an InputStream as a byte[]. + * Use this method instead of toByteArray(InputStream) + * when InputStream size is known. + * NOTE: the method checks that the length can safely be cast to an int without truncation + * before using {@link IOUtils#toByteArray(java.io.InputStream, int)} to read into the byte array. + * (Arrays can have no more than Integer.MAX_VALUE entries anyway) + * + * @param input the InputStream to read from + * @param size the size of InputStream + * @return the requested byte array + * @throws IOException if an I/O error occurs or InputStream size differ from parameter + * size + * @throws IllegalArgumentException if size is less than zero or size is greater than Integer.MAX_VALUE + * @see IOUtils#toByteArray(java.io.InputStream, int) + * @since 2.1 + */ + public static byte[] toByteArray(final InputStream input, final long size) throws IOException { + + if (size > Integer.MAX_VALUE) { + throw new IllegalArgumentException("Size cannot be greater than Integer max value: " + size); + } + + return toByteArray(input, (int) size); + } + + /** + * Gets the contents of an InputStream as a byte[]. + * Use this method instead of toByteArray(InputStream) + * when InputStream size is known + * + * @param input the InputStream to read from + * @param size the size of InputStream + * @return the requested byte array + * @throws IOException if an I/O error occurs or InputStream size differ from parameter + * size + * @throws IllegalArgumentException if size is less than zero + * @since 2.1 + */ + public static byte[] toByteArray(final InputStream input, final int size) throws IOException { + + if (size < 0) { + throw new IllegalArgumentException("Size must be equal or greater than zero: " + size); + } + + if (size == 0) { + return new byte[0]; + } + + final byte[] data = new byte[size]; + int offset = 0; + int readed; + + while (offset < size && (readed = input.read(data, offset, size - offset)) != EOF) { + offset += readed; + } + + if (offset != size) { + throw new IOException("Unexpected readed size. current: " + offset + ", excepted: " + size); + } + + return data; + } + + /** + * Gets the contents of a Reader as a byte[] + * using the default character encoding of the platform. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + * + * @param input the Reader to read from + * @return the requested byte array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @deprecated 2.5 use {@link #toByteArray(Reader, Charset)} instead + */ + @Deprecated + public static byte[] toByteArray(final Reader input) throws IOException { + return toByteArray(input, Charset.defaultCharset()); + } + + /** + * Gets the contents of a Reader as a byte[] + * using the specified character encoding. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + * + * @param input the Reader to read from + * @param encoding the encoding to use, null means platform default + * @return the requested byte array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static byte[] toByteArray(final Reader input, final Charset encoding) throws IOException { + final ByteArrayOutputStream output = new ByteArrayOutputStream(); + copy(input, output, encoding); + return output.toByteArray(); + } + + /** + * Gets the contents of a Reader as a byte[] + * using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + * + * @param input the Reader to read from + * @param encoding the encoding to use, null means platform default + * @return the requested byte array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static byte[] toByteArray(final Reader input, final String encoding) throws IOException { + return toByteArray(input, Charsets.toCharset(encoding)); + } + + /** + * Gets the contents of a String as a byte[] + * using the default character encoding of the platform. + *

+ * This is the same as {@link String#getBytes()}. + * + * @param input the String to convert + * @return the requested byte array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs (never occurs) + * @deprecated 2.5 Use {@link String#getBytes()} instead + */ + @Deprecated + public static byte[] toByteArray(final String input) throws IOException { + // make explicit the use of the default charset + return input.getBytes(Charset.defaultCharset()); + } + + /** + * Gets the contents of a URI as a byte[]. + * + * @param uri the URI to read + * @return the requested byte array + * @throws NullPointerException if the uri is null + * @throws IOException if an I/O exception occurs + * @since 2.4 + */ + public static byte[] toByteArray(final URI uri) throws IOException { + return IOUtils.toByteArray(uri.toURL()); + } + + /** + * Gets the contents of a URL as a byte[]. + * + * @param url the URL to read + * @return the requested byte array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O exception occurs + * @since 2.4 + */ + public static byte[] toByteArray(final URL url) throws IOException { + final URLConnection conn = url.openConnection(); + try { + return IOUtils.toByteArray(conn); + } finally { + close(conn); + } + } + + /** + * Gets the contents of a URLConnection as a byte[]. + * + * @param urlConn the URLConnection to read + * @return the requested byte array + * @throws NullPointerException if the urlConn is null + * @throws IOException if an I/O exception occurs + * @since 2.4 + */ + public static byte[] toByteArray(final URLConnection urlConn) throws IOException { + final InputStream inputStream = urlConn.getInputStream(); + try { + return IOUtils.toByteArray(inputStream); + } finally { + inputStream.close(); + } + } + + // read char[] + //----------------------------------------------------------------------- + + /** + * Gets the contents of an InputStream as a character array + * using the default character encoding of the platform. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param is the InputStream to read from + * @return the requested character array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #toCharArray(InputStream, Charset)} instead + */ + @Deprecated + public static char[] toCharArray(final InputStream is) throws IOException { + return toCharArray(is, Charset.defaultCharset()); + } + + /** + * Gets the contents of an InputStream as a character array + * using the specified character encoding. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param is the InputStream to read from + * @param encoding the encoding to use, null means platform default + * @return the requested character array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static char[] toCharArray(final InputStream is, final Charset encoding) + throws IOException { + final CharArrayWriter output = new CharArrayWriter(); + copy(is, output, encoding); + return output.toCharArray(); + } + + /** + * Gets the contents of an InputStream as a character array + * using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param is the InputStream to read from + * @param encoding the encoding to use, null means platform default + * @return the requested character array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static char[] toCharArray(final InputStream is, final String encoding) throws IOException { + return toCharArray(is, Charsets.toCharset(encoding)); + } + + /** + * Gets the contents of a Reader as a character array. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + * + * @param input the Reader to read from + * @return the requested character array + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static char[] toCharArray(final Reader input) throws IOException { + final CharArrayWriter sw = new CharArrayWriter(); + copy(input, sw); + return sw.toCharArray(); + } + + // read toString + //----------------------------------------------------------------------- + + /** + * Gets the contents of an InputStream as a String + * using the default character encoding of the platform. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from + * @return the requested String + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @deprecated 2.5 use {@link #toString(InputStream, Charset)} instead + */ + @Deprecated + public static String toString(final InputStream input) throws IOException { + return toString(input, Charset.defaultCharset()); + } + + /** + * Gets the contents of an InputStream as a String + * using the specified character encoding. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

+ * + * @param input the InputStream to read from + * @param encoding the encoding to use, null means platform default + * @return the requested String + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static String toString(final InputStream input, final Charset encoding) throws IOException { + final StringBuilderWriter sw = new StringBuilderWriter(); + copy(input, sw, encoding); + return sw.toString(); + } + + /** + * Gets the contents of an InputStream as a String + * using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from + * @param encoding the encoding to use, null means platform default + * @return the requested String + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + */ + public static String toString(final InputStream input, final String encoding) + throws IOException { + return toString(input, Charsets.toCharset(encoding)); + } + + /** + * Gets the contents of a Reader as a String. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + * + * @param input the Reader to read from + * @return the requested String + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + */ + public static String toString(final Reader input) throws IOException { + final StringBuilderWriter sw = new StringBuilderWriter(); + copy(input, sw); + return sw.toString(); + } + + /** + * Gets the contents at the given URI. + * + * @param uri The URI source. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @since 2.1 + * @deprecated 2.5 use {@link #toString(URI, Charset)} instead + */ + @Deprecated + public static String toString(final URI uri) throws IOException { + return toString(uri, Charset.defaultCharset()); + } + + /** + * Gets the contents at the given URI. + * + * @param uri The URI source. + * @param encoding The encoding name for the URL contents. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @since 2.3. + */ + public static String toString(final URI uri, final Charset encoding) throws IOException { + return toString(uri.toURL(), Charsets.toCharset(encoding)); + } + + /** + * Gets the contents at the given URI. + * + * @param uri The URI source. + * @param encoding The encoding name for the URL contents. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 2.1 + */ + public static String toString(final URI uri, final String encoding) throws IOException { + return toString(uri, Charsets.toCharset(encoding)); + } + + /** + * Gets the contents at the given URL. + * + * @param url The URL source. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @since 2.1 + * @deprecated 2.5 use {@link #toString(URL, Charset)} instead + */ + @Deprecated + public static String toString(final URL url) throws IOException { + return toString(url, Charset.defaultCharset()); + } + + /** + * Gets the contents at the given URL. + * + * @param url The URL source. + * @param encoding The encoding name for the URL contents. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @since 2.3 + */ + public static String toString(final URL url, final Charset encoding) throws IOException { + final InputStream inputStream = url.openStream(); + try { + return toString(inputStream, encoding); + } finally { + inputStream.close(); + } + } + + /** + * Gets the contents at the given URL. + * + * @param url The URL source. + * @param encoding The encoding name for the URL contents. + * @return The contents of the URL as a String. + * @throws IOException if an I/O exception occurs. + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 2.1 + */ + public static String toString(final URL url, final String encoding) throws IOException { + return toString(url, Charsets.toCharset(encoding)); + } + + /** + * Gets the contents of a byte[] as a String + * using the default character encoding of the platform. + * + * @param input the byte array to read from + * @return the requested String + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs (never occurs) + * @deprecated 2.5 Use {@link String#String(byte[])} instead + */ + @Deprecated + public static String toString(final byte[] input) throws IOException { + // make explicit the use of the default charset + return new String(input, Charset.defaultCharset()); + } + + /** + * Gets the contents of a byte[] as a String + * using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + * + * @param input the byte array to read from + * @param encoding the encoding to use, null means platform default + * @return the requested String + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs (never occurs) + */ + public static String toString(final byte[] input, final String encoding) throws IOException { + return new String(input, Charsets.toCharset(encoding)); + } + + // readLines + //----------------------------------------------------------------------- + + /** + * Gets the contents of an InputStream as a list of Strings, + * one entry per line, using the default character encoding of the platform. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from, not null + * @return the list of Strings, never null + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #readLines(InputStream, Charset)} instead + */ + @Deprecated + public static List readLines(final InputStream input) throws IOException { + return readLines(input, Charset.defaultCharset()); + } + + /** + * Gets the contents of an InputStream as a list of Strings, + * one entry per line, using the specified character encoding. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from, not null + * @param encoding the encoding to use, null means platform default + * @return the list of Strings, never null + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static List readLines(final InputStream input, final Charset encoding) throws IOException { + final InputStreamReader reader = new InputStreamReader(input, Charsets.toCharset(encoding)); + return readLines(reader); + } + + /** + * Gets the contents of an InputStream as a list of Strings, + * one entry per line, using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input the InputStream to read from, not null + * @param encoding the encoding to use, null means platform default + * @return the list of Strings, never null + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static List readLines(final InputStream input, final String encoding) throws IOException { + return readLines(input, Charsets.toCharset(encoding)); + } + + /** + * Gets the contents of a Reader as a list of Strings, + * one entry per line. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + * + * @param input the Reader to read from, not null + * @return the list of Strings, never null + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static List readLines(final Reader input) throws IOException { + final BufferedReader reader = toBufferedReader(input); + final List list = new ArrayList(); + String line = reader.readLine(); + while (line != null) { + list.add(line); + line = reader.readLine(); + } + return list; + } + + // lineIterator + //----------------------------------------------------------------------- + + /** + * Returns an Iterator for the lines in a Reader. + *

+ * LineIterator holds a reference to the open + * Reader specified here. 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 + * {@link LineIterator#close()} or {@link LineIterator#closeQuietly(LineIterator)}. + *

+ * The recommended usage pattern is: + *

+     * try {
+     *   LineIterator it = IOUtils.lineIterator(reader);
+     *   while (it.hasNext()) {
+     *     String line = it.nextLine();
+     *     /// do something with line
+     *   }
+     * } finally {
+     *   IOUtils.closeQuietly(reader);
+     * }
+     * 
+ * + * @param reader the Reader to read from, not null + * @return an Iterator of the lines in the reader, never null + * @throws IllegalArgumentException if the reader is null + * @since 1.2 + */ + public static LineIterator lineIterator(final Reader reader) { + return new LineIterator(reader); + } + + /** + * Returns an Iterator for the lines in an InputStream, using + * the character encoding specified (or default encoding if null). + *

+ * LineIterator holds a reference to the open + * InputStream specified here. When you have finished with + * the iterator you should close the stream to free internal resources. + * This can be done by closing the stream directly, or by calling + * {@link LineIterator#close()} or {@link LineIterator#closeQuietly(LineIterator)}. + *

+ * The recommended usage pattern is: + *

+     * try {
+     *   LineIterator it = IOUtils.lineIterator(stream, charset);
+     *   while (it.hasNext()) {
+     *     String line = it.nextLine();
+     *     /// do something with line
+     *   }
+     * } finally {
+     *   IOUtils.closeQuietly(stream);
+     * }
+     * 
+ * + * @param input the InputStream to read from, not null + * @param encoding the encoding to use, null means platform default + * @return an Iterator of the lines in the reader, never null + * @throws IllegalArgumentException if the input is null + * @throws IOException if an I/O error occurs, such as if the encoding is invalid + * @since 2.3 + */ + public static LineIterator lineIterator(final InputStream input, final Charset encoding) throws IOException { + return new LineIterator(new InputStreamReader(input, Charsets.toCharset(encoding))); + } + + /** + * Returns an Iterator for the lines in an InputStream, using + * the character encoding specified (or default encoding if null). + *

+ * LineIterator holds a reference to the open + * InputStream specified here. When you have finished with + * the iterator you should close the stream to free internal resources. + * This can be done by closing the stream directly, or by calling + * {@link LineIterator#close()} or {@link LineIterator#closeQuietly(LineIterator)}. + *

+ * The recommended usage pattern is: + *

+     * try {
+     *   LineIterator it = IOUtils.lineIterator(stream, "UTF-8");
+     *   while (it.hasNext()) {
+     *     String line = it.nextLine();
+     *     /// do something with line
+     *   }
+     * } finally {
+     *   IOUtils.closeQuietly(stream);
+     * }
+     * 
+ * + * @param input the InputStream to read from, not null + * @param encoding the encoding to use, null means platform default + * @return an Iterator of the lines in the reader, never null + * @throws IllegalArgumentException if the input is null + * @throws IOException if an I/O error occurs, such as if the encoding is invalid + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.2 + */ + public static LineIterator lineIterator(final InputStream input, final String encoding) throws IOException { + return lineIterator(input, Charsets.toCharset(encoding)); + } + + //----------------------------------------------------------------------- + + /** + * Converts the specified CharSequence to an input stream, encoded as bytes + * using the default character encoding of the platform. + * + * @param input the CharSequence to convert + * @return an input stream + * @since 2.0 + * @deprecated 2.5 use {@link #toInputStream(CharSequence, Charset)} instead + */ + @Deprecated + public static InputStream toInputStream(final CharSequence input) { + return toInputStream(input, Charset.defaultCharset()); + } + + /** + * Converts the specified CharSequence to an input stream, encoded as bytes + * using the specified character encoding. + * + * @param input the CharSequence to convert + * @param encoding the encoding to use, null means platform default + * @return an input stream + * @since 2.3 + */ + public static InputStream toInputStream(final CharSequence input, final Charset encoding) { + return toInputStream(input.toString(), encoding); + } + + /** + * Converts the specified CharSequence to an input stream, encoded as bytes + * using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + * + * @param input the CharSequence to convert + * @param encoding the encoding to use, null means platform default + * @return an input stream + * @throws IOException if the encoding is invalid + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 2.0 + */ + public static InputStream toInputStream(final CharSequence input, final String encoding) throws IOException { + return toInputStream(input, Charsets.toCharset(encoding)); + } + + //----------------------------------------------------------------------- + + /** + * Converts the specified string to an input stream, encoded as bytes + * using the default character encoding of the platform. + * + * @param input the string to convert + * @return an input stream + * @since 1.1 + * @deprecated 2.5 use {@link #toInputStream(String, Charset)} instead + */ + @Deprecated + public static InputStream toInputStream(final String input) { + return toInputStream(input, Charset.defaultCharset()); + } + + /** + * Converts the specified string to an input stream, encoded as bytes + * using the specified character encoding. + * + * @param input the string to convert + * @param encoding the encoding to use, null means platform default + * @return an input stream + * @since 2.3 + */ + public static InputStream toInputStream(final String input, final Charset encoding) { + return new ByteArrayInputStream(input.getBytes(Charsets.toCharset(encoding))); + } + + /** + * Converts the specified string to an input stream, encoded as bytes + * using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + * + * @param input the string to convert + * @param encoding the encoding to use, null means platform default + * @return an input stream + * @throws IOException if the encoding is invalid + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static InputStream toInputStream(final String input, final String encoding) throws IOException { + final byte[] bytes = input.getBytes(Charsets.toCharset(encoding)); + return new ByteArrayInputStream(bytes); + } + + // write byte[] + //----------------------------------------------------------------------- + + /** + * Writes bytes from a byte[] to an OutputStream. + * + * @param data the byte array to write, do not modify during output, + * null ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static void write(final byte[] data, final OutputStream output) + throws IOException { + if (data != null) { + output.write(data); + } + } + + /** + * Writes bytes from a byte[] to an OutputStream using chunked writes. + * This is intended for writing very large byte arrays which might otherwise cause excessive + * memory usage if the native code has to allocate a copy. + * + * @param data the byte array to write, do not modify during output, + * null ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.5 + */ + public static void writeChunked(final byte[] data, final OutputStream output) + throws IOException { + if (data != null) { + int bytes = data.length; + int offset = 0; + while (bytes > 0) { + int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); + output.write(data, offset, chunk); + bytes -= chunk; + offset += chunk; + } + } + } + + /** + * Writes bytes from a byte[] to chars on a Writer + * using the default character encoding of the platform. + *

+ * This method uses {@link String#String(byte[])}. + * + * @param data the byte array to write, do not modify during output, + * null ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #write(byte[], Writer, Charset)} instead + */ + @Deprecated + public static void write(final byte[] data, final Writer output) throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes bytes from a byte[] to chars on a Writer + * using the specified character encoding. + *

+ * This method uses {@link String#String(byte[], String)}. + * + * @param data the byte array to write, do not modify during output, + * null ignored + * @param output the Writer to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(final byte[] data, final Writer output, final Charset encoding) throws IOException { + if (data != null) { + output.write(new String(data, Charsets.toCharset(encoding))); + } + } + + /** + * Writes bytes from a byte[] to chars on a Writer + * using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method uses {@link String#String(byte[], String)}. + * + * @param data the byte array to write, do not modify during output, + * null ignored + * @param output the Writer to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static void write(final byte[] data, final Writer output, final String encoding) throws IOException { + write(data, output, Charsets.toCharset(encoding)); + } + + // write char[] + //----------------------------------------------------------------------- + + /** + * Writes chars from a char[] to a Writer + * + * @param data the char array to write, do not modify during output, + * null ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static void write(final char[] data, final Writer output) throws IOException { + if (data != null) { + output.write(data); + } + } + + /** + * Writes chars from a char[] to a Writer using chunked writes. + * This is intended for writing very large byte arrays which might otherwise cause excessive + * memory usage if the native code has to allocate a copy. + * + * @param data the char array to write, do not modify during output, + * null ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.5 + */ + public static void writeChunked(final char[] data, final Writer output) throws IOException { + if (data != null) { + int bytes = data.length; + int offset = 0; + while (bytes > 0) { + int chunk = Math.min(bytes, DEFAULT_BUFFER_SIZE); + output.write(data, offset, chunk); + bytes -= chunk; + offset += chunk; + } + } + } + + /** + * Writes chars from a char[] to bytes on an + * OutputStream. + *

+ * This method uses {@link String#String(char[])} and + * {@link String#getBytes()}. + * + * @param data the char array to write, do not modify during output, + * null ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #write(char[], OutputStream, Charset)} instead + */ + @Deprecated + public static void write(final char[] data, final OutputStream output) + throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes chars from a char[] to bytes on an + * OutputStream using the specified character encoding. + *

+ * This method uses {@link String#String(char[])} and + * {@link String#getBytes(String)}. + * + * @param data the char array to write, do not modify during output, + * null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(final char[] data, final OutputStream output, final Charset encoding) throws IOException { + if (data != null) { + output.write(new String(data).getBytes(Charsets.toCharset(encoding))); + } + } + + /** + * Writes chars from a char[] to bytes on an + * OutputStream using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method uses {@link String#String(char[])} and + * {@link String#getBytes(String)}. + * + * @param data the char array to write, do not modify during output, + * null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. + * @since 1.1 + */ + public static void write(final char[] data, final OutputStream output, final String encoding) + throws IOException { + write(data, output, Charsets.toCharset(encoding)); + } + + // write CharSequence + //----------------------------------------------------------------------- + + /** + * Writes chars from a CharSequence to a Writer. + * + * @param data the CharSequence to write, null ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + public static void write(final CharSequence data, final Writer output) throws IOException { + if (data != null) { + write(data.toString(), output); + } + } + + /** + * Writes chars from a CharSequence to bytes on an + * OutputStream using the default character encoding of the + * platform. + *

+ * This method uses {@link String#getBytes()}. + * + * @param data the CharSequence to write, null ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.0 + * @deprecated 2.5 use {@link #write(CharSequence, OutputStream, Charset)} instead + */ + @Deprecated + public static void write(final CharSequence data, final OutputStream output) + throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes chars from a CharSequence to bytes on an + * OutputStream using the specified character encoding. + *

+ * This method uses {@link String#getBytes(String)}. + * + * @param data the CharSequence to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(final CharSequence data, final OutputStream output, final Charset encoding) + throws IOException { + if (data != null) { + write(data.toString(), output, encoding); + } + } + + /** + * Writes chars from a CharSequence to bytes on an + * OutputStream using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method uses {@link String#getBytes(String)}. + * + * @param data the CharSequence to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. + * @since 2.0 + */ + public static void write(final CharSequence data, final OutputStream output, final String encoding) + throws IOException { + write(data, output, Charsets.toCharset(encoding)); + } + + // write String + //----------------------------------------------------------------------- + + /** + * Writes chars from a String to a Writer. + * + * @param data the String to write, null ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static void write(final String data, final Writer output) throws IOException { + if (data != null) { + output.write(data); + } + } + + /** + * Writes chars from a String to bytes on an + * OutputStream using the default character encoding of the + * platform. + *

+ * This method uses {@link String#getBytes()}. + * + * @param data the String to write, null ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #write(String, OutputStream, Charset)} instead + */ + @Deprecated + public static void write(final String data, final OutputStream output) + throws IOException { + write(data, output, Charset.defaultCharset()); + } + + /** + * Writes chars from a String to bytes on an + * OutputStream using the specified character encoding. + *

+ * This method uses {@link String#getBytes(String)}. + * + * @param data the String to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void write(final String data, final OutputStream output, final Charset encoding) throws IOException { + if (data != null) { + output.write(data.getBytes(Charsets.toCharset(encoding))); + } + } + + /** + * Writes chars from a String to bytes on an + * OutputStream using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method uses {@link String#getBytes(String)}. + * + * @param data the String to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. + * @since 1.1 + */ + public static void write(final String data, final OutputStream output, final String encoding) + throws IOException { + write(data, output, Charsets.toCharset(encoding)); + } + + // write StringBuffer + //----------------------------------------------------------------------- + + /** + * Writes chars from a StringBuffer to a Writer. + * + * @param data the StringBuffer to write, null ignored + * @param output the Writer to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated replaced by write(CharSequence, Writer) + */ + @Deprecated + public static void write(final StringBuffer data, final Writer output) + throws IOException { + if (data != null) { + output.write(data.toString()); + } + } + + /** + * Writes chars from a StringBuffer to bytes on an + * OutputStream using the default character encoding of the + * platform. + *

+ * This method uses {@link String#getBytes()}. + * + * @param data the StringBuffer to write, null ignored + * @param output the OutputStream to write to + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated replaced by write(CharSequence, OutputStream) + */ + @Deprecated + public static void write(final StringBuffer data, final OutputStream output) + throws IOException { + write(data, output, (String) null); + } + + /** + * Writes chars from a StringBuffer to bytes on an + * OutputStream using the specified character encoding. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method uses {@link String#getBytes(String)}. + * + * @param data the StringBuffer to write, null ignored + * @param output the OutputStream to write to + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the encoding is not supported. + * @since 1.1 + * @deprecated replaced by write(CharSequence, OutputStream, String) + */ + @Deprecated + public static void write(final StringBuffer data, final OutputStream output, final String encoding) + throws IOException { + if (data != null) { + output.write(data.toString().getBytes(Charsets.toCharset(encoding))); + } + } + + // writeLines + //----------------------------------------------------------------------- + + /** + * Writes the toString() value of each item in a collection to + * an OutputStream line by line, using the default character + * encoding of the platform and the specified line ending. + * + * @param lines the lines to write, null entries produce blank lines + * @param lineEnding the line separator to use, null is system default + * @param output the OutputStream to write to, not null, not closed + * @throws NullPointerException if the output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #writeLines(Collection, String, OutputStream, Charset)} instead + */ + @Deprecated + public static void writeLines(final Collection lines, final String lineEnding, + final OutputStream output) throws IOException { + writeLines(lines, lineEnding, output, Charset.defaultCharset()); + } + + /** + * Writes the toString() value of each item in a collection to + * an OutputStream line by line, using the specified character + * encoding and the specified line ending. + * + * @param lines the lines to write, null entries produce blank lines + * @param lineEnding the line separator to use, null is system default + * @param output the OutputStream to write to, not null, not closed + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void writeLines(final Collection lines, String lineEnding, final OutputStream output, + final Charset encoding) throws IOException { + if (lines == null) { + return; + } + if (lineEnding == null) { + lineEnding = LINE_SEPARATOR; + } + final Charset cs = Charsets.toCharset(encoding); + for (final Object line : lines) { + if (line != null) { + output.write(line.toString().getBytes(cs)); + } + output.write(lineEnding.getBytes(cs)); + } + } + + /** + * Writes the toString() value of each item in a collection to + * an OutputStream line by line, using the specified character + * encoding and the specified line ending. + *

+ * Character encoding names can be found at + * IANA. + * + * @param lines the lines to write, null entries produce blank lines + * @param lineEnding the line separator to use, null is system default + * @param output the OutputStream to write to, not null, not closed + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static void writeLines(final Collection lines, final String lineEnding, + final OutputStream output, final String encoding) throws IOException { + writeLines(lines, lineEnding, output, Charsets.toCharset(encoding)); + } + + /** + * Writes the toString() value of each item in a collection to + * a Writer line by line, using the specified line ending. + * + * @param lines the lines to write, null entries produce blank lines + * @param lineEnding the line separator to use, null is system default + * @param writer the Writer to write to, not null, not closed + * @throws NullPointerException if the input is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static void writeLines(final Collection lines, String lineEnding, + final Writer writer) throws IOException { + if (lines == null) { + return; + } + if (lineEnding == null) { + lineEnding = LINE_SEPARATOR; + } + for (final Object line : lines) { + if (line != null) { + writer.write(line.toString()); + } + writer.write(lineEnding); + } + } + + // copy from InputStream + //----------------------------------------------------------------------- + + /** + * Copies bytes from an InputStream to an + * OutputStream. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

+ * Large streams (over 2GB) will return a bytes copied value of + * -1 after the copy has completed since the correct + * number of bytes cannot be returned as an int. For large streams + * use the copyLarge(InputStream, OutputStream) method. + * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @return the number of bytes copied, or -1 if > Integer.MAX_VALUE + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static int copy(final InputStream input, final OutputStream output) throws IOException { + final long count = copyLarge(input, output); + if (count > Integer.MAX_VALUE) { + return -1; + } + return (int) count; + } + + /** + * Copies bytes from an InputStream to an OutputStream using an internal buffer of the + * given size. + *

+ * This method buffers the input internally, so there is no need to use a BufferedInputStream. + *

+ * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param bufferSize the bufferSize used to copy from the input to the output + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.5 + */ + public static long copy(final InputStream input, final OutputStream output, final int bufferSize) + throws IOException { + return copyLarge(input, output, new byte[bufferSize]); + } + + /** + * Copies bytes from a large (over 2GB) InputStream to an + * OutputStream. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

+ * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. + * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 1.3 + */ + public static long copyLarge(final InputStream input, final OutputStream output) + throws IOException { + return copy(input, output, DEFAULT_BUFFER_SIZE); + } + + /** + * Copies bytes from a large (over 2GB) InputStream to an + * OutputStream. + *

+ * This method uses the provided buffer, so there is no need to use a + * BufferedInputStream. + *

+ * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param buffer the buffer to use for the copy + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(final InputStream input, final OutputStream output, final byte[] buffer) + throws IOException { + long count = 0; + int n; + while (EOF != (n = input.read(buffer))) { + output.write(buffer, 0, n); + count += n; + } + return count; + } + + /** + * Copies some or all bytes from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input bytes. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

+ *

+ * Note that the implementation uses {@link #skip(InputStream, long)}. + * This means that the method may be considerably less efficient than using the actual skip implementation, + * this is done to guarantee that the correct number of characters are skipped. + *

+ * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. + * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param inputOffset : number of bytes to skip from input before copying + * -ve values are ignored + * @param length : number of bytes to copy. -ve means all + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(final InputStream input, final OutputStream output, final long inputOffset, + final long length) throws IOException { + return copyLarge(input, output, inputOffset, length, new byte[DEFAULT_BUFFER_SIZE]); + } + + /** + * Copies some or all bytes from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input bytes. + *

+ * This method uses the provided buffer, so there is no need to use a + * BufferedInputStream. + *

+ *

+ * Note that the implementation uses {@link #skip(InputStream, long)}. + * This means that the method may be considerably less efficient than using the actual skip implementation, + * this is done to guarantee that the correct number of characters are skipped. + *

+ * + * @param input the InputStream to read from + * @param output the OutputStream to write to + * @param inputOffset : number of bytes to skip from input before copying + * -ve values are ignored + * @param length : number of bytes to copy. -ve means all + * @param buffer the buffer to use for the copy + * @return the number of bytes copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(final InputStream input, final OutputStream output, + final long inputOffset, final long length, final byte[] buffer) throws IOException { + if (inputOffset > 0) { + skipFully(input, inputOffset); + } + if (length == 0) { + return 0; + } + final int bufferLength = buffer.length; + int bytesToRead = bufferLength; + if (length > 0 && length < bufferLength) { + bytesToRead = (int) length; + } + int read; + long totalRead = 0; + while (bytesToRead > 0 && EOF != (read = input.read(buffer, 0, bytesToRead))) { + output.write(buffer, 0, read); + totalRead += read; + if (length > 0) { // only adjust length if not reading to the end + // Note the cast must work because buffer.length is an integer + bytesToRead = (int) Math.min(length - totalRead, bufferLength); + } + } + return totalRead; + } + + /** + * Copies bytes from an InputStream to chars on a + * Writer using the default character encoding of the platform. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

+ * This method uses {@link InputStreamReader}. + * + * @param input the InputStream to read from + * @param output the Writer to write to + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #copy(InputStream, Writer, Charset)} instead + */ + @Deprecated + public static void copy(final InputStream input, final Writer output) + throws IOException { + copy(input, output, Charset.defaultCharset()); + } + + /** + * Copies bytes from an InputStream to chars on a + * Writer using the specified character encoding. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

+ * This method uses {@link InputStreamReader}. + * + * @param input the InputStream to read from + * @param output the Writer to write to + * @param inputEncoding the encoding to use for the input stream, null means platform default + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void copy(final InputStream input, final Writer output, final Charset inputEncoding) + throws IOException { + final InputStreamReader in = new InputStreamReader(input, Charsets.toCharset(inputEncoding)); + copy(in, output); + } + + /** + * Copies bytes from an InputStream to chars on a + * Writer using the specified character encoding. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + *

+ * Character encoding names can be found at + * IANA. + *

+ * This method uses {@link InputStreamReader}. + * + * @param input the InputStream to read from + * @param output the Writer to write to + * @param inputEncoding the encoding to use for the InputStream, null means platform default + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static void copy(final InputStream input, final Writer output, final String inputEncoding) + throws IOException { + copy(input, output, Charsets.toCharset(inputEncoding)); + } + + // copy from Reader + //----------------------------------------------------------------------- + + /** + * Copies chars from a Reader to a Writer. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

+ * Large streams (over 2GB) will return a chars copied value of + * -1 after the copy has completed since the correct + * number of chars cannot be returned as an int. For large streams + * use the copyLarge(Reader, Writer) method. + * + * @param input the Reader to read from + * @param output the Writer to write to + * @return the number of characters copied, or -1 if > Integer.MAX_VALUE + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static int copy(final Reader input, final Writer output) throws IOException { + final long count = copyLarge(input, output); + if (count > Integer.MAX_VALUE) { + return -1; + } + return (int) count; + } + + /** + * Copies chars from a large (over 2GB) Reader to a Writer. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

+ * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. + * + * @param input the Reader to read from + * @param output the Writer to write to + * @return the number of characters copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 1.3 + */ + public static long copyLarge(final Reader input, final Writer output) throws IOException { + return copyLarge(input, output, new char[DEFAULT_BUFFER_SIZE]); + } + + /** + * Copies chars from a large (over 2GB) Reader to a Writer. + *

+ * This method uses the provided buffer, so there is no need to use a + * BufferedReader. + *

+ * + * @param input the Reader to read from + * @param output the Writer to write to + * @param buffer the buffer to be used for the copy + * @return the number of characters copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(final Reader input, final Writer output, final char[] buffer) throws IOException { + long count = 0; + int n; + while (EOF != (n = input.read(buffer))) { + output.write(buffer, 0, n); + count += n; + } + return count; + } + + /** + * Copies some or all chars from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input chars. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

+ * The buffer size is given by {@link #DEFAULT_BUFFER_SIZE}. + * + * @param input the Reader to read from + * @param output the Writer to write to + * @param inputOffset : number of chars to skip from input before copying + * -ve values are ignored + * @param length : number of chars to copy. -ve means all + * @return the number of chars copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(final Reader input, final Writer output, final long inputOffset, final long length) + throws IOException { + return copyLarge(input, output, inputOffset, length, new char[DEFAULT_BUFFER_SIZE]); + } + + /** + * Copies some or all chars from a large (over 2GB) InputStream to an + * OutputStream, optionally skipping input chars. + *

+ * This method uses the provided buffer, so there is no need to use a + * BufferedReader. + *

+ * + * @param input the Reader to read from + * @param output the Writer to write to + * @param inputOffset : number of chars to skip from input before copying + * -ve values are ignored + * @param length : number of chars to copy. -ve means all + * @param buffer the buffer to be used for the copy + * @return the number of chars copied + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static long copyLarge(final Reader input, final Writer output, final long inputOffset, final long length, + final char[] buffer) + throws IOException { + if (inputOffset > 0) { + skipFully(input, inputOffset); + } + if (length == 0) { + return 0; + } + int bytesToRead = buffer.length; + if (length > 0 && length < buffer.length) { + bytesToRead = (int) length; + } + int read; + long totalRead = 0; + while (bytesToRead > 0 && EOF != (read = input.read(buffer, 0, bytesToRead))) { + output.write(buffer, 0, read); + totalRead += read; + if (length > 0) { // only adjust length if not reading to the end + // Note the cast must work because buffer.length is an integer + bytesToRead = (int) Math.min(length - totalRead, buffer.length); + } + } + return totalRead; + } + + /** + * Copies chars from a Reader to bytes on an + * OutputStream using the default character encoding of the + * platform, and calling flush. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

+ * Due to the implementation of OutputStreamWriter, this method performs a + * flush. + *

+ * This method uses {@link OutputStreamWriter}. + * + * @param input the Reader to read from + * @param output the OutputStream to write to + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 1.1 + * @deprecated 2.5 use {@link #copy(Reader, OutputStream, Charset)} instead + */ + @Deprecated + public static void copy(final Reader input, final OutputStream output) + throws IOException { + copy(input, output, Charset.defaultCharset()); + } + + /** + * Copies chars from a Reader to bytes on an + * OutputStream using the specified character encoding, and + * calling flush. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

+ *

+ * Due to the implementation of OutputStreamWriter, this method performs a + * flush. + *

+ *

+ * This method uses {@link OutputStreamWriter}. + *

+ * + * @param input the Reader to read from + * @param output the OutputStream to write to + * @param outputEncoding the encoding to use for the OutputStream, null means platform default + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + public static void copy(final Reader input, final OutputStream output, final Charset outputEncoding) + throws IOException { + final OutputStreamWriter out = new OutputStreamWriter(output, Charsets.toCharset(outputEncoding)); + copy(input, out); + // XXX Unless anyone is planning on rewriting OutputStreamWriter, + // we have to flush here. + out.flush(); + } + + /** + * Copies chars from a Reader to bytes on an + * OutputStream using the specified character encoding, and + * calling flush. + *

+ * This method buffers the input internally, so there is no need to use a + * BufferedReader. + *

+ * Character encoding names can be found at + * IANA. + *

+ * Due to the implementation of OutputStreamWriter, this method performs a + * flush. + *

+ * This method uses {@link OutputStreamWriter}. + * + * @param input the Reader to read from + * @param output the OutputStream to write to + * @param outputEncoding the encoding to use for the OutputStream, null means platform default + * @throws NullPointerException if the input or output is null + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link java.io + * .UnsupportedEncodingException} in version 2.2 if the + * encoding is not supported. + * @since 1.1 + */ + public static void copy(final Reader input, final OutputStream output, final String outputEncoding) + throws IOException { + copy(input, output, Charsets.toCharset(outputEncoding)); + } + + // content equals + //----------------------------------------------------------------------- + + /** + * Compares the contents of two Streams to determine if they are equal or + * not. + *

+ * This method buffers the input internally using + * BufferedInputStream if they are not already buffered. + * + * @param input1 the first stream + * @param input2 the second stream + * @return true if the content of the streams are equal or they both don't + * exist, false otherwise + * @throws NullPointerException if either input is null + * @throws IOException if an I/O error occurs + */ + public static boolean contentEquals(InputStream input1, InputStream input2) + throws IOException { + if (input1 == input2) { + return true; + } + if (!(input1 instanceof BufferedInputStream)) { + input1 = new BufferedInputStream(input1); + } + if (!(input2 instanceof BufferedInputStream)) { + input2 = new BufferedInputStream(input2); + } + + int ch = input1.read(); + while (EOF != ch) { + final int ch2 = input2.read(); + if (ch != ch2) { + return false; + } + ch = input1.read(); + } + + final int ch2 = input2.read(); + return ch2 == EOF; + } + + /** + * Compares the contents of two Readers to determine if they are equal or + * not. + *

+ * This method buffers the input internally using + * BufferedReader if they are not already buffered. + * + * @param input1 the first reader + * @param input2 the second reader + * @return true if the content of the readers are equal or they both don't + * exist, false otherwise + * @throws NullPointerException if either input is null + * @throws IOException if an I/O error occurs + * @since 1.1 + */ + public static boolean contentEquals(Reader input1, Reader input2) + throws IOException { + if (input1 == input2) { + return true; + } + + input1 = toBufferedReader(input1); + input2 = toBufferedReader(input2); + + int ch = input1.read(); + while (EOF != ch) { + final int ch2 = input2.read(); + if (ch != ch2) { + return false; + } + ch = input1.read(); + } + + final int ch2 = input2.read(); + return ch2 == EOF; + } + + /** + * Compares the contents of two Readers to determine if they are equal or + * not, ignoring EOL characters. + *

+ * This method buffers the input internally using + * BufferedReader if they are not already buffered. + * + * @param input1 the first reader + * @param input2 the second reader + * @return true if the content of the readers are equal (ignoring EOL differences), false otherwise + * @throws NullPointerException if either input is null + * @throws IOException if an I/O error occurs + * @since 2.2 + */ + public static boolean contentEqualsIgnoreEOL(final Reader input1, final Reader input2) + throws IOException { + if (input1 == input2) { + return true; + } + final BufferedReader br1 = toBufferedReader(input1); + final BufferedReader br2 = toBufferedReader(input2); + + String line1 = br1.readLine(); + String line2 = br2.readLine(); + while (line1 != null && line2 != null && line1.equals(line2)) { + line1 = br1.readLine(); + line2 = br2.readLine(); + } + return line1 == null ? line2 == null ? true : false : line1.equals(line2); + } + + /** + * Skips bytes from an input byte stream. + * This implementation guarantees that it will read as many bytes + * as possible before giving up; this may not always be the case for + * skip() implementations in subclasses of {@link InputStream}. + *

+ * Note that the implementation uses {@link InputStream#read(byte[], int, int)} rather + * than delegating to {@link InputStream#skip(long)}. + * This means that the method may be considerably less efficient than using the actual skip implementation, + * this is done to guarantee that the correct number of bytes are skipped. + *

+ * + * @param input byte stream to skip + * @param toSkip number of bytes to skip. + * @return number of bytes actually skipped. + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative + * @see InputStream#skip(long) + * @see IO-203 - Add skipFully() method for InputStreams + * @since 2.0 + */ + public static long skip(final InputStream input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); + } + /* + * N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data + * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer + * size were variable, we would need to synch. to ensure some other thread did not create a smaller one) + */ + if (SKIP_BYTE_BUFFER == null) { + SKIP_BYTE_BUFFER = new byte[SKIP_BUFFER_SIZE]; + } + long remain = toSkip; + while (remain > 0) { + // See https://issues.apache.org/jira/browse/IO-203 for why we use read() rather than delegating to skip() + final long n = input.read(SKIP_BYTE_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE)); + if (n < 0) { // EOF + break; + } + remain -= n; + } + return toSkip - remain; + } + + /** + * Skips bytes from a ReadableByteChannel. + * This implementation guarantees that it will read as many bytes + * as possible before giving up. + * + * @param input ReadableByteChannel to skip + * @param toSkip number of bytes to skip. + * @return number of bytes actually skipped. + * @throws IOException if there is a problem reading the ReadableByteChannel + * @throws IllegalArgumentException if toSkip is negative + * @since 2.5 + */ + public static long skip(final ReadableByteChannel input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); + } + final ByteBuffer skipByteBuffer = ByteBuffer.allocate((int) Math.min(toSkip, SKIP_BUFFER_SIZE)); + long remain = toSkip; + while (remain > 0) { + skipByteBuffer.position(0); + skipByteBuffer.limit((int) Math.min(remain, SKIP_BUFFER_SIZE)); + final int n = input.read(skipByteBuffer); + if (n == EOF) { + break; + } + remain -= n; + } + return toSkip - remain; + } + + /** + * Skips characters from an input character stream. + * This implementation guarantees that it will read as many characters + * as possible before giving up; this may not always be the case for + * skip() implementations in subclasses of {@link Reader}. + *

+ * Note that the implementation uses {@link Reader#read(char[], int, int)} rather + * than delegating to {@link Reader#skip(long)}. + * This means that the method may be considerably less efficient than using the actual skip implementation, + * this is done to guarantee that the correct number of characters are skipped. + *

+ * + * @param input character stream to skip + * @param toSkip number of characters to skip. + * @return number of characters actually skipped. + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative + * @see Reader#skip(long) + * @see IO-203 - Add skipFully() method for InputStreams + * @since 2.0 + */ + public static long skip(final Reader input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Skip count must be non-negative, actual: " + toSkip); + } + /* + * N.B. no need to synchronize this because: - we don't care if the buffer is created multiple times (the data + * is ignored) - we always use the same size buffer, so if it it is recreated it will still be OK (if the buffer + * size were variable, we would need to synch. to ensure some other thread did not create a smaller one) + */ + if (SKIP_CHAR_BUFFER == null) { + SKIP_CHAR_BUFFER = new char[SKIP_BUFFER_SIZE]; + } + long remain = toSkip; + while (remain > 0) { + // See https://issues.apache.org/jira/browse/IO-203 for why we use read() rather than delegating to skip() + final long n = input.read(SKIP_CHAR_BUFFER, 0, (int) Math.min(remain, SKIP_BUFFER_SIZE)); + if (n < 0) { // EOF + break; + } + remain -= n; + } + return toSkip - remain; + } + + /** + * Skips the requested number of bytes or fail if there are not enough left. + *

+ * This allows for the possibility that {@link InputStream#skip(long)} may + * not skip as many bytes as requested (most likely because of reaching EOF). + *

+ * Note that the implementation uses {@link #skip(InputStream, long)}. + * This means that the method may be considerably less efficient than using the actual skip implementation, + * this is done to guarantee that the correct number of characters are skipped. + *

+ * + * @param input stream to skip + * @param toSkip the number of bytes to skip + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative + * @throws EOFException if the number of bytes skipped was incorrect + * @see InputStream#skip(long) + * @since 2.0 + */ + public static void skipFully(final InputStream input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Bytes to skip must not be negative: " + toSkip); + } + final long skipped = skip(input, toSkip); + if (skipped != toSkip) { + throw new EOFException("Bytes to skip: " + toSkip + " actual: " + skipped); + } + } + + /** + * Skips the requested number of bytes or fail if there are not enough left. + * + * @param input ReadableByteChannel to skip + * @param toSkip the number of bytes to skip + * @throws IOException if there is a problem reading the ReadableByteChannel + * @throws IllegalArgumentException if toSkip is negative + * @throws EOFException if the number of bytes skipped was incorrect + * @since 2.5 + */ + public static void skipFully(final ReadableByteChannel input, final long toSkip) throws IOException { + if (toSkip < 0) { + throw new IllegalArgumentException("Bytes to skip must not be negative: " + toSkip); + } + final long skipped = skip(input, toSkip); + if (skipped != toSkip) { + throw new EOFException("Bytes to skip: " + toSkip + " actual: " + skipped); + } + } + + /** + * Skips the requested number of characters or fail if there are not enough left. + *

+ * This allows for the possibility that {@link Reader#skip(long)} may + * not skip as many characters as requested (most likely because of reaching EOF). + *

+ * Note that the implementation uses {@link #skip(Reader, long)}. + * This means that the method may be considerably less efficient than using the actual skip implementation, + * this is done to guarantee that the correct number of characters are skipped. + *

+ * + * @param input stream to skip + * @param toSkip the number of characters to skip + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if toSkip is negative + * @throws EOFException if the number of characters skipped was incorrect + * @see Reader#skip(long) + * @since 2.0 + */ + public static void skipFully(final Reader input, final long toSkip) throws IOException { + final long skipped = skip(input, toSkip); + if (skipped != toSkip) { + throw new EOFException("Chars to skip: " + toSkip + " actual: " + skipped); + } + } + + + /** + * Reads characters from an input character stream. + * This implementation guarantees that it will read as many characters + * as possible before giving up; this may not always be the case for + * subclasses of {@link Reader}. + * + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(final Reader input, final char[] buffer, final int offset, final int length) + throws IOException { + if (length < 0) { + throw new IllegalArgumentException("Length must not be negative: " + length); + } + int remaining = length; + while (remaining > 0) { + final int location = length - remaining; + final int count = input.read(buffer, offset + location, remaining); + if (EOF == count) { // EOF + break; + } + remaining -= count; + } + return length - remaining; + } + + /** + * Reads characters from an input character stream. + * This implementation guarantees that it will read as many characters + * as possible before giving up; this may not always be the case for + * subclasses of {@link Reader}. + * + * @param input where to read input from + * @param buffer destination + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(final Reader input, final char[] buffer) throws IOException { + return read(input, buffer, 0, buffer.length); + } + + /** + * Reads bytes from an input stream. + * This implementation guarantees that it will read as many bytes + * as possible before giving up; this may not always be the case for + * subclasses of {@link InputStream}. + * + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(final InputStream input, final byte[] buffer, final int offset, final int length) + throws IOException { + if (length < 0) { + throw new IllegalArgumentException("Length must not be negative: " + length); + } + int remaining = length; + while (remaining > 0) { + final int location = length - remaining; + final int count = input.read(buffer, offset + location, remaining); + if (EOF == count) { // EOF + break; + } + remaining -= count; + } + return length - remaining; + } + + /** + * Reads bytes from an input stream. + * This implementation guarantees that it will read as many bytes + * as possible before giving up; this may not always be the case for + * subclasses of {@link InputStream}. + * + * @param input where to read input from + * @param buffer destination + * @return actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.2 + */ + public static int read(final InputStream input, final byte[] buffer) throws IOException { + return read(input, buffer, 0, buffer.length); + } + + /** + * Reads bytes from a ReadableByteChannel. + *

+ * This implementation guarantees that it will read as many bytes + * as possible before giving up; this may not always be the case for + * subclasses of {@link ReadableByteChannel}. + * + * @param input the byte channel to read + * @param buffer byte buffer destination + * @return the actual length read; may be less than requested if EOF was reached + * @throws IOException if a read error occurs + * @since 2.5 + */ + public static int read(final ReadableByteChannel input, final ByteBuffer buffer) throws IOException { + final int length = buffer.remaining(); + while (buffer.remaining() > 0) { + final int count = input.read(buffer); + if (EOF == count) { // EOF + break; + } + } + return length - buffer.remaining(); + } + + /** + * Reads the requested number of characters or fail if there are not enough left. + *

+ * This allows for the possibility that {@link Reader#read(char[], int, int)} may + * not read as many characters as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of characters read was incorrect + * @since 2.2 + */ + public static void readFully(final Reader input, final char[] buffer, final int offset, final int length) + throws IOException { + final int actual = read(input, buffer, offset, length); + if (actual != length) { + throw new EOFException("Length to read: " + length + " actual: " + actual); + } + } + + /** + * Reads the requested number of characters or fail if there are not enough left. + *

+ * This allows for the possibility that {@link Reader#read(char[], int, int)} may + * not read as many characters as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of characters read was incorrect + * @since 2.2 + */ + public static void readFully(final Reader input, final char[] buffer) throws IOException { + readFully(input, buffer, 0, buffer.length); + } + + /** + * Reads the requested number of bytes or fail if there are not enough left. + *

+ * This allows for the possibility that {@link InputStream#read(byte[], int, int)} may + * not read as many bytes as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * @param offset initial offset into buffer + * @param length length to read, must be >= 0 + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect + * @since 2.2 + */ + public static void readFully(final InputStream input, final byte[] buffer, final int offset, final int length) + throws IOException { + final int actual = read(input, buffer, offset, length); + if (actual != length) { + throw new EOFException("Length to read: " + length + " actual: " + actual); + } + } + + /** + * Reads the requested number of bytes or fail if there are not enough left. + *

+ * This allows for the possibility that {@link InputStream#read(byte[], int, int)} may + * not read as many bytes as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param buffer destination + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect + * @since 2.2 + */ + public static void readFully(final InputStream input, final byte[] buffer) throws IOException { + readFully(input, buffer, 0, buffer.length); + } + + /** + * Reads the requested number of bytes or fail if there are not enough left. + *

+ * This allows for the possibility that {@link InputStream#read(byte[], int, int)} may + * not read as many bytes as requested (most likely because of reaching EOF). + * + * @param input where to read input from + * @param length length to read, must be >= 0 + * @return the bytes read from input + * @throws IOException if there is a problem reading the file + * @throws IllegalArgumentException if length is negative + * @throws EOFException if the number of bytes read was incorrect + * @since 2.5 + */ + public static byte[] readFully(final InputStream input, final int length) throws IOException { + final byte[] buffer = new byte[length]; + readFully(input, buffer, 0, buffer.length); + return buffer; + } + + /** + * Reads the requested number of bytes or fail if there are not enough left. + *

+ * This allows for the possibility that {@link ReadableByteChannel#read(ByteBuffer)} may + * not read as many bytes as requested (most likely because of reaching EOF). + * + * @param input the byte channel to read + * @param buffer byte buffer destination + * @throws IOException if there is a problem reading the file + * @throws EOFException if the number of bytes read was incorrect + * @since 2.5 + */ + public static void readFully(final ReadableByteChannel input, final ByteBuffer buffer) throws IOException { + final int expected = buffer.remaining(); + final int actual = read(input, buffer); + if (actual != expected) { + throw new EOFException("Length to read: " + expected + " actual: " + actual); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/Java7Support.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/Java7Support.java" new file mode 100644 index 0000000000000000000000000000000000000000..d9033a457644c4de4bb71936fff229f30084b329 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/Java7Support.java" @@ -0,0 +1,190 @@ +package 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. + *

+ * 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; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/LineIterator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/LineIterator.java" new file mode 100644 index 0000000000000000000000000000000000000000..8d56f583bd90e0af6f3d1a8a0e50d9c5f7ad4372 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/LineIterator.java" @@ -0,0 +1,180 @@ +/* + * 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 Reader. + *

+ * LineIterator holds a reference to an open Reader. + * 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. + *

+ * The recommended usage pattern is: + *

+ * LineIterator it = FileUtils.lineIterator(file, "UTF-8");
+ * try {
+ *   while (it.hasNext()) {
+ *     String line = it.nextLine();
+ *     // do something with line
+ *   }
+ * } finally {
+ *   it.close();
+ * }
+ * 
+ * + * @version $Id: LineIterator.java 1471767 2013-04-24 23:24:19Z sebb $ + * @since 1.2 + */ +public class LineIterator implements Iterator { + + // 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 Reader. + * + * @param reader the Reader 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 Reader has more lines. + * If there is an IOException 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 Reader. + * + * @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 Reader. + * + * @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 Reader 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 Reader 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(); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/TaggedIOException.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/TaggedIOException.java" new file mode 100644 index 0000000000000000000000000000000000000000..228384797ca823fd6e5ac58e19de9e30b3c5f3db --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/TaggedIOException.java" @@ -0,0 +1,136 @@ +/* + * 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. + *

+ * 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. + *

+ * A typical use for this method is in a catch block to + * determine how a caught exception should be handled: + *

+     * Serializable tag = ...;
+     * try {
+     *     ...;
+     * } catch (Throwable t) {
+     *     if (TaggedIOExcepton.isTaggedWith(t, tag)) {
+     *         // special processing for tagged exception
+     *     } else {
+     *         // handling of other kinds of exceptions
+     *     }
+     * }
+     * 
+ * + * @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. + *

+ * This method is typically used in a catch block to + * selectively rethrow tagged exceptions. + *

+     * Serializable tag = ...;
+     * try {
+     *     ...;
+     * } catch (Throwable t) {
+     *     TaggedIOExcepton.throwCauseIfTagged(t, tag);
+     *     // handle other kinds of exceptions
+     * }
+     * 
+ * + * @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(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/ThreadMonitor.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/ThreadMonitor.java" new file mode 100644 index 0000000000000000000000000000000000000000..e97ae3c62c1aaf92943633b8fcd922bbe6a502f0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/ThreadMonitor.java" @@ -0,0 +1,134 @@ +/* + * 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. + *

+ * 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 interrupt() + * the monitor thread. + *

+ * + *
+ *       long timeoutInMillis = 1000;
+ *       try {
+ *           Thread monitor = ThreadMonitor.start(timeoutInMillis);
+ *           // do some work here
+ *           ThreadMonitor.stop(monitor);
+ *       } catch (InterruptedException e) {
+ *           // timed amount was reached
+ *       }
+ * 
+ * + * @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); + } + + +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/AbstractFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/AbstractFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..92822fbe37f1b668d744a819de3608367f47b626 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/AbstractFileComparator.java" @@ -0,0 +1,76 @@ +/* + * 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 { + + /** + * Sort an array of files. + *

+ * 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. + *

+ * 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 sort(final List 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(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/CompositeFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/CompositeFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..04aa5ba614c0e6750e173f14edd0587883c85c35 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/CompositeFileComparator.java" @@ -0,0 +1,122 @@ +/* + * 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}. + *

+ * This comparator can be used to sort lists or arrays of files + * by combining a number other comparators. + *

+ * Example of sorting a list of files by type (i.e. directory or file) + * and then by name: + *

+ *       CompositeFileComparator comparator =
+ *                       new CompositeFileComparator(
+ *                                 (AbstractFileComparator) DirectoryFileComparator.DIRECTORY_COMPARATOR,
+ *                                 (AbstractFileComparator) NameFileComparator.NAME_COMPARATOR);
+ *       List<File> list = ...
+ *       comparator.sort(list);
+ * 
+ * + * @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[] 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... delegates) { + if (delegates == null) { + this.delegates = (Comparator[]) NO_COMPARATORS;//1 + } else { + this.delegates = (Comparator[]) 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> delegates) { + if (delegates == null) { + this.delegates = (Comparator[]) NO_COMPARATORS; //1 + } else { + final List> list = new ArrayList>(); + for (final Comparator comparator : delegates) { + list.add(comparator); + } + this.delegates = (Comparator[]) 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 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(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DefaultFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DefaultFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..d19e3830d69e9c14fedff94022414c5e952ab9d6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DefaultFileComparator.java" @@ -0,0 +1,68 @@ +/* + * 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 default {@link File#compareTo(File)} method. + *

+ * This comparator can be used to sort lists or arrays of files + * by using the default file comparison. + *

+ * Example of sorting a list of files using the + * {@link #DEFAULT_COMPARATOR} singleton instance: + *

+ *       List<File> list = ...
+ *       ((AbstractFileComparator) DefaultFileComparator.DEFAULT_COMPARATOR).sort(list);
+ * 
+ *

+ * Example of doing a reverse sort of an array of files using the + * {@link #DEFAULT_REVERSE} singleton instance: + *

+ *       File[] array = ...
+ *       ((AbstractFileComparator) DefaultFileComparator.DEFAULT_REVERSE).sort(array);
+ * 
+ *

+ * + * @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 DEFAULT_COMPARATOR = new DefaultFileComparator(); + + /** Singleton reverse default comparator instance */ + public static final Comparator 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); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DirectoryFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DirectoryFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..cb789394b11a324d448fb2d9552f3273c9350f09 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/DirectoryFileComparator.java" @@ -0,0 +1,81 @@ +/* + * 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. + *

+ * This comparator can be used to sort lists or arrays by directories and files. + *

+ * Example of sorting a list of files/directories using the + * {@link #DIRECTORY_COMPARATOR} singleton instance: + *

+ *       List<File> list = ...
+ *       ((AbstractFileComparator) DirectoryFileComparator.DIRECTORY_COMPARATOR).sort(list);
+ * 
+ *

+ * Example of doing a reverse sort of an array of files/directories using the + * {@link #DIRECTORY_REVERSE} singleton instance: + *

+ *       File[] array = ...
+ *       ((AbstractFileComparator) DirectoryFileComparator.DIRECTORY_REVERSE).sort(array);
+ * 
+ *

+ * + * @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 DIRECTORY_COMPARATOR = new DirectoryFileComparator(); + + /** Singleton reverse default comparator instance */ + public static final Comparator 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; + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ExtensionFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ExtensionFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..03a104ebb9223dcef7dee16ec7aa16a43f713bbb --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ExtensionFileComparator.java" @@ -0,0 +1,123 @@ +/* + * 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 extensions for order + * (see {@link FilenameUtils#getExtension(String)}). + *

+ * 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. + *

+ * Example of a case-sensitive file extension sort using the + * {@link #EXTENSION_COMPARATOR} singleton instance: + *

+ *       List<File> list = ...
+ *       ((AbstractFileComparator) ExtensionFileComparator.EXTENSION_COMPARATOR).sort(list);
+ * 
+ *

+ * Example of a reverse case-insensitive file extension sort using the + * {@link #EXTENSION_INSENSITIVE_REVERSE} singleton instance: + *

+ *       File[] array = ...
+ *       ((AbstractFileComparator) ExtensionFileComparator.EXTENSION_INSENSITIVE_REVERSE).sort(array);
+ * 
+ *

+ * + * @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 EXTENSION_COMPARATOR = new ExtensionFileComparator(); + + /** Reverse case-sensitive extension comparator instance (see {@link IOCase#SENSITIVE}) */ + public static final Comparator EXTENSION_REVERSE = new ReverseComparator(EXTENSION_COMPARATOR); + + /** Case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */ + public static final Comparator EXTENSION_INSENSITIVE_COMPARATOR + = new ExtensionFileComparator(IOCase.INSENSITIVE); + + /** Reverse case-insensitive extension comparator instance (see {@link IOCase#INSENSITIVE}) */ + public static final Comparator EXTENSION_INSENSITIVE_REVERSE + = new ReverseComparator(EXTENSION_INSENSITIVE_COMPARATOR); + + /** System sensitive extension comparator instance (see {@link IOCase#SYSTEM}) */ + public static final Comparator EXTENSION_SYSTEM_COMPARATOR = new ExtensionFileComparator(IOCase.SYSTEM); + + /** Reverse system sensitive path comparator instance (see {@link IOCase#SYSTEM}) */ + public static final Comparator 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 + "]"; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/LastModifiedFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/LastModifiedFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..8596d899d546f743823c3b9373083a9465124a4a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/LastModifiedFileComparator.java" @@ -0,0 +1,79 @@ +/* + * 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 last modified date/time of two files for order + * (see {@link File#lastModified()}). + *

+ * This comparator can be used to sort lists or arrays of files + * by their last modified date/time. + *

+ * Example of sorting a list of files using the + * {@link #LASTMODIFIED_COMPARATOR} singleton instance: + *

+ *       List<File> list = ...
+ *       ((AbstractFileComparator) LastModifiedFileComparator.LASTMODIFIED_COMPARATOR).sort(list);
+ * 
+ *

+ * Example of doing a reverse sort of an array of files using the + * {@link #LASTMODIFIED_REVERSE} singleton instance: + *

+ *       File[] array = ...
+ *       ((AbstractFileComparator) LastModifiedFileComparator.LASTMODIFIED_REVERSE).sort(array);
+ * 
+ *

+ * + * @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 LASTMODIFIED_COMPARATOR = new LastModifiedFileComparator(); + + /** Reverse last modified comparator instance */ + public static final Comparator 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; + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/NameFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/NameFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..58a31a7df89d4ccfbd158aa2afc10c5055c5301d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/NameFileComparator.java" @@ -0,0 +1,116 @@ +/* + * 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 names of two files for order (see {@link File#getName()}). + *

+ * 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. + *

+ * Example of a case-sensitive file name sort using the + * {@link #NAME_COMPARATOR} singleton instance: + *

+ *       List<File> list = ...
+ *       ((AbstractFileComparator) NameFileComparator.NAME_COMPARATOR).sort(list);
+ * 
+ *

+ * Example of a reverse case-insensitive file name sort using the + * {@link #NAME_INSENSITIVE_REVERSE} singleton instance: + *

+ *       File[] array = ...
+ *       ((AbstractFileComparator) NameFileComparator.NAME_INSENSITIVE_REVERSE).sort(array);
+ * 
+ *

+ * + * @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 NAME_COMPARATOR = new NameFileComparator(); + + /** Reverse case-sensitive name comparator instance (see {@link IOCase#SENSITIVE}) */ + public static final Comparator NAME_REVERSE = new ReverseComparator(NAME_COMPARATOR); + + /** Case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */ + public static final Comparator NAME_INSENSITIVE_COMPARATOR = new NameFileComparator(IOCase.INSENSITIVE); + + /** Reverse case-insensitive name comparator instance (see {@link IOCase#INSENSITIVE}) */ + public static final Comparator NAME_INSENSITIVE_REVERSE = new ReverseComparator(NAME_INSENSITIVE_COMPARATOR); + + /** System sensitive name comparator instance (see {@link IOCase#SYSTEM}) */ + public static final Comparator NAME_SYSTEM_COMPARATOR = new NameFileComparator(IOCase.SYSTEM); + + /** Reverse system sensitive name comparator instance (see {@link IOCase#SYSTEM}) */ + public static final Comparator 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 + "]"; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/PathFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/PathFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..57b453440289ba52fee344b27f4a236bad4ad228 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/PathFileComparator.java" @@ -0,0 +1,117 @@ +/* + * 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 path of two files for order (see {@link File#getPath()}). + *

+ * 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. + *

+ * Example of a case-sensitive file path sort using the + * {@link #PATH_COMPARATOR} singleton instance: + *

+ *       List<File> list = ...
+ *       ((AbstractFileComparator) PathFileComparator.PATH_COMPARATOR).sort(list);
+ * 
+ *

+ * Example of a reverse case-insensitive file path sort using the + * {@link #PATH_INSENSITIVE_REVERSE} singleton instance: + *

+ *       File[] array = ...
+ *       ((AbstractFileComparator) PathFileComparator.PATH_INSENSITIVE_REVERSE).sort(array);
+ * 
+ *

+ * + * @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 PATH_COMPARATOR = new PathFileComparator(); + + /** Reverse case-sensitive path comparator instance (see {@link IOCase#SENSITIVE}) */ + public static final Comparator PATH_REVERSE = new ReverseComparator(PATH_COMPARATOR); + + /** Case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */ + public static final Comparator PATH_INSENSITIVE_COMPARATOR = new PathFileComparator(IOCase.INSENSITIVE); + + /** Reverse case-insensitive path comparator instance (see {@link IOCase#INSENSITIVE}) */ + public static final Comparator PATH_INSENSITIVE_REVERSE = new ReverseComparator(PATH_INSENSITIVE_COMPARATOR); + + /** System sensitive path comparator instance (see {@link IOCase#SYSTEM}) */ + public static final Comparator PATH_SYSTEM_COMPARATOR = new PathFileComparator(IOCase.SYSTEM); + + /** Reverse system sensitive path comparator instance (see {@link IOCase#SYSTEM}) */ + public static final Comparator 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 + "]"; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ReverseComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ReverseComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..bf0f63e69c7c3e6efab688d9429303b94c844658 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/ReverseComparator.java" @@ -0,0 +1,69 @@ +/* + * 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 delegate; + + /** + * Construct an instance with the sepecified delegate {@link Comparator}. + * + * @param delegate The comparator to delegate to + */ + public ReverseComparator(final Comparator 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() + "]"; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/SizeFileComparator.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/SizeFileComparator.java" new file mode 100644 index 0000000000000000000000000000000000000000..7351f9267cb30f38ca880014dbda64aededc5164 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/SizeFileComparator.java" @@ -0,0 +1,142 @@ +/* + * 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 length/size of two files for order (see + * {@link File#length()} and {@link FileUtils#sizeOfDirectory(File)}). + *

+ * This comparator can be used to sort lists or arrays of files + * by their length/size. + *

+ * Example of sorting a list of files using the + * {@link #SIZE_COMPARATOR} singleton instance: + *

+ *       List<File> list = ...
+ *       ((AbstractFileComparator) SizeFileComparator.SIZE_COMPARATOR).sort(list);
+ * 
+ *

+ * Example of doing a reverse sort of an array of files using the + * {@link #SIZE_REVERSE} singleton instance: + *

+ *       File[] array = ...
+ *       ((AbstractFileComparator) SizeFileComparator.SIZE_REVERSE).sort(array);
+ * 
+ *

+ * N.B. Directories are treated as zero size unless + * sumDirectoryContents 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 SIZE_COMPARATOR = new SizeFileComparator(); + + /** Reverse size comparator instance - directories are treated as zero size */ + public static final Comparator 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 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 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. + *

+ * If the sumDirectoryContents 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 + "]"; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/package.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/package.html" new file mode 100644 index 0000000000000000000000000000000000000000..d0071583e2b57feb43201a2a85faf42057ca0125 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/comparator/package.html" @@ -0,0 +1,188 @@ + + + + +

This package provides various {@link java.util.Comparator} implementations +for {@link java.io.File}s. +

+

Sorting

+

+ All the compartors include convenience utility sort(File...) and + sort(List) methods. +

+

+ For example, to sort the files in a directory by name: +

+
+        File[] files = dir.listFiles();
+        NameFileComparator.NAME_COMPARATOR.sort(files);
+  
+

+ ...alternatively you can do this in one line: +

+

+

+        File[] files = NameFileComparator.NAME_COMPARATOR.sort(dir.listFiles());
+  
+

+ +

Composite Comparator

+

+ The CompositeFileComparator can be used + to compare (and sort lists or arrays of files) by combining a number other comparators. +

+

+ For example, to sort an array of files by type (i.e. directory or file) + and then by name: +

+

+

+        CompositeFileComparator comparator =
+                        new CompositeFileComparator(
+                                    DirectoryFileComparator.DIRECTORY_COMPARATOR,
+                                    NameFileComparator.NAME_COMPARATOR);
+        File[] files = dir.listFiles();
+        comparator.sort(files);
+  
+

+ +

Singleton Instances (thread-safe)

+

+ The {@link java.util.Comparator} implementations have some convenience + singleton(thread-safe) instances ready to use: +

+

+ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AbstractFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AbstractFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..2e4d5974f6454994cf24c77dac5a495763ba20d1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AbstractFileFilter.java" @@ -0,0 +1,64 @@ +/* + * 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. + *

+ * Note that a subclass must 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(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AgeFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AgeFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..bc8081e0e642be9deb880f6e5bf6c9623a817100 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AgeFileFilter.java" @@ -0,0 +1,159 @@ +/* + * 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. + *

+ * For example, to print all files and directories in the + * current directory older than one day: + * + *

+ * 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]);
+ * }
+ * 
+ * + * @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. + *

+ * If last modification time equals cutoff and newer files are required, + * file IS NOT selected. + * If last modification time equals cutoff and older files are required, + * file IS 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 + ")"; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AndFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AndFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..2352aeb3a6492c980ba21e32f9b698cbe2fa94f3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/AndFileFilter.java" @@ -0,0 +1,170 @@ +/* + * 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 fileFilters; + + /** + * Constructs a new instance of AndFileFilter. + * + * @since 1.1 + */ + public AndFileFilter() { + this.fileFilters = new ArrayList(); + } + + /** + * Constructs a new instance of AndFileFilter + * with the specified list of filters. + * + * @param fileFilters a List of IOFileFilter instances, copied, null ignored + * @since 1.1 + */ + public AndFileFilter(final List fileFilters) { + if (fileFilters == null) { + this.fileFilters = new ArrayList(); + } else { + this.fileFilters = new ArrayList(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(2); + addFileFilter(filter1); + addFileFilter(filter2); + } + + /** + * {@inheritDoc} + */ + public void addFileFilter(final IOFileFilter ioFileFilter) { + this.fileFilters.add(ioFileFilter); + } + + /** + * {@inheritDoc} + */ + public List getFileFilters() { + return Collections.unmodifiableList(this.fileFilters); + } + + /** + * {@inheritDoc} + */ + public boolean removeFileFilter(final IOFileFilter ioFileFilter) { + return this.fileFilters.remove(ioFileFilter); + } + + /** + * {@inheritDoc} + */ + public void setFileFilters(final List 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(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/CanReadFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/CanReadFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..2c06133604eef03b5099a3c3b299c346f8f67529 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/CanReadFileFilter.java" @@ -0,0 +1,95 @@ +/* + * 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; + +/** + * This filter accepts Files that can be read. + *

+ * Example, showing how to print out a list of the + * current directory's readable files: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( CanReadFileFilter.CAN_READ );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + *

+ * Example, showing how to print out a list of the + * current directory's un-readable files: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( CanReadFileFilter.CANNOT_READ );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + *

+ * Example, showing how to print out a list of the + * current directory's read-only files: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( CanReadFileFilter.READ_ONLY );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.3 + * @version $Id: CanReadFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + */ +public class CanReadFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 3179904805251622989L; + + /** Singleton instance of readable filter */ + public static final IOFileFilter CAN_READ = new CanReadFileFilter(); + + /** Singleton instance of not readable filter */ + public static final IOFileFilter CANNOT_READ = new NotFileFilter(CAN_READ); + + /** Singleton instance of read-only filter */ + public static final IOFileFilter READ_ONLY = new AndFileFilter(CAN_READ, + CanWriteFileFilter.CANNOT_WRITE); + + /** + * Restrictive consructor. + */ + protected CanReadFileFilter() { + } + + /** + * Checks to see if the file can be read. + * + * @param file the File to check. + * @return {@code true} if the file can be + * read, otherwise {@code false}. + */ + @Override + public boolean accept(final File file) { + return file.canRead(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/CanWriteFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/CanWriteFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..eebee7d1e2004ce6a204ac15affdee4f3e3b089d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/CanWriteFileFilter.java" @@ -0,0 +1,83 @@ +/* + * 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; + +/** + * This filter accepts Files that can be written to. + *

+ * Example, showing how to print out a list of the + * current directory's writable files: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( CanWriteFileFilter.CAN_WRITE );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + *

+ * Example, showing how to print out a list of the + * current directory's un-writable files: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( CanWriteFileFilter.CANNOT_WRITE );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + *

+ * N.B. For read-only files, use + * CanReadFileFilter.READ_ONLY. + * + * @since 1.3 + * @version $Id: CanWriteFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + */ +public class CanWriteFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 5132005214688990379L; + + /** Singleton instance of writable filter */ + public static final IOFileFilter CAN_WRITE = new CanWriteFileFilter(); + + /** Singleton instance of not writable filter */ + public static final IOFileFilter CANNOT_WRITE = new NotFileFilter(CAN_WRITE); + + /** + * Restrictive consructor. + */ + protected CanWriteFileFilter() { + } + + /** + * Checks to see if the file can be written to. + * + * @param file the File to check + * @return {@code true} if the file can be + * written to, otherwise {@code false}. + */ + @Override + public boolean accept(final File file) { + return file.canWrite(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/ConditionalFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/ConditionalFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..b577b99452d30ff933d3ca096af4e0d4e6b67b11 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/ConditionalFileFilter.java" @@ -0,0 +1,65 @@ +/* + * 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.util.List; + +/** + * Defines operations for conditional file filters. + * + * @since 1.1 + * @version $Id: ConditionalFileFilter.java 1307462 2012-03-30 15:13:11Z ggregory $ + */ +public interface ConditionalFileFilter { + + /** + * Adds the specified file filter to the list of file filters at the end of + * the list. + * + * @param ioFileFilter the filter to be added + * @since 1.1 + */ + void addFileFilter(IOFileFilter ioFileFilter); + + /** + * Returns this conditional file filter's list of file filters. + * + * @return the file filter list + * @since 1.1 + */ + List getFileFilters(); + + /** + * Removes the specified file filter. + * + * @param ioFileFilter filter to be removed + * @return {@code true} if the filter was found in the list, + * {@code false} otherwise + * @since 1.1 + */ + boolean removeFileFilter(IOFileFilter ioFileFilter); + + /** + * Sets the list of file filters, replacing any previously configured + * file filters on this filter. + * + * @param fileFilters the list of filters + * @since 1.1 + */ + void setFileFilters(List fileFilters); + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/DelegateFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/DelegateFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..789b00fecd60a382339be6647fffb3334d1473e3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/DelegateFileFilter.java" @@ -0,0 +1,109 @@ +/* + * 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.FileFilter; +import java.io.FilenameFilter; +import java.io.Serializable; + +/** + * This class turns a Java FileFilter or FilenameFilter into an IO FileFilter. + * + * @since 1.0 + * @version $Id: DelegateFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * + * @see FileFilterUtils#asFileFilter(FileFilter) + * @see FileFilterUtils#asFileFilter(FilenameFilter) + */ +public class DelegateFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = -8723373124984771318L; + /** The Filename filter */ + private final FilenameFilter filenameFilter; + /** The File filter */ + private final FileFilter fileFilter; + + /** + * Constructs a delegate file filter around an existing FilenameFilter. + * + * @param filter the filter to decorate + */ + public DelegateFileFilter(final FilenameFilter filter) { + if (filter == null) { + throw new IllegalArgumentException("The FilenameFilter must not be null"); + } + this.filenameFilter = filter; + this.fileFilter = null; + } + + /** + * Constructs a delegate file filter around an existing FileFilter. + * + * @param filter the filter to decorate + */ + public DelegateFileFilter(final FileFilter filter) { + if (filter == null) { + throw new IllegalArgumentException("The FileFilter must not be null"); + } + this.fileFilter = filter; + this.filenameFilter = null; + } + + /** + * Checks the filter. + * + * @param file the file to check + * @return true if the filter matches + */ + @Override + public boolean accept(final File file) { + if (fileFilter != null) { + return fileFilter.accept(file); + } else { + return super.accept(file); + } + } + + /** + * Checks the filter. + * + * @param dir the directory + * @param name the filename in the directory + * @return true if the filter matches + */ + @Override + public boolean accept(final File dir, final String name) { + if (filenameFilter != null) { + return filenameFilter.accept(dir, name); + } else { + return super.accept(dir, name); + } + } + + /** + * Provide a String representaion of this file filter. + * + * @return a String representaion + */ + @Override + public String toString() { + final String delegate = fileFilter != null ? fileFilter.toString() : filenameFilter.toString(); + return super.toString() + "(" + delegate + ")"; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..1c7f1c088122204f867b430387c1b7df30203186 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java" @@ -0,0 +1,74 @@ +/* + * 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; + +/** + * This filter accepts Files that are directories. + *

+ * For example, here is how to print out a list of the + * current directory's subdirectories: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( DirectoryFileFilter.INSTANCE );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.0 + * @version $Id: DirectoryFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * + * @see FileFilterUtils#directoryFileFilter() + */ +public class DirectoryFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = -5148237843784525732L; + /** + * Singleton instance of directory filter. + * @since 1.3 + */ + public static final IOFileFilter DIRECTORY = new DirectoryFileFilter(); + /** + * Singleton instance of directory filter. + * Please use the identical DirectoryFileFilter.DIRECTORY constant. + * The new name is more JDK 1.5 friendly as it doesn't clash with other + * values when using static imports. + */ + public static final IOFileFilter INSTANCE = DIRECTORY; + + /** + * Restrictive consructor. + */ + protected DirectoryFileFilter() { + } + + /** + * Checks to see if the file is a directory. + * + * @param file the File to check + * @return true if the file is a directory + */ + @Override + public boolean accept(final File file) { + return file.isDirectory(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..241aa60e7bd837952174cdfcf3a79d9eeb6ff3d1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/EmptyFileFilter.java" @@ -0,0 +1,87 @@ +/* + * 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; + +/** + * This filter accepts files or directories that are empty. + *

+ * If the File is a directory it checks that + * it contains no files. + *

+ * Example, showing how to print out a list of the + * current directory's empty files/directories: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( EmptyFileFilter.EMPTY );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + *

+ * Example, showing how to print out a list of the + * current directory's non-empty files/directories: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( EmptyFileFilter.NOT_EMPTY );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.3 + * @version $Id: EmptyFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + */ +public class EmptyFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 3631422087512832211L; + + /** Singleton instance of empty filter */ + public static final IOFileFilter EMPTY = new EmptyFileFilter(); + + /** Singleton instance of not-empty filter */ + public static final IOFileFilter NOT_EMPTY = new NotFileFilter(EMPTY); + + /** + * Restrictive consructor. + */ + protected EmptyFileFilter() { + } + + /** + * Checks to see if the file is empty. + * + * @param file the file or directory to check + * @return {@code true} if the file or directory + * is empty, otherwise {@code false}. + */ + @Override + public boolean accept(final File file) { + if (file.isDirectory()) { + final File[] files = file.listFiles(); + return files == null || files.length == 0; + } else { + return file.length() == 0; + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FalseFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FalseFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..6378c5566b2a11b36d1455ce09dbd568b3a16bd2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FalseFileFilter.java" @@ -0,0 +1,73 @@ +/* + * 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; + +/** + * A file filter that always returns false. + * + * @since 1.0 + * @version $Id: FalseFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * + * @see FileFilterUtils#falseFileFilter() + */ +public class FalseFileFilter implements IOFileFilter, Serializable { + + private static final long serialVersionUID = 6210271677940926200L; + /** + * Singleton instance of false filter. + * @since 1.3 + */ + public static final IOFileFilter FALSE = new FalseFileFilter(); + /** + * Singleton instance of false filter. + * Please use the identical FalseFileFilter.FALSE constant. + * The new name is more JDK 1.5 friendly as it doesn't clash with other + * values when using static imports. + */ + public static final IOFileFilter INSTANCE = FALSE; + + /** + * Restrictive consructor. + */ + protected FalseFileFilter() { + } + + /** + * Returns false. + * + * @param file the file to check (ignored) + * @return false + */ + public boolean accept(final File file) { + return false; + } + + /** + * Returns false. + * + * @param dir the directory to check (ignored) + * @param name the filename (ignored) + * @return false + */ + public boolean accept(final File dir, final String name) { + return false; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FileFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FileFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..e858974b3849da9d691deb367456369d6f080405 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FileFileFilter.java" @@ -0,0 +1,63 @@ +/* + * 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; + +/** + * This filter accepts Files that are files (not directories). + *

+ * For example, here is how to print out a list of the real files + * within the current directory: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( FileFileFilter.FILE );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.3 + * @version $Id: FileFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @see FileFilterUtils#fileFileFilter() + */ +public class FileFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 5345244090827540862L; + /** Singleton instance of file filter */ + public static final IOFileFilter FILE = new FileFileFilter(); + + /** + * Restrictive consructor. + */ + protected FileFileFilter() { + } + + /** + * Checks to see if the file is a file. + * + * @param file the File to check + * @return true if the file is a file + */ + @Override + public boolean accept(final File file) { + return file.isFile(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..7bdbe3c32c372b66ba003d27a704c088ecd3d987 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/FileFilterUtils.java" @@ -0,0 +1,796 @@ +/* + * 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.FileFilter; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.commons.io.IOCase; + +/** + * Useful utilities for working with file filters. It provides access to all + * file filter implementations in this package so you don't have to import + * every class you use. + * + * @since 1.0 + * @version $Id: FileFilterUtils.java 1471767 2013-04-24 23:24:19Z sebb $ + */ +public class FileFilterUtils { + + /** + * FileFilterUtils is not normally instantiated. + */ + public FileFilterUtils() { + } + + //----------------------------------------------------------------------- + + /** + *

+ * Applies an {@link IOFileFilter} to the provided {@link File} + * objects. The resulting array is a subset of the original file list that + * matches the provided filter. + *

+ * + *

+ * The {@link Set} returned by this method is not guaranteed to be thread safe. + *

+ * + *
+     * Set<File> allFiles = ...
+     * Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
+     *     FileFilterUtils.suffixFileFilter(".java"));
+     * 
+ * @param filter the filter to apply to the set of files. + * @param files the array of files to apply the filter to. + * + * @return a subset of files that is accepted by the + * file filter. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * + * @since 2.0 + */ + public static File[] filter(final IOFileFilter filter, final File... files) { + if (filter == null) { + throw new IllegalArgumentException("file filter is null"); + } + if (files == null) { + return new File[0]; + } + final List acceptedFiles = new ArrayList(); + for (final File file : files) { + if (file == null) { + throw new IllegalArgumentException("file array contains null"); + } + if (filter.accept(file)) { + acceptedFiles.add(file); + } + } + return acceptedFiles.toArray(new File[acceptedFiles.size()]); + } + + /** + *

+ * Applies an {@link IOFileFilter} to the provided {@link File} + * objects. The resulting array is a subset of the original file list that + * matches the provided filter. + *

+ * + *

+ * The {@link Set} returned by this method is not guaranteed to be thread safe. + *

+ * + *
+     * Set<File> allFiles = ...
+     * Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
+     *     FileFilterUtils.suffixFileFilter(".java"));
+     * 
+ * @param filter the filter to apply to the set of files. + * @param files the array of files to apply the filter to. + * + * @return a subset of files that is accepted by the + * file filter. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * + * @since 2.0 + */ + public static File[] filter(final IOFileFilter filter, final Iterable files) { + final List acceptedFiles = filterList(filter, files); + return acceptedFiles.toArray(new File[acceptedFiles.size()]); + } + + /** + *

+ * Applies an {@link IOFileFilter} to the provided {@link File} + * objects. The resulting list is a subset of the original files that + * matches the provided filter. + *

+ * + *

+ * The {@link List} returned by this method is not guaranteed to be thread safe. + *

+ * + *
+     * List<File> filesAndDirectories = ...
+     * List<File> directories = FileFilterUtils.filterList(filesAndDirectories,
+     *     FileFilterUtils.directoryFileFilter());
+     * 
+ * @param filter the filter to apply to each files in the list. + * @param files the collection of files to apply the filter to. + * + * @return a subset of files that is accepted by the + * file filter. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * @since 2.0 + */ + public static List filterList(final IOFileFilter filter, final Iterable files) { + return filter(filter, files, new ArrayList()); + } + + /** + *

+ * Applies an {@link IOFileFilter} to the provided {@link File} + * objects. The resulting list is a subset of the original files that + * matches the provided filter. + *

+ * + *

+ * The {@link List} returned by this method is not guaranteed to be thread safe. + *

+ * + *
+     * List<File> filesAndDirectories = ...
+     * List<File> directories = FileFilterUtils.filterList(filesAndDirectories,
+     *     FileFilterUtils.directoryFileFilter());
+     * 
+ * @param filter the filter to apply to each files in the list. + * @param files the collection of files to apply the filter to. + * + * @return a subset of files that is accepted by the + * file filter. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * @since 2.0 + */ + public static List filterList(final IOFileFilter filter, final File... files) { + final File[] acceptedFiles = filter(filter, files); + return Arrays.asList(acceptedFiles); + } + + /** + *

+ * Applies an {@link IOFileFilter} to the provided {@link File} + * objects. The resulting set is a subset of the original file list that + * matches the provided filter. + *

+ * + *

+ * The {@link Set} returned by this method is not guaranteed to be thread safe. + *

+ * + *
+     * Set<File> allFiles = ...
+     * Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
+     *     FileFilterUtils.suffixFileFilter(".java"));
+     * 
+ * @param filter the filter to apply to the set of files. + * @param files the collection of files to apply the filter to. + * + * @return a subset of files that is accepted by the + * file filter. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * + * @since 2.0 + */ + public static Set filterSet(final IOFileFilter filter, final File... files) { + final File[] acceptedFiles = filter(filter, files); + return new HashSet(Arrays.asList(acceptedFiles)); + } + + /** + *

+ * Applies an {@link IOFileFilter} to the provided {@link File} + * objects. The resulting set is a subset of the original file list that + * matches the provided filter. + *

+ * + *

+ * The {@link Set} returned by this method is not guaranteed to be thread safe. + *

+ * + *
+     * Set<File> allFiles = ...
+     * Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
+     *     FileFilterUtils.suffixFileFilter(".java"));
+     * 
+ * @param filter the filter to apply to the set of files. + * @param files the collection of files to apply the filter to. + * + * @return a subset of files that is accepted by the + * file filter. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + * + * @since 2.0 + */ + public static Set filterSet(final IOFileFilter filter, final Iterable files) { + return filter(filter, files, new HashSet()); + } + + /** + *

+ * Applies an {@link IOFileFilter} to the provided {@link File} + * objects and appends the accepted files to the other supplied collection. + *

+ * + *
+     * List<File> files = ...
+     * List<File> directories = FileFilterUtils.filterList(files,
+     *     FileFilterUtils.sizeFileFilter(FileUtils.FIFTY_MB),
+     *         new ArrayList<File>());
+     * 
+ * @param filter the filter to apply to the collection of files. + * @param files the collection of files to apply the filter to. + * @param acceptedFiles the list of files to add accepted files to. + * + * @param the type of the file collection. + * @return a subset of files that is accepted by the + * file filter. + * @throws IllegalArgumentException if the filter is {@code null} + * or files contains a {@code null} value. + */ + private static > T filter(final IOFileFilter filter, + final Iterable files, final T acceptedFiles) { + if (filter == null) { + throw new IllegalArgumentException("file filter is null"); + } + if (files != null) { + for (final File file : files) { + if (file == null) { + throw new IllegalArgumentException("file collection contains null"); + } + if (filter.accept(file)) { + acceptedFiles.add(file); + } + } + } + return acceptedFiles; + } + + /** + * Returns a filter that returns true if the filename starts with the specified text. + * + * @param prefix the filename prefix + * @return a prefix checking filter + * @see PrefixFileFilter + */ + public static IOFileFilter prefixFileFilter(final String prefix) { + return new PrefixFileFilter(prefix); + } + + /** + * Returns a filter that returns true if the filename starts with the specified text. + * + * @param prefix the filename prefix + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @return a prefix checking filter + * @see PrefixFileFilter + * @since 2.0 + */ + public static IOFileFilter prefixFileFilter(final String prefix, final IOCase caseSensitivity) { + return new PrefixFileFilter(prefix, caseSensitivity); + } + + /** + * Returns a filter that returns true if the filename ends with the specified text. + * + * @param suffix the filename suffix + * @return a suffix checking filter + * @see SuffixFileFilter + */ + public static IOFileFilter suffixFileFilter(final String suffix) { + return new SuffixFileFilter(suffix); + } + + /** + * Returns a filter that returns true if the filename ends with the specified text. + * + * @param suffix the filename suffix + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @return a suffix checking filter + * @see SuffixFileFilter + * @since 2.0 + */ + public static IOFileFilter suffixFileFilter(final String suffix, final IOCase caseSensitivity) { + return new SuffixFileFilter(suffix, caseSensitivity); + } + + /** + * Returns a filter that returns true if the filename matches the specified text. + * + * @param name the filename + * @return a name checking filter + * @see NameFileFilter + */ + public static IOFileFilter nameFileFilter(final String name) { + return new NameFileFilter(name); + } + + /** + * Returns a filter that returns true if the filename matches the specified text. + * + * @param name the filename + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @return a name checking filter + * @see NameFileFilter + * @since 2.0 + */ + public static IOFileFilter nameFileFilter(final String name, final IOCase caseSensitivity) { + return new NameFileFilter(name, caseSensitivity); + } + + /** + * Returns a filter that checks if the file is a directory. + * + * @return file filter that accepts only directories and not files + * @see DirectoryFileFilter#DIRECTORY + */ + public static IOFileFilter directoryFileFilter() { + return DirectoryFileFilter.DIRECTORY; + } + + /** + * Returns a filter that checks if the file is a file (and not a directory). + * + * @return file filter that accepts only files and not directories + * @see FileFileFilter#FILE + */ + public static IOFileFilter fileFileFilter() { + return FileFileFilter.FILE; + } + + //----------------------------------------------------------------------- + /** + * Returns a filter that ANDs the two specified filters. + * + * @param filter1 the first filter + * @param filter2 the second filter + * @return a filter that ANDs the two specified filters + * @see #and(IOFileFilter...) + * @see AndFileFilter + * @deprecated use {@link #and(IOFileFilter...)} + */ + @Deprecated + public static IOFileFilter andFileFilter(final IOFileFilter filter1, final IOFileFilter filter2) { + return new AndFileFilter(filter1, filter2); + } + + /** + * Returns a filter that ORs the two specified filters. + * + * @param filter1 the first filter + * @param filter2 the second filter + * @return a filter that ORs the two specified filters + * @see #or(IOFileFilter...) + * @see OrFileFilter + * @deprecated use {@link #or(IOFileFilter...)} + */ + @Deprecated + public static IOFileFilter orFileFilter(final IOFileFilter filter1, final IOFileFilter filter2) { + return new OrFileFilter(filter1, filter2); + } + + /** + * Returns a filter that ANDs the specified filters. + * + * @param filters the IOFileFilters that will be ANDed together. + * @return a filter that ANDs the specified filters + * + * @throws IllegalArgumentException if the filters are null or contain a + * null value. + * @see AndFileFilter + * @since 2.0 + */ + public static IOFileFilter and(final IOFileFilter... filters) { + return new AndFileFilter(toList(filters)); + } + + /** + * Returns a filter that ORs the specified filters. + * + * @param filters the IOFileFilters that will be ORed together. + * @return a filter that ORs the specified filters + * + * @throws IllegalArgumentException if the filters are null or contain a + * null value. + * @see OrFileFilter + * @since 2.0 + */ + public static IOFileFilter or(final IOFileFilter... filters) { + return new OrFileFilter(toList(filters)); + } + + /** + * Create a List of file filters. + * + * @param filters The file filters + * @return The list of file filters + * @throws IllegalArgumentException if the filters are null or contain a + * null value. + * @since 2.0 + */ + public static List toList(final IOFileFilter... filters) { + if (filters == null) { + throw new IllegalArgumentException("The filters must not be null"); + } + final List list = new ArrayList(filters.length); + for (int i = 0; i < filters.length; i++) { + if (filters[i] == null) { + throw new IllegalArgumentException("The filter[" + i + "] is null"); + } + list.add(filters[i]); + } + return list; + } + + /** + * Returns a filter that NOTs the specified filter. + * + * @param filter the filter to invert + * @return a filter that NOTs the specified filter + * @see NotFileFilter + */ + public static IOFileFilter notFileFilter(final IOFileFilter filter) { + return new NotFileFilter(filter); + } + + //----------------------------------------------------------------------- + /** + * Returns a filter that always returns true. + * + * @return a true filter + * @see TrueFileFilter#TRUE + */ + public static IOFileFilter trueFileFilter() { + return TrueFileFilter.TRUE; + } + + /** + * Returns a filter that always returns false. + * + * @return a false filter + * @see FalseFileFilter#FALSE + */ + public static IOFileFilter falseFileFilter() { + return FalseFileFilter.FALSE; + } + + //----------------------------------------------------------------------- + /** + * Returns an IOFileFilter that wraps the + * FileFilter instance. + * + * @param filter the filter to be wrapped + * @return a new filter that implements IOFileFilter + * @see DelegateFileFilter + */ + public static IOFileFilter asFileFilter(final FileFilter filter) { + return new DelegateFileFilter(filter); + } + + /** + * Returns an IOFileFilter that wraps the + * FilenameFilter instance. + * + * @param filter the filter to be wrapped + * @return a new filter that implements IOFileFilter + * @see DelegateFileFilter + */ + public static IOFileFilter asFileFilter(final FilenameFilter filter) { + return new DelegateFileFilter(filter); + } + + //----------------------------------------------------------------------- + /** + * Returns a filter that returns true if the file was last modified after + * the specified cutoff time. + * + * @param cutoff the time threshold + * @return an appropriately configured age file filter + * @see AgeFileFilter + * @since 1.2 + */ + public static IOFileFilter ageFileFilter(final long cutoff) { + return new AgeFileFilter(cutoff); + } + + /** + * Returns a filter that filters files based on a cutoff time. + * + * @param cutoff the time threshold + * @param acceptOlder if true, older files get accepted, if false, newer + * @return an appropriately configured age file filter + * @see AgeFileFilter + * @since 1.2 + */ + public static IOFileFilter ageFileFilter(final long cutoff, final boolean acceptOlder) { + return new AgeFileFilter(cutoff, acceptOlder); + } + + /** + * Returns a filter that returns true if the file was last modified after + * the specified cutoff date. + * + * @param cutoffDate the time threshold + * @return an appropriately configured age file filter + * @see AgeFileFilter + * @since 1.2 + */ + public static IOFileFilter ageFileFilter(final Date cutoffDate) { + return new AgeFileFilter(cutoffDate); + } + + /** + * Returns a filter that filters files based on a cutoff date. + * + * @param cutoffDate the time threshold + * @param acceptOlder if true, older files get accepted, if false, newer + * @return an appropriately configured age file filter + * @see AgeFileFilter + * @since 1.2 + */ + public static IOFileFilter ageFileFilter(final Date cutoffDate, final boolean acceptOlder) { + return new AgeFileFilter(cutoffDate, acceptOlder); + } + + /** + * Returns a filter that returns true if the file was last modified after + * the specified reference file. + * + * @param cutoffReference the file whose last modification + * time is usesd as the threshold age of the files + * @return an appropriately configured age file filter + * @see AgeFileFilter + * @since 1.2 + */ + public static IOFileFilter ageFileFilter(final File cutoffReference) { + return new AgeFileFilter(cutoffReference); + } + + /** + * Returns a filter that filters files based on a cutoff reference file. + * + * @param cutoffReference the file whose last modification + * time is usesd as the threshold age of the files + * @param acceptOlder if true, older files get accepted, if false, newer + * @return an appropriately configured age file filter + * @see AgeFileFilter + * @since 1.2 + */ + public static IOFileFilter ageFileFilter(final File cutoffReference, final boolean acceptOlder) { + return new AgeFileFilter(cutoffReference, acceptOlder); + } + + //----------------------------------------------------------------------- + /** + * Returns a filter that returns true if the file is bigger than a certain size. + * + * @param threshold the file size threshold + * @return an appropriately configured SizeFileFilter + * @see SizeFileFilter + * @since 1.2 + */ + public static IOFileFilter sizeFileFilter(final long threshold) { + return new SizeFileFilter(threshold); + } + + /** + * Returns a filter that filters based on file size. + * + * @param threshold the file size threshold + * @param acceptLarger if true, larger files get accepted, if false, smaller + * @return an appropriately configured SizeFileFilter + * @see SizeFileFilter + * @since 1.2 + */ + public static IOFileFilter sizeFileFilter(final long threshold, final boolean acceptLarger) { + return new SizeFileFilter(threshold, acceptLarger); + } + + /** + * Returns a filter that accepts files whose size is >= minimum size + * and <= maximum size. + * + * @param minSizeInclusive the minimum file size (inclusive) + * @param maxSizeInclusive the maximum file size (inclusive) + * @return an appropriately configured IOFileFilter + * @see SizeFileFilter + * @since 1.3 + */ + public static IOFileFilter sizeRangeFileFilter(final long minSizeInclusive, final long maxSizeInclusive ) { + final IOFileFilter minimumFilter = new SizeFileFilter(minSizeInclusive, true); + final IOFileFilter maximumFilter = new SizeFileFilter(maxSizeInclusive + 1L, false); + return new AndFileFilter(minimumFilter, maximumFilter); + } + + /** + * Returns a filter that accepts files that begin with the provided magic + * number. + * + * @param magicNumber the magic number (byte sequence) to match at the + * beginning of each file. + * + * @return an IOFileFilter that accepts files beginning with the provided + * magic number. + * + * @throws IllegalArgumentException if magicNumber is + * {@code null} or the empty String. + * @see MagicNumberFileFilter + * @since 2.0 + */ + public static IOFileFilter magicNumberFileFilter(final String magicNumber) { + return new MagicNumberFileFilter(magicNumber); + } + + /** + * Returns a filter that accepts files that contains the provided magic + * number at a specified offset within the file. + * + * @param magicNumber the magic number (byte sequence) to match at the + * provided offset in each file. + * @param offset the offset within the files to look for the magic number. + * + * @return an IOFileFilter that accepts files containing the magic number + * at the specified offset. + * + * @throws IllegalArgumentException if magicNumber is + * {@code null} or the empty String, or if offset is a + * negative number. + * @see MagicNumberFileFilter + * @since 2.0 + */ + public static IOFileFilter magicNumberFileFilter(final String magicNumber, final long offset) { + return new MagicNumberFileFilter(magicNumber, offset); + } + + /** + * Returns a filter that accepts files that begin with the provided magic + * number. + * + * @param magicNumber the magic number (byte sequence) to match at the + * beginning of each file. + * + * @return an IOFileFilter that accepts files beginning with the provided + * magic number. + * + * @throws IllegalArgumentException if magicNumber is + * {@code null} or is of length zero. + * @see MagicNumberFileFilter + * @since 2.0 + */ + public static IOFileFilter magicNumberFileFilter(final byte[] magicNumber) { + return new MagicNumberFileFilter(magicNumber); + } + + /** + * Returns a filter that accepts files that contains the provided magic + * number at a specified offset within the file. + * + * @param magicNumber the magic number (byte sequence) to match at the + * provided offset in each file. + * @param offset the offset within the files to look for the magic number. + * + * @return an IOFileFilter that accepts files containing the magic number + * at the specified offset. + * + * @throws IllegalArgumentException if magicNumber is + * {@code null}, or contains no bytes, or offset + * is a negative number. + * @see MagicNumberFileFilter + * @since 2.0 + */ + public static IOFileFilter magicNumberFileFilter(final byte[] magicNumber, final long offset) { + return new MagicNumberFileFilter(magicNumber, offset); + } + + //----------------------------------------------------------------------- + /* Constructed on demand and then cached */ + private static final IOFileFilter cvsFilter = notFileFilter( + and(directoryFileFilter(), nameFileFilter("CVS"))); + + /* Constructed on demand and then cached */ + private static final IOFileFilter svnFilter = notFileFilter( + and(directoryFileFilter(), nameFileFilter(".svn"))); + + /** + * Decorates a filter to make it ignore CVS directories. + * Passing in {@code null} will return a filter that accepts everything + * except CVS directories. + * + * @param filter the filter to decorate, null means an unrestricted filter + * @return the decorated filter, never null + * @since 1.1 (method existed but had bug in 1.0) + */ + public static IOFileFilter makeCVSAware(final IOFileFilter filter) { + if (filter == null) { + return cvsFilter; + } else { + return and(filter, cvsFilter); + } + } + + /** + * Decorates a filter to make it ignore SVN directories. + * Passing in {@code null} will return a filter that accepts everything + * except SVN directories. + * + * @param filter the filter to decorate, null means an unrestricted filter + * @return the decorated filter, never null + * @since 1.1 + */ + public static IOFileFilter makeSVNAware(final IOFileFilter filter) { + if (filter == null) { + return svnFilter; + } else { + return and(filter, svnFilter); + } + } + + //----------------------------------------------------------------------- + /** + * Decorates a filter so that it only applies to directories and not to files. + * + * @param filter the filter to decorate, null means an unrestricted filter + * @return the decorated filter, never null + * @see DirectoryFileFilter#DIRECTORY + * @since 1.3 + */ + public static IOFileFilter makeDirectoryOnly(final IOFileFilter filter) { + if (filter == null) { + return DirectoryFileFilter.DIRECTORY; + } + return new AndFileFilter(DirectoryFileFilter.DIRECTORY, filter); + } + + /** + * Decorates a filter so that it only applies to files and not to directories. + * + * @param filter the filter to decorate, null means an unrestricted filter + * @return the decorated filter, never null + * @see FileFileFilter#FILE + * @since 1.3 + */ + public static IOFileFilter makeFileOnly(final IOFileFilter filter) { + if (filter == null) { + return FileFileFilter.FILE; + } + return new AndFileFilter(FileFileFilter.FILE, filter); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/HiddenFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/HiddenFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..c7dcf9c540f6861fa4ec6d169c9150b2c157e3c3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/HiddenFileFilter.java" @@ -0,0 +1,79 @@ +/* + * 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; + +/** + * This filter accepts Files that are hidden. + *

+ * Example, showing how to print out a list of the + * current directory's hidden files: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( HiddenFileFilter.HIDDEN );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + *

+ * Example, showing how to print out a list of the + * current directory's visible (i.e. not hidden) files: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( HiddenFileFilter.VISIBLE );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.3 + * @version $Id: HiddenFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + */ +public class HiddenFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 8930842316112759062L; + + /** Singleton instance of hidden filter */ + public static final IOFileFilter HIDDEN = new HiddenFileFilter(); + + /** Singleton instance of visible filter */ + public static final IOFileFilter VISIBLE = new NotFileFilter(HIDDEN); + + /** + * Restrictive consructor. + */ + protected HiddenFileFilter() { + } + + /** + * Checks to see if the file is hidden. + * + * @param file the File to check + * @return {@code true} if the file is + * hidden, otherwise {@code false}. + */ + @Override + public boolean accept(final File file) { + return file.isHidden(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/IOFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/IOFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..ea840f399930a7014612b0ca3f683f7b654a32fa --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/IOFileFilter.java" @@ -0,0 +1,53 @@ +/* + * 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.FileFilter; +import java.io.FilenameFilter; + +/** + * An interface which brings the FileFilter and FilenameFilter + * interfaces together. + * + * @since 1.0 + * @version $Id: IOFileFilter.java 1471767 2013-04-24 23:24:19Z sebb $ + */ +public interface IOFileFilter extends FileFilter, FilenameFilter { + + /** + * Checks to see if the File should be accepted by this filter. + *

+ * Defined in {@link java.io.FileFilter}. + * + * @param file the File to check + * @return true if this file matches the test + */ + boolean accept(File file); + + /** + * Checks to see if the File should be accepted by this filter. + *

+ * Defined in {@link java.io.FilenameFilter}. + * + * @param dir the directory File to check + * @param name the filename within the directory to check + * @return true if this file matches the test + */ + boolean accept(File dir, String name); + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..00aa9962280af801e855f18dd5ecfd9bc2c62597 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/MagicNumberFileFilter.java" @@ -0,0 +1,274 @@ +/* + * 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.IOException; +import java.io.RandomAccessFile; +import java.io.Serializable; +import java.nio.charset.Charset; +import java.util.Arrays; + +import org.apache.commons.io.IOUtils; + +/** + *

+ * File filter for matching files containing a "magic number". A magic number + * is a unique series of bytes common to all files of a specific file format. + * For instance, all Java class files begin with the bytes + * 0xCAFEBABE. + *

+ * + *
+ * File dir = new File(".");
+ * MagicNumberFileFilter javaClassFileFilter =
+ *     MagicNumberFileFilter(new byte[] {(byte) 0xCA, (byte) 0xFE,
+ *       (byte) 0xBA, (byte) 0xBE});
+ * String[] javaClassFiles = dir.list(javaClassFileFilter);
+ * for (String javaClassFile : javaClassFiles) {
+ *     System.out.println(javaClassFile);
+ * }
+ * 
+ * + *

+ * Sometimes, such as in the case of TAR files, the + * magic number will be offset by a certain number of bytes in the file. In the + * case of TAR archive files, this offset is 257 bytes. + *

+ * + *
+ * File dir = new File(".");
+ * MagicNumberFileFilter tarFileFilter =
+ *     MagicNumberFileFilter("ustar", 257);
+ * String[] tarFiles = dir.list(tarFileFilter);
+ * for (String tarFile : tarFiles) {
+ *     System.out.println(tarFile);
+ * }
+ * 
+ * + * @since 2.0 + * @see FileFilterUtils#magicNumberFileFilter(byte[]) + * @see FileFilterUtils#magicNumberFileFilter(String) + * @see FileFilterUtils#magicNumberFileFilter(byte[], long) + * @see FileFilterUtils#magicNumberFileFilter(String, long) + */ +public class MagicNumberFileFilter extends AbstractFileFilter implements + Serializable { + + /** + * The serialization version unique identifier. + */ + private static final long serialVersionUID = -547733176983104172L; + + /** + * The magic number to compare against the file's bytes at the provided + * offset. + */ + private final byte[] magicNumbers; + + /** + * The offset (in bytes) within the files that the magic number's bytes + * should appear. + */ + private final long byteOffset; + + /** + *

+ * Constructs a new MagicNumberFileFilter and associates it with the magic + * number to test for in files. This constructor assumes a starting offset + * of 0. + *

+ * + *

+ * It is important to note that the array is not cloned and that + * any changes to the magic number array after construction will affect the + * behavior of this file filter. + *

+ * + *
+     * MagicNumberFileFilter javaClassFileFilter =
+     *     MagicNumberFileFilter(new byte[] {(byte) 0xCA, (byte) 0xFE,
+     *       (byte) 0xBA, (byte) 0xBE});
+     * 
+ * + * @param magicNumber the magic number to look for in the file. + * + * @throws IllegalArgumentException if magicNumber is + * {@code null}, or contains no bytes. + */ + public MagicNumberFileFilter(final byte[] magicNumber) { + this(magicNumber, 0); + } + + /** + *

+ * Constructs a new MagicNumberFileFilter and associates it with the magic + * number to test for in files. This constructor assumes a starting offset + * of 0. + *

+ * + * Example usage: + *
+     * {@code
+     * MagicNumberFileFilter xmlFileFilter =
+     *     MagicNumberFileFilter("
+     *
+     * @param magicNumber the magic number to look for in the file.
+     *        The string is converted to bytes using the platform default charset.
+     *
+     * @throws IllegalArgumentException if magicNumber is
+     *         {@code null} or the empty String.
+     */
+    public MagicNumberFileFilter(final String magicNumber) {
+        this(magicNumber, 0);
+    }
+
+    /**
+     * 

+ * Constructs a new MagicNumberFileFilter and associates it with the magic + * number to test for in files and the byte offset location in the file to + * to look for that magic number. + *

+ * + *
+     * MagicNumberFileFilter tarFileFilter =
+     *     MagicNumberFileFilter("ustar", 257);
+     * 
+ * + * @param magicNumber the magic number to look for in the file. + * The string is converted to bytes using the platform default charset. + * @param offset the byte offset in the file to start comparing bytes. + * + * @throws IllegalArgumentException if magicNumber is + * {@code null} or the empty String, or offset is + * a negative number. + */ + public MagicNumberFileFilter(final String magicNumber, final long offset) { + if (magicNumber == null) { + throw new IllegalArgumentException("The magic number cannot be null"); + } + if (magicNumber.isEmpty()) { + throw new IllegalArgumentException("The magic number must contain at least one byte"); + } + if (offset < 0) { + throw new IllegalArgumentException("The offset cannot be negative"); + } + + this.magicNumbers = magicNumber.getBytes(Charset.defaultCharset()); // explicitly uses the platform default + // charset + this.byteOffset = offset; + } + + /** + *

+ * Constructs a new MagicNumberFileFilter and associates it with the magic + * number to test for in files and the byte offset location in the file to + * to look for that magic number. + *

+ * + *
+     * MagicNumberFileFilter tarFileFilter =
+     *     MagicNumberFileFilter(new byte[] {0x75, 0x73, 0x74, 0x61, 0x72}, 257);
+     * 
+ * + *
+     * MagicNumberFileFilter javaClassFileFilter =
+     *     MagicNumberFileFilter(new byte[] {0xCA, 0xFE, 0xBA, 0xBE}, 0);
+     * 
+ * + * @param magicNumber the magic number to look for in the file. + * @param offset the byte offset in the file to start comparing bytes. + * + * @throws IllegalArgumentException if magicNumber is + * {@code null}, or contains no bytes, or offset + * is a negative number. + */ + public MagicNumberFileFilter(final byte[] magicNumber, final long offset) { + if (magicNumber == null) { + throw new IllegalArgumentException("The magic number cannot be null"); + } + if (magicNumber.length == 0) { + throw new IllegalArgumentException("The magic number must contain at least one byte"); + } + if (offset < 0) { + throw new IllegalArgumentException("The offset cannot be negative"); + } + + this.magicNumbers = new byte[magicNumber.length]; + System.arraycopy(magicNumber, 0, this.magicNumbers, 0, magicNumber.length); + this.byteOffset = offset; + } + + /** + *

+ * Accepts the provided file if the file contains the file filter's magic + * number at the specified offset. + *

+ * + *

+ * If any {@link IOException}s occur while reading the file, the file will + * be rejected. + *

+ * + * @param file the file to accept or reject. + * + * @return {@code true} if the file contains the filter's magic number + * at the specified offset, {@code false} otherwise. + */ + @Override + public boolean accept(final File file) { + if (file != null && file.isFile() && file.canRead()) { + RandomAccessFile randomAccessFile = null; + try { + final byte[] fileBytes = new byte[this.magicNumbers.length]; + randomAccessFile = new RandomAccessFile(file, "r"); + randomAccessFile.seek(byteOffset); + final int read = randomAccessFile.read(fileBytes); + if (read != magicNumbers.length) { + return false; + } + return Arrays.equals(this.magicNumbers, fileBytes); + } catch (final IOException ioe) { + // Do nothing, fall through and do not accept file + } finally { + IOUtils.closeQuietly(randomAccessFile); + } + } + + return false; + } + + /** + * Returns a String representation of the file filter, which includes the + * magic number bytes and byte offset. + * + * @return a String representation of the file filter. + */ + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(super.toString()); + builder.append("("); + builder.append(new String(magicNumbers, Charset.defaultCharset()));// TODO perhaps use hex if value is not + // printable + builder.append(","); + builder.append(this.byteOffset); + builder.append(")"); + return builder.toString(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..99521e4fd7294134bd45a2c08807a4effd2c07cd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/NameFileFilter.java" @@ -0,0 +1,190 @@ +/* + * 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.List; + +import org.apache.commons.io.IOCase; + +/** + * Filters filenames for a certain name. + *

+ * For example, to print all files and directories in the + * current directory whose name is Test: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( new NameFileFilter("Test") );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.0 + * @version $Id: NameFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @see FileFilterUtils#nameFileFilter(String) + * @see FileFilterUtils#nameFileFilter(String, IOCase) + */ +public class NameFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 176844364689077340L; + /** The filenames to search for */ + private final String[] names; + /** Whether the comparison is case sensitive. */ + private final IOCase caseSensitivity; + + /** + * Constructs a new case-sensitive name file filter for a single name. + * + * @param name the name to allow, must not be null + * @throws IllegalArgumentException if the name is null + */ + public NameFileFilter(final String name) { + this(name, null); + } + + /** + * Construct a new name file filter specifying case-sensitivity. + * + * @param name the name to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the name is null + */ + public NameFileFilter(final String name, final IOCase caseSensitivity) { + if (name == null) { + throw new IllegalArgumentException("The wildcard must not be null"); + } + this.names = new String[] {name}; + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Constructs a new case-sensitive name file filter for an array of names. + *

+ * The array is not cloned, so could be changed after constructing the + * instance. This would be inadvisable however. + * + * @param names the names to allow, must not be null + * @throws IllegalArgumentException if the names array is null + */ + public NameFileFilter(final String[] names) { + this(names, null); + } + + /** + * Constructs a new name file filter for an array of names specifying case-sensitivity. + * + * @param names the names to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the names array is null + */ + public NameFileFilter(final String[] names, final IOCase caseSensitivity) { + if (names == null) { + throw new IllegalArgumentException("The array of names must not be null"); + } + this.names = new String[names.length]; + System.arraycopy(names, 0, this.names, 0, names.length); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Constructs a new case-sensitive name file filter for a list of names. + * + * @param names the names to allow, must not be null + * @throws IllegalArgumentException if the name list is null + * @throws ClassCastException if the list does not contain Strings + */ + public NameFileFilter(final List names) { + this(names, null); + } + + /** + * Constructs a new name file filter for a list of names specifying case-sensitivity. + * + * @param names the names to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the name list is null + * @throws ClassCastException if the list does not contain Strings + */ + public NameFileFilter(final List names, final IOCase caseSensitivity) { + if (names == null) { + throw new IllegalArgumentException("The list of names must not be null"); + } + this.names = names.toArray(new String[names.size()]); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + //----------------------------------------------------------------------- + /** + * Checks to see if the filename matches. + * + * @param file the File to check + * @return true if the filename matches + */ + @Override + public boolean accept(final File file) { + final String name = file.getName(); + for (final String name2 : this.names) { + if (caseSensitivity.checkEquals(name, name2)) { + return true; + } + } + return false; + } + + /** + * Checks to see if the filename matches. + * + * @param dir the File directory (ignored) + * @param name the filename + * @return true if the filename matches + */ + @Override + public boolean accept(final File dir, final String name) { + for (final String name2 : names) { + if (caseSensitivity.checkEquals(name, name2)) { + return true; + } + } + return false; + } + + /** + * 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 (names != null) { + for (int i = 0; i < names.length; i++) { + if (i > 0) { + buffer.append(","); + } + buffer.append(names[i]); + } + } + buffer.append(")"); + return buffer.toString(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/NotFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/NotFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..d86e382e1053037d92fa7121698f774734150b1c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/NotFileFilter.java" @@ -0,0 +1,81 @@ +/* + * 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; + +/** + * This filter produces a logical NOT of the filters specified. + * + * @since 1.0 + * @version $Id: NotFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @see FileFilterUtils#notFileFilter(IOFileFilter) + */ +public class NotFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 6131563330944994230L; + /** The filter */ + private final IOFileFilter filter; + + /** + * Constructs a new file filter that NOTs the result of another filter. + * + * @param filter the filter, must not be null + * @throws IllegalArgumentException if the filter is null + */ + public NotFileFilter(final IOFileFilter filter) { + if (filter == null) { + throw new IllegalArgumentException("The filter must not be null"); + } + this.filter = filter; + } + + /** + * Returns the logical NOT of the underlying filter's return value for the same File. + * + * @param file the File to check + * @return true if the filter returns false + */ + @Override + public boolean accept(final File file) { + return ! filter.accept(file); + } + + /** + * Returns the logical NOT of the underlying filter's return value for the same arguments. + * + * @param file the File directory + * @param name the filename + * @return true if the filter returns false + */ + @Override + public boolean accept(final File file, final String name) { + return ! filter.accept(file, name); + } + + /** + * Provide a String representaion of this file filter. + * + * @return a String representaion + */ + @Override + public String toString() { + return super.toString() + "(" + filter.toString() + ")"; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/OrFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/OrFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..75332dec24cc1fc7da71bc07c413a841bc5cfabd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/OrFileFilter.java" @@ -0,0 +1,162 @@ +/* + * 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 OR logic across a list of + * file filters. This filter returns {@code true} if any 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 true}. + * + * @since 1.0 + * @version $Id: OrFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @see FileFilterUtils#or(IOFileFilter...) + */ +public class OrFileFilter + extends AbstractFileFilter + implements ConditionalFileFilter, Serializable { + + private static final long serialVersionUID = 5767770777065432721L; + /** The list of file filters. */ + private final List fileFilters; + + /** + * Constructs a new instance of OrFileFilter. + * + * @since 1.1 + */ + public OrFileFilter() { + this.fileFilters = new ArrayList(); + } + + /** + * Constructs a new instance of OrFileFilter + * with the specified filters. + * + * @param fileFilters the file filters for this filter, copied, null ignored + * @since 1.1 + */ + public OrFileFilter(final List fileFilters) { + if (fileFilters == null) { + this.fileFilters = new ArrayList(); + } else { + this.fileFilters = new ArrayList(fileFilters); + } + } + + /** + * Constructs a new file filter that ORs 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 OrFileFilter(final IOFileFilter filter1, final IOFileFilter filter2) { + if (filter1 == null || filter2 == null) { + throw new IllegalArgumentException("The filters must not be null"); + } + this.fileFilters = new ArrayList(2); + addFileFilter(filter1); + addFileFilter(filter2); + } + + /** + * {@inheritDoc} + */ + public void addFileFilter(final IOFileFilter ioFileFilter) { + this.fileFilters.add(ioFileFilter); + } + + /** + * {@inheritDoc} + */ + public List getFileFilters() { + return Collections.unmodifiableList(this.fileFilters); + } + + /** + * {@inheritDoc} + */ + public boolean removeFileFilter(final IOFileFilter ioFileFilter) { + return this.fileFilters.remove(ioFileFilter); + } + + /** + * {@inheritDoc} + */ + public void setFileFilters(final List fileFilters) { + this.fileFilters.clear(); + this.fileFilters.addAll(fileFilters); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean accept(final File file) { + for (final IOFileFilter fileFilter : fileFilters) { + if (fileFilter.accept(file)) { + return true; + } + } + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean accept(final File file, final String name) { + for (final IOFileFilter fileFilter : fileFilters) { + if (fileFilter.accept(file, name)) { + return true; + } + } + return false; + } + + /** + * 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(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/PrefixFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/PrefixFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..22c386bb45f4e142fd9d4a470bdbe4998b8cbd28 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/PrefixFileFilter.java" @@ -0,0 +1,197 @@ +/* + * 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.List; + +import org.apache.commons.io.IOCase; + +/** + * Filters filenames for a certain prefix. + *

+ * For example, to print all files and directories in the + * current directory whose name starts with Test: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( new PrefixFileFilter("Test") );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.0 + * @version $Id: PrefixFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @see FileFilterUtils#prefixFileFilter(String) + * @see FileFilterUtils#prefixFileFilter(String, IOCase) + */ +public class PrefixFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 8533897440809599867L; + + /** The filename prefixes to search for */ + private final String[] prefixes; + + /** Whether the comparison is case sensitive. */ + private final IOCase caseSensitivity; + + /** + * Constructs a new Prefix file filter for a single prefix. + * + * @param prefix the prefix to allow, must not be null + * @throws IllegalArgumentException if the prefix is null + */ + public PrefixFileFilter(final String prefix) { + this(prefix, IOCase.SENSITIVE); + } + + /** + * Constructs a new Prefix file filter for a single prefix + * specifying case-sensitivity. + * + * @param prefix the prefix to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the prefix is null + * @since 1.4 + */ + public PrefixFileFilter(final String prefix, final IOCase caseSensitivity) { + if (prefix == null) { + throw new IllegalArgumentException("The prefix must not be null"); + } + this.prefixes = new String[] {prefix}; + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Constructs a new Prefix file filter for any of an array of prefixes. + *

+ * The array is not cloned, so could be changed after constructing the + * instance. This would be inadvisable however. + * + * @param prefixes the prefixes to allow, must not be null + * @throws IllegalArgumentException if the prefix array is null + */ + public PrefixFileFilter(final String[] prefixes) { + this(prefixes, IOCase.SENSITIVE); + } + + /** + * Constructs a new Prefix file filter for any of an array of prefixes + * specifying case-sensitivity. + * + * @param prefixes the prefixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the prefix is null + * @since 1.4 + */ + public PrefixFileFilter(final String[] prefixes, final IOCase caseSensitivity) { + if (prefixes == null) { + throw new IllegalArgumentException("The array of prefixes must not be null"); + } + this.prefixes = new String[prefixes.length]; + System.arraycopy(prefixes, 0, this.prefixes, 0, prefixes.length); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Constructs a new Prefix file filter for a list of prefixes. + * + * @param prefixes the prefixes to allow, must not be null + * @throws IllegalArgumentException if the prefix list is null + * @throws ClassCastException if the list does not contain Strings + */ + public PrefixFileFilter(final List prefixes) { + this(prefixes, IOCase.SENSITIVE); + } + + /** + * Constructs a new Prefix file filter for a list of prefixes + * specifying case-sensitivity. + * + * @param prefixes the prefixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the prefix list is null + * @throws ClassCastException if the list does not contain Strings + * @since 1.4 + */ + public PrefixFileFilter(final List prefixes, final IOCase caseSensitivity) { + if (prefixes == null) { + throw new IllegalArgumentException("The list of prefixes must not be null"); + } + this.prefixes = prefixes.toArray(new String[prefixes.size()]); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Checks to see if the filename starts with the prefix. + * + * @param file the File to check + * @return true if the filename starts with one of our prefixes + */ + @Override + public boolean accept(final File file) { + final String name = file.getName(); + for (final String prefix : this.prefixes) { + if (caseSensitivity.checkStartsWith(name, prefix)) { + return true; + } + } + return false; + } + + /** + * Checks to see if the filename starts with the prefix. + * + * @param file the File directory + * @param name the filename + * @return true if the filename starts with one of our prefixes + */ + @Override + public boolean accept(final File file, final String name) { + for (final String prefix : prefixes) { + if (caseSensitivity.checkStartsWith(name, prefix)) { + return true; + } + } + return false; + } + + /** + * 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 (prefixes != null) { + for (int i = 0; i < prefixes.length; i++) { + if (i > 0) { + buffer.append(","); + } + buffer.append(prefixes[i]); + } + } + buffer.append(")"); + return buffer.toString(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..0d462c7ea5f2100b4a1a9a4041597db11d818d5e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/RegexFileFilter.java" @@ -0,0 +1,123 @@ +/* + * 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.regex.Pattern; + +import org.apache.commons.io.IOCase; + +/** + * Filters files using supplied regular expression(s). + *

+ * See java.util.regex.Pattern for regex matching rules + *

+ * + *

+ * e.g. + *

+ * File dir = new File(".");
+ * FileFilter fileFilter = new RegexFileFilter("^.*[tT]est(-\\d+)?\\.java$");
+ * File[] files = dir.listFiles(fileFilter);
+ * for (int i = 0; i < files.length; i++) {
+ *   System.out.println(files[i]);
+ * }
+ * 
+ * + * @version $Id: RegexFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @since 1.4 + */ +public class RegexFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 4269646126155225062L; + /** The regular expression pattern that will be used to match filenames */ + private final Pattern pattern; + + /** + * Construct a new regular expression filter. + * + * @param pattern regular string expression to match + * @throws IllegalArgumentException if the pattern is null + */ + public RegexFileFilter(final String pattern) { + if (pattern == null) { + throw new IllegalArgumentException("Pattern is missing"); + } + + this.pattern = Pattern.compile(pattern); + } + + /** + * Construct a new regular expression filter with the specified flags case sensitivity. + * + * @param pattern regular string expression to match + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the pattern is null + */ + public RegexFileFilter(final String pattern, final IOCase caseSensitivity) { + if (pattern == null) { + throw new IllegalArgumentException("Pattern is missing"); + } + int flags = 0; + if (caseSensitivity != null && !caseSensitivity.isCaseSensitive()) { + flags = Pattern.CASE_INSENSITIVE; + } + this.pattern = Pattern.compile(pattern, flags); + } + + /** + * Construct a new regular expression filter with the specified flags. + * + * @param pattern regular string expression to match + * @param flags pattern flags - e.g. {@link Pattern#CASE_INSENSITIVE} + * @throws IllegalArgumentException if the pattern is null + */ + public RegexFileFilter(final String pattern, final int flags) { + if (pattern == null) { + throw new IllegalArgumentException("Pattern is missing"); + } + this.pattern = Pattern.compile(pattern, flags); + } + + /** + * Construct a new regular expression filter for a compiled regular expression + * + * @param pattern regular expression to match + * @throws IllegalArgumentException if the pattern is null + */ + public RegexFileFilter(final Pattern pattern) { + if (pattern == null) { + throw new IllegalArgumentException("Pattern is missing"); + } + + this.pattern = pattern; + } + + /** + * Checks to see if the filename matches one of the regular expressions. + * + * @param dir the file directory (ignored) + * @param name the filename + * @return true if the filename matches one of the regular expressions + */ + @Override + public boolean accept(final File dir, final String name) { + return pattern.matcher(name).matches(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/SizeFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/SizeFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..1623e255e930139d0021d93d560ff4fe1776fda1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/SizeFileFilter.java" @@ -0,0 +1,108 @@ +/* + * 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; + +/** + * Filters files based on size, can filter either smaller files or + * files equal to or larger than a given threshold. + *

+ * For example, to print all files and directories in the + * current directory whose size is greater than 1 MB: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( new SizeFileFilter(1024 * 1024) );
+ * for ( int i = 0; i < files.length; i++ ) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @version $Id: SizeFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @since 1.2 + * @see FileFilterUtils#sizeFileFilter(long) + * @see FileFilterUtils#sizeFileFilter(long, boolean) + * @see FileFilterUtils#sizeRangeFileFilter(long, long) + */ +public class SizeFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = 7388077430788600069L; + /** The size threshold. */ + private final long size; + /** Whether the files accepted will be larger or smaller. */ + private final boolean acceptLarger; + + /** + * Constructs a new size file filter for files equal to or + * larger than a certain size. + * + * @param size the threshold size of the files + * @throws IllegalArgumentException if the size is negative + */ + public SizeFileFilter(final long size) { + this(size, true); + } + + /** + * Constructs a new size file filter for files based on a certain size + * threshold. + * + * @param size the threshold size of the files + * @param acceptLarger if true, files equal to or larger are accepted, + * otherwise smaller ones (but not equal to) + * @throws IllegalArgumentException if the size is negative + */ + public SizeFileFilter(final long size, final boolean acceptLarger) { + if (size < 0) { + throw new IllegalArgumentException("The size must be non-negative"); + } + this.size = size; + this.acceptLarger = acceptLarger; + } + + //----------------------------------------------------------------------- + /** + * Checks to see if the size of the file is favorable. + *

+ * If size equals threshold and smaller files are required, + * file IS NOT selected. + * If size equals threshold and larger files are required, + * file IS selected. + * + * @param file the File to check + * @return true if the filename matches + */ + @Override + public boolean accept(final File file) { + final boolean smaller = file.length() < size; + return acceptLarger ? !smaller : smaller; + } + + /** + * Provide a String representaion of this file filter. + * + * @return a String representaion + */ + @Override + public String toString() { + final String condition = acceptLarger ? ">=" : "<"; + return super.toString() + "(" + condition + size + ")"; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/SuffixFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/SuffixFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..cd5a9d057afd43a182580eaa96093c00c412f4fd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/SuffixFileFilter.java" @@ -0,0 +1,198 @@ +/* + * 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.List; + +import org.apache.commons.io.IOCase; + +/** + * Filters files based on the suffix (what the filename ends with). + * This is used in retrieving all the files of a particular type. + *

+ * For example, to retrieve and print all *.java files + * in the current directory: + * + *

+ * File dir = new File(".");
+ * String[] files = dir.list( new SuffixFileFilter(".java") );
+ * for (int i = 0; i < files.length; i++) {
+ *     System.out.println(files[i]);
+ * }
+ * 
+ * + * @since 1.0 + * @version $Id: SuffixFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @see FileFilterUtils#suffixFileFilter(String) + * @see FileFilterUtils#suffixFileFilter(String, IOCase) + */ +public class SuffixFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = -3389157631240246157L; + + /** The filename suffixes to search for */ + private final String[] suffixes; + + /** Whether the comparison is case sensitive. */ + private final IOCase caseSensitivity; + + /** + * Constructs a new Suffix file filter for a single extension. + * + * @param suffix the suffix to allow, must not be null + * @throws IllegalArgumentException if the suffix is null + */ + public SuffixFileFilter(final String suffix) { + this(suffix, IOCase.SENSITIVE); + } + + /** + * Constructs a new Suffix file filter for a single extension + * specifying case-sensitivity. + * + * @param suffix the suffix to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the suffix is null + * @since 1.4 + */ + public SuffixFileFilter(final String suffix, final IOCase caseSensitivity) { + if (suffix == null) { + throw new IllegalArgumentException("The suffix must not be null"); + } + this.suffixes = new String[] {suffix}; + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Constructs a new Suffix file filter for an array of suffixs. + *

+ * The array is not cloned, so could be changed after constructing the + * instance. This would be inadvisable however. + * + * @param suffixes the suffixes to allow, must not be null + * @throws IllegalArgumentException if the suffix array is null + */ + public SuffixFileFilter(final String[] suffixes) { + this(suffixes, IOCase.SENSITIVE); + } + + /** + * Constructs a new Suffix file filter for an array of suffixs + * specifying case-sensitivity. + * + * @param suffixes the suffixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the suffix array is null + * @since 1.4 + */ + public SuffixFileFilter(final String[] suffixes, final IOCase caseSensitivity) { + if (suffixes == null) { + throw new IllegalArgumentException("The array of suffixes must not be null"); + } + this.suffixes = new String[suffixes.length]; + System.arraycopy(suffixes, 0, this.suffixes, 0, suffixes.length); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Constructs a new Suffix file filter for a list of suffixes. + * + * @param suffixes the suffixes to allow, must not be null + * @throws IllegalArgumentException if the suffix list is null + * @throws ClassCastException if the list does not contain Strings + */ + public SuffixFileFilter(final List suffixes) { + this(suffixes, IOCase.SENSITIVE); + } + + /** + * Constructs a new Suffix file filter for a list of suffixes + * specifying case-sensitivity. + * + * @param suffixes the suffixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the suffix list is null + * @throws ClassCastException if the list does not contain Strings + * @since 1.4 + */ + public SuffixFileFilter(final List suffixes, final IOCase caseSensitivity) { + if (suffixes == null) { + throw new IllegalArgumentException("The list of suffixes must not be null"); + } + this.suffixes = suffixes.toArray(new String[suffixes.size()]); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Checks to see if the filename ends with the suffix. + * + * @param file the File to check + * @return true if the filename ends with one of our suffixes + */ + @Override + public boolean accept(final File file) { + final String name = file.getName(); + for (final String suffix : this.suffixes) { + if (caseSensitivity.checkEndsWith(name, suffix)) { + return true; + } + } + return false; + } + + /** + * Checks to see if the filename ends with the suffix. + * + * @param file the File directory + * @param name the filename + * @return true if the filename ends with one of our suffixes + */ + @Override + public boolean accept(final File file, final String name) { + for (final String suffix : this.suffixes) { + if (caseSensitivity.checkEndsWith(name, suffix)) { + return true; + } + } + return false; + } + + /** + * 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 (suffixes != null) { + for (int i = 0; i < suffixes.length; i++) { + if (i > 0) { + buffer.append(","); + } + buffer.append(suffixes[i]); + } + } + buffer.append(")"); + return buffer.toString(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/TrueFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/TrueFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..61028605591f9f355f8884e8cb59b526dbcf0206 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/TrueFileFilter.java" @@ -0,0 +1,72 @@ +/* + * 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; + +/** + * A file filter that always returns true. + * + * @since 1.0 + * @version $Id: TrueFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @see FileFilterUtils#trueFileFilter() + */ +public class TrueFileFilter implements IOFileFilter, Serializable { + + private static final long serialVersionUID = 8782512160909720199L; + /** + * Singleton instance of true filter. + * @since 1.3 + */ + public static final IOFileFilter TRUE = new TrueFileFilter(); + /** + * Singleton instance of true filter. + * Please use the identical TrueFileFilter.TRUE constant. + * The new name is more JDK 1.5 friendly as it doesn't clash with other + * values when using static imports. + */ + public static final IOFileFilter INSTANCE = TRUE; + + /** + * Restrictive constructor. + */ + protected TrueFileFilter() { + } + + /** + * Returns true. + * + * @param file the file to check (ignored) + * @return true + */ + public boolean accept(final File file) { + return true; + } + + /** + * Returns true. + * + * @param dir the directory to check (ignored) + * @param name the filename (ignored) + * @return true + */ + public boolean accept(final File dir, final String name) { + return true; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/WildcardFileFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/WildcardFileFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..02a5f23dc6b9cbde2ec9a4c9f9470cf6bcfd65ba --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/WildcardFileFilter.java" @@ -0,0 +1,196 @@ +/* + * 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.List; + +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.io.IOCase; + +/** + * Filters files using the supplied wildcards. + *

+ * This filter selects files and directories based on one or more wildcards. + * Testing is case-sensitive by default, but this can be configured. + *

+ * The wildcard matcher uses the characters '?' and '*' to represent a + * single or multiple wildcard characters. + * This is the same as often found on Dos/Unix command lines. + * The check is case-sensitive by default. + * See {@link FilenameUtils#wildcardMatchOnSystem} for more information. + *

+ * For example: + *

+ * File dir = new File(".");
+ * FileFilter fileFilter = new WildcardFileFilter("*test*.java~*~");
+ * File[] files = dir.listFiles(fileFilter);
+ * for (int i = 0; i < files.length; i++) {
+ *   System.out.println(files[i]);
+ * }
+ * 
+ * + * @version $Id: WildcardFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @since 1.3 + */ +public class WildcardFileFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = -7426486598995782105L; + /** The wildcards that will be used to match filenames. */ + private final String[] wildcards; + /** Whether the comparison is case sensitive. */ + private final IOCase caseSensitivity; + + /** + * Construct a new case-sensitive wildcard filter for a single wildcard. + * + * @param wildcard the wildcard to match + * @throws IllegalArgumentException if the pattern is null + */ + public WildcardFileFilter(final String wildcard) { + this(wildcard, IOCase.SENSITIVE); + } + + /** + * Construct a new wildcard filter for a single wildcard specifying case-sensitivity. + * + * @param wildcard the wildcard to match, not null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the pattern is null + */ + public WildcardFileFilter(final String wildcard, final IOCase caseSensitivity) { + if (wildcard == null) { + throw new IllegalArgumentException("The wildcard must not be null"); + } + this.wildcards = new String[] { wildcard }; + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Construct a new case-sensitive wildcard filter for an array of wildcards. + *

+ * + * @param wildcards the array of wildcards to match + * @throws IllegalArgumentException if the pattern array is null + */ + public WildcardFileFilter(final String[] wildcards) { + this(wildcards, IOCase.SENSITIVE); + } + + /** + * Construct a new wildcard filter for an array of wildcards specifying case-sensitivity. + *

+ * + * @param wildcards the array of wildcards to match, not null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the pattern array is null + */ + public WildcardFileFilter(final String[] wildcards, final IOCase caseSensitivity) { + if (wildcards == null) { + throw new IllegalArgumentException("The wildcard array must not be null"); + } + this.wildcards = new String[wildcards.length]; + System.arraycopy(wildcards, 0, this.wildcards, 0, wildcards.length); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + /** + * Construct a new case-sensitive wildcard filter for a list of wildcards. + * + * @param wildcards the list of wildcards to match, not null + * @throws IllegalArgumentException if the pattern list is null + * @throws ClassCastException if the list does not contain Strings + */ + public WildcardFileFilter(final List wildcards) { + this(wildcards, IOCase.SENSITIVE); + } + + /** + * Construct a new wildcard filter for a list of wildcards specifying case-sensitivity. + * + * @param wildcards the list of wildcards to match, not null + * @param caseSensitivity how to handle case sensitivity, null means case-sensitive + * @throws IllegalArgumentException if the pattern list is null + * @throws ClassCastException if the list does not contain Strings + */ + public WildcardFileFilter(final List wildcards, final IOCase caseSensitivity) { + if (wildcards == null) { + throw new IllegalArgumentException("The wildcard list must not be null"); + } + this.wildcards = wildcards.toArray(new String[wildcards.size()]); + this.caseSensitivity = caseSensitivity == null ? IOCase.SENSITIVE : caseSensitivity; + } + + //----------------------------------------------------------------------- + /** + * Checks to see if the filename matches one of the wildcards. + * + * @param dir the file directory (ignored) + * @param name the filename + * @return true if the filename matches one of the wildcards + */ + @Override + public boolean accept(final File dir, final String name) { + for (final String wildcard : wildcards) { + if (FilenameUtils.wildcardMatch(name, wildcard, caseSensitivity)) { + return true; + } + } + return false; + } + + /** + * Checks to see if the filename matches one of the wildcards. + * + * @param file the file to check + * @return true if the filename matches one of the wildcards + */ + @Override + public boolean accept(final File file) { + final String name = file.getName(); + for (final String wildcard : wildcards) { + if (FilenameUtils.wildcardMatch(name, wildcard, caseSensitivity)) { + return true; + } + } + return false; + } + + /** + * Provide a String representation of this file filter. + * + * @return a String representation + */ + @Override + public String toString() { + final StringBuilder buffer = new StringBuilder(); + buffer.append(super.toString()); + buffer.append("("); + if (wildcards != null) { + for (int i = 0; i < wildcards.length; i++) { + if (i > 0) { + buffer.append(","); + } + buffer.append(wildcards[i]); + } + } + buffer.append(")"); + return buffer.toString(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/WildcardFilter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/WildcardFilter.java" new file mode 100644 index 0000000000000000000000000000000000000000..e1c38d3518c57919ea5dd42f9c57ef54e3dd4815 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/WildcardFilter.java" @@ -0,0 +1,144 @@ +/* + * 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.List; + +import org.apache.commons.io.FilenameUtils; + +/** + * Filters files using the supplied wildcards. + *

+ * This filter selects files, but not directories, based on one or more wildcards + * and using case-sensitive comparison. + *

+ * The wildcard matcher uses the characters '?' and '*' to represent a + * single or multiple wildcard characters. + * This is the same as often found on Dos/Unix command lines. + * The extension check is case-sensitive. + * See {@link FilenameUtils#wildcardMatch(String, String)} for more information. + *

+ * For example: + *

+ * File dir = new File(".");
+ * FileFilter fileFilter = new WildcardFilter("*test*.java~*~");
+ * File[] files = dir.listFiles(fileFilter);
+ * for (int i = 0; i < files.length; i++) {
+ *   System.out.println(files[i]);
+ * }
+ * 
+ * + * @version $Id: WildcardFilter.java 1642757 2014-12-01 21:09:30Z sebb $ + * @since 1.1 + * @deprecated Use WilcardFileFilter. Deprecated as this class performs directory + * filtering which it shouldn't do, but that can't be removed due to compatability. + */ +@Deprecated +public class WildcardFilter extends AbstractFileFilter implements Serializable { + + private static final long serialVersionUID = -5037645902506953517L; + /** The wildcards that will be used to match filenames. */ + private final String[] wildcards; + + /** + * Construct a new case-sensitive wildcard filter for a single wildcard. + * + * @param wildcard the wildcard to match + * @throws IllegalArgumentException if the pattern is null + */ + public WildcardFilter(final String wildcard) { + if (wildcard == null) { + throw new IllegalArgumentException("The wildcard must not be null"); + } + this.wildcards = new String[] { wildcard }; + } + + /** + * Construct a new case-sensitive wildcard filter for an array of wildcards. + * + * @param wildcards the array of wildcards to match + * @throws IllegalArgumentException if the pattern array is null + */ + public WildcardFilter(final String[] wildcards) { + if (wildcards == null) { + throw new IllegalArgumentException("The wildcard array must not be null"); + } + this.wildcards = new String[wildcards.length]; + System.arraycopy(wildcards, 0, this.wildcards, 0, wildcards.length); + } + + /** + * Construct a new case-sensitive wildcard filter for a list of wildcards. + * + * @param wildcards the list of wildcards to match + * @throws IllegalArgumentException if the pattern list is null + * @throws ClassCastException if the list does not contain Strings + */ + public WildcardFilter(final List wildcards) { + if (wildcards == null) { + throw new IllegalArgumentException("The wildcard list must not be null"); + } + this.wildcards = wildcards.toArray(new String[wildcards.size()]); + } + + //----------------------------------------------------------------------- + /** + * Checks to see if the filename matches one of the wildcards. + * + * @param dir the file directory + * @param name the filename + * @return true if the filename matches one of the wildcards + */ + @Override + public boolean accept(final File dir, final String name) { + if (dir != null && new File(dir, name).isDirectory()) { + return false; + } + + for (final String wildcard : wildcards) { + if (FilenameUtils.wildcardMatch(name, wildcard)) { + return true; + } + } + + return false; + } + + /** + * Checks to see if the filename matches one of the wildcards. + * + * @param file the file to check + * @return true if the filename matches one of the wildcards + */ + @Override + public boolean accept(final File file) { + if (file.isDirectory()) { + return false; + } + + for (final String wildcard : wildcards) { + if (FilenameUtils.wildcardMatch(file.getName(), wildcard)) { + return true; + } + } + + return false; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/package.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/package.html" new file mode 100644 index 0000000000000000000000000000000000000000..e495e9521399b04ab0241dc8eb2675a33a2bf37c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/filefilter/package.html" @@ -0,0 +1,143 @@ + + + + +

This package defines an interface (IOFileFilter) that combines both +{@link java.io.FileFilter} and {@link java.io.FilenameFilter}. Besides +that the package offers a series of ready-to-use implementations of the +IOFileFilter interface including implementation that allow you to combine +other such filters.

+

These filter can be used to list files or in {@link java.awt.FileDialog}, +for example.

+ +

There are a number of 'primitive' filters:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DirectoryFilterOnly accept directories
PrefixFileFilterFilter based on a prefix
SuffixFileFilterFilter based on a suffix
NameFileFilterFilter based on a filename
WildcardFileFilterFilter based on wildcards
AgeFileFilterFilter based on last modified time of file
SizeFileFilterFilter based on file size
+ +

And there are five 'boolean' filters:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
TrueFileFilterAccept all files
FalseFileFilterAccept no files
NotFileFilterApplies a logical NOT to an existing filter
AndFileFilterCombines two filters using a logical AND
OrFileFilterCombines two filter using a logical OR
+ +

These boolean FilenameFilters can be nested, to allow arbitrary expressions. +For example, here is how one could print all non-directory files in the +current directory, starting with "A", and ending in ".java" or ".class":

+ +
+  File dir = new File(".");
+  String[] files = dir.list( 
+    new AndFileFilter(
+      new AndFileFilter(
+        new PrefixFileFilter("A"),
+        new OrFileFilter(
+          new SuffixFileFilter(".class"),
+          new SuffixFileFilter(".java")
+        )
+      ),
+      new NotFileFilter(
+        new DirectoryFileFilter()
+      )
+    )
+  );
+  for ( int i=0; i<files.length; i++ ) {
+    System.out.println(files[i]);
+  }
+
+ +

This package also contains a utility class: +FileFilterUtils. It allows you to use all +file filters without having to put them in the import section. Here's how the +above example will look using FileFilterUtils:

+
+  File dir = new File(".");
+  String[] files = dir.list( 
+    FileFilterUtils.andFileFilter(
+      FileFilterUtils.andFileFilter(
+        FileFilterUtils.prefixFileFilter("A"),
+        FileFilterUtils.orFileFilter(
+          FileFilterUtils.suffixFileFilter(".class"),
+          FileFilterUtils.suffixFileFilter(".java")
+        )
+      ),
+      FileFilterUtils.notFileFilter(
+        FileFilterUtils.directoryFileFilter()
+      )
+    )
+  );
+  for ( int i=0; i<files.length; i++ ) {
+    System.out.println(files[i]);
+  }
+
+

There are a few other goodies in that class so please have a look at the +documentation in detail.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..660cae3abbb03a9a25a6d27f1e44c22ef85117a1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/AutoCloseInputStream.java" @@ -0,0 +1,95 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Proxy stream that closes and discards the underlying stream as soon as the + * end of input has been reached or when the stream is explicitly closed. + * Not even a reference to the underlying stream is kept after it has been + * closed, so any allocated in-memory buffers can be freed even if the + * client application still keeps a reference to the proxy stream. + *

+ * This class is typically used to release any resources related to an open + * stream as soon as possible even if the client application (by not explicitly + * closing the stream when no longer needed) or the underlying stream (by not + * releasing resources once the last byte has been read) do not do that. + * + * @version $Id: AutoCloseInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $ + * @since 1.4 + */ +public class AutoCloseInputStream extends ProxyInputStream { + + /** + * Creates an automatically closing proxy for the given input stream. + * + * @param in underlying input stream + */ + public AutoCloseInputStream(final InputStream in) { + super(in); + } + + /** + * Closes the underlying input stream and replaces the reference to it + * with a {@link ClosedInputStream} instance. + *

+ * This method is automatically called by the read methods when the end + * of input has been reached. + *

+ * Note that it is safe to call this method any number of times. The original + * underlying input stream is closed and discarded only once when this + * method is first called. + * + * @throws IOException if the underlying input stream can not be closed + */ + @Override + public void close() throws IOException { + in.close(); + in = new ClosedInputStream(); + } + + /** + * Automatically closes the stream if the end of stream was reached. + * + * @param n number of bytes read, or -1 if no more bytes are available + * @throws IOException if the stream could not be closed + * @since 2.0 + */ + @Override + protected void afterRead(final int n) throws IOException { + if (n == EOF) { + close(); + } + } + + /** + * Ensures that the stream is closed before it gets garbage-collected. + * As mentioned in {@link #close()}, this is a no-op if the stream has + * already been closed. + * @throws Throwable if an error occurs + */ + @Override + protected void finalize() throws Throwable { + close(); + super.finalize(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BOMInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BOMInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..6aef06f90a5b20d3032449a4517c10841e4e792c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BOMInputStream.java" @@ -0,0 +1,408 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import org.apache.commons.io.ByteOrderMark; + +/** + * This class is used to wrap a stream that includes an encoded {@link ByteOrderMark} as its first bytes. + * + * This class detects these bytes and, if required, can automatically skip them and return the subsequent byte as the + * first byte in the stream. + * + * The {@link ByteOrderMark} implementation has the following pre-defined BOMs: + *

    + *
  • UTF-8 - {@link ByteOrderMark#UTF_8}
  • + *
  • UTF-16BE - {@link ByteOrderMark#UTF_16LE}
  • + *
  • UTF-16LE - {@link ByteOrderMark#UTF_16BE}
  • + *
  • UTF-32BE - {@link ByteOrderMark#UTF_32LE}
  • + *
  • UTF-32LE - {@link ByteOrderMark#UTF_32BE}
  • + *
+ * + * + *

Example 1 - Detect and exclude a UTF-8 BOM

+ * + *
+ * BOMInputStream bomIn = new BOMInputStream(in);
+ * if (bomIn.hasBOM()) {
+ *     // has a UTF-8 BOM
+ * }
+ * 
+ * + *

Example 2 - Detect a UTF-8 BOM (but don't exclude it)

+ * + *
+ * boolean include = true;
+ * BOMInputStream bomIn = new BOMInputStream(in, include);
+ * if (bomIn.hasBOM()) {
+ *     // has a UTF-8 BOM
+ * }
+ * 
+ * + *

Example 3 - Detect Multiple BOMs

+ * + *
+ * BOMInputStream bomIn = new BOMInputStream(in, 
+ *   ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE,
+ *   ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE
+ *   );
+ * if (bomIn.hasBOM() == false) {
+ *     // No BOM found
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_16LE)) {
+ *     // has a UTF-16LE BOM
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_16BE)) {
+ *     // has a UTF-16BE BOM
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_32LE)) {
+ *     // has a UTF-32LE BOM
+ * } else if (bomIn.hasBOM(ByteOrderMark.UTF_32BE)) {
+ *     // has a UTF-32BE BOM
+ * }
+ * 
+ * + * @see org.apache.commons.io.ByteOrderMark + * @see Wikipedia - Byte Order Mark + * @version $Id: BOMInputStream.java 1686527 2015-06-20 06:31:39Z krosenvold $ + * @since 2.0 + */ +public class BOMInputStream extends ProxyInputStream { + private final boolean include; + /** + * BOMs are sorted from longest to shortest. + */ + private final List boms; + private ByteOrderMark byteOrderMark; + private int[] firstBytes; + private int fbLength; + private int fbIndex; + private int markFbIndex; + private boolean markedAtStart; + + /** + * Constructs a new BOM InputStream that excludes a {@link ByteOrderMark#UTF_8} BOM. + * + * @param delegate + * the InputStream to delegate to + */ + public BOMInputStream(final InputStream delegate) { + this(delegate, false, ByteOrderMark.UTF_8); + } + + /** + * Constructs a new BOM InputStream that detects a a {@link ByteOrderMark#UTF_8} and optionally includes it. + * + * @param delegate + * the InputStream to delegate to + * @param include + * true to include the UTF-8 BOM or false to exclude it + */ + public BOMInputStream(final InputStream delegate, final boolean include) { + this(delegate, include, ByteOrderMark.UTF_8); + } + + /** + * Constructs a new BOM InputStream that excludes the specified BOMs. + * + * @param delegate + * the InputStream to delegate to + * @param boms + * The BOMs to detect and exclude + */ + public BOMInputStream(final InputStream delegate, final ByteOrderMark... boms) { + this(delegate, false, boms); + } + + /** + * Compares ByteOrderMark objects in descending length order. + */ + private static final Comparator ByteOrderMarkLengthComparator = new Comparator() { + + public int compare(final ByteOrderMark bom1, final ByteOrderMark bom2) { + final int len1 = bom1.length(); + final int len2 = bom2.length(); + if (len1 > len2) { + return EOF; + } + if (len2 > len1) { + return 1; + } + return 0; + } + }; + + /** + * Constructs a new BOM InputStream that detects the specified BOMs and optionally includes them. + * + * @param delegate + * the InputStream to delegate to + * @param include + * true to include the specified BOMs or false to exclude them + * @param boms + * The BOMs to detect and optionally exclude + */ + public BOMInputStream(final InputStream delegate, final boolean include, final ByteOrderMark... boms) { + super(delegate); + if (boms == null || boms.length == 0) { + throw new IllegalArgumentException("No BOMs specified"); + } + this.include = include; + // Sort the BOMs to match the longest BOM first because some BOMs have the same starting two bytes. + Arrays.sort(boms, ByteOrderMarkLengthComparator); + this.boms = Arrays.asList(boms); + + } + + /** + * Indicates whether the stream contains one of the specified BOMs. + * + * @return true if the stream has one of the specified BOMs, otherwise false if it does not + * @throws IOException + * if an error reading the first bytes of the stream occurs + */ + public boolean hasBOM() throws IOException { + return getBOM() != null; + } + + /** + * Indicates whether the stream contains the specified BOM. + * + * @param bom + * The BOM to check for + * @return true if the stream has the specified BOM, otherwise false if it does not + * @throws IllegalArgumentException + * if the BOM is not one the stream is configured to detect + * @throws IOException + * if an error reading the first bytes of the stream occurs + */ + public boolean hasBOM(final ByteOrderMark bom) throws IOException { + if (!boms.contains(bom)) { + throw new IllegalArgumentException("Stream not configure to detect " + bom); + } + return byteOrderMark != null && getBOM().equals(bom); + } + + /** + * Return the BOM (Byte Order Mark). + * + * @return The BOM or null if none + * @throws IOException + * if an error reading the first bytes of the stream occurs + */ + public ByteOrderMark getBOM() throws IOException { + if (firstBytes == null) { + fbLength = 0; + // BOMs are sorted from longest to shortest + final int maxBomSize = boms.get(0).length(); + firstBytes = new int[maxBomSize]; + // Read first maxBomSize bytes + for (int i = 0; i < firstBytes.length; i++) { + firstBytes[i] = in.read(); + fbLength++; + if (firstBytes[i] < 0) { + break; + } + } + // match BOM in firstBytes + byteOrderMark = find(); + if (byteOrderMark != null) { + if (!include) { + if (byteOrderMark.length() < firstBytes.length) { + fbIndex = byteOrderMark.length(); + } else { + fbLength = 0; + } + } + } + } + return byteOrderMark; + } + + /** + * Return the BOM charset Name - {@link ByteOrderMark#getCharsetName()}. + * + * @return The BOM charset Name or null if no BOM found + * @throws IOException + * if an error reading the first bytes of the stream occurs + * + */ + public String getBOMCharsetName() throws IOException { + getBOM(); + return byteOrderMark == null ? null : byteOrderMark.getCharsetName(); + } + + /** + * This method reads and either preserves or skips the first bytes in the stream. It behaves like the single-byte + * read() method, either returning a valid byte or -1 to indicate that the initial bytes have been + * processed already. + * + * @return the byte read (excluding BOM) or -1 if the end of stream + * @throws IOException + * if an I/O error occurs + */ + private int readFirstBytes() throws IOException { + getBOM(); + return fbIndex < fbLength ? firstBytes[fbIndex++] : EOF; + } + + /** + * Find a BOM with the specified bytes. + * + * @return The matched BOM or null if none matched + */ + private ByteOrderMark find() { + for (final ByteOrderMark bom : boms) { + if (matches(bom)) { + return bom; + } + } + return null; + } + + /** + * Check if the bytes match a BOM. + * + * @param bom + * The BOM + * @return true if the bytes match the bom, otherwise false + */ + private boolean matches(final ByteOrderMark bom) { + // if (bom.length() != fbLength) { + // return false; + // } + // firstBytes may be bigger than the BOM bytes + for (int i = 0; i < bom.length(); i++) { + if (bom.get(i) != firstBytes[i]) { + return false; + } + } + return true; + } + + // ---------------------------------------------------------------------------- + // Implementation of InputStream + // ---------------------------------------------------------------------------- + + /** + * Invokes the delegate's read() method, detecting and optionally skipping BOM. + * + * @return the byte read (excluding BOM) or -1 if the end of stream + * @throws IOException + * if an I/O error occurs + */ + @Override + public int read() throws IOException { + final int b = readFirstBytes(); + return b >= 0 ? b : in.read(); + } + + /** + * Invokes the delegate's read(byte[], int, int) method, detecting and optionally skipping BOM. + * + * @param buf + * the buffer to read the bytes into + * @param off + * The start offset + * @param len + * The number of bytes to read (excluding BOM) + * @return the number of bytes read or -1 if the end of stream + * @throws IOException + * if an I/O error occurs + */ + @Override + public int read(final byte[] buf, int off, int len) throws IOException { + int firstCount = 0; + int b = 0; + while (len > 0 && b >= 0) { + b = readFirstBytes(); + if (b >= 0) { + buf[off++] = (byte) (b & 0xFF); + len--; + firstCount++; + } + } + final int secondCount = in.read(buf, off, len); + return secondCount < 0 ? firstCount > 0 ? firstCount : EOF : firstCount + secondCount; + } + + /** + * Invokes the delegate's read(byte[]) method, detecting and optionally skipping BOM. + * + * @param buf + * the buffer to read the bytes into + * @return the number of bytes read (excluding BOM) or -1 if the end of stream + * @throws IOException + * if an I/O error occurs + */ + @Override + public int read(final byte[] buf) throws IOException { + return read(buf, 0, buf.length); + } + + /** + * Invokes the delegate's mark(int) method. + * + * @param readlimit + * read ahead limit + */ + @Override + public synchronized void mark(final int readlimit) { + markFbIndex = fbIndex; + markedAtStart = firstBytes == null; + in.mark(readlimit); + } + + /** + * Invokes the delegate's reset() method. + * + * @throws IOException + * if an I/O error occurs + */ + @Override + public synchronized void reset() throws IOException { + fbIndex = markFbIndex; + if (markedAtStart) { + firstBytes = null; + } + + in.reset(); + } + + /** + * Invokes the delegate's skip(long) method, detecting and optionallyskipping BOM. + * + * @param n + * the number of bytes to skip + * @return the number of bytes to skipped or -1 if the end of stream + * @throws IOException + * if an I/O error occurs + */ + @Override + public long skip(long n) throws IOException { + int skipped = 0; + while ((n > skipped) && (readFirstBytes() >= 0)) { + skipped++; + } + return in.skip(n - skipped) + skipped; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BoundedInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BoundedInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..ba7a18468a4e29d4bc5ff5c1c828fc7081777bf7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BoundedInputStream.java" @@ -0,0 +1,232 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; + +/** + * This is a stream that will only supply bytes up to a certain length - if its + * position goes above that, it will stop. + *

+ * This is useful to wrap ServletInputStreams. The ServletInputStream will block + * if you try to read content from it that isn't there, because it doesn't know + * whether the content hasn't arrived yet or whether the content has finished. + * So, one of these, initialized with the Content-length sent in the + * ServletInputStream's header, will stop it blocking, providing it's been sent + * with a correct content length. + * + * @version $Id: BoundedInputStream.java 1586342 2014-04-10 15:36:29Z ggregory $ + * @since 2.0 + */ +public class BoundedInputStream extends InputStream { + + /** the wrapped input stream */ + private final InputStream in; + + /** the max length to provide */ + private final long max; + + /** the number of bytes already returned */ + private long pos = 0; + + /** the marked position */ + private long mark = EOF; + + /** flag if close shoud be propagated */ + private boolean propagateClose = true; + + /** + * Creates a new BoundedInputStream that wraps the given input + * stream and limits it to a certain size. + * + * @param in The wrapped input stream + * @param size The maximum number of bytes to return + */ + public BoundedInputStream(final InputStream in, final long size) { + // Some badly designed methods - eg the servlet API - overload length + // such that "-1" means stream finished + this.max = size; + this.in = in; + } + + /** + * Creates a new BoundedInputStream that wraps the given input + * stream and is unlimited. + * + * @param in The wrapped input stream + */ + public BoundedInputStream(final InputStream in) { + this(in, EOF); + } + + /** + * Invokes the delegate's read() method if + * the current position is less than the limit. + * @return the byte read or -1 if the end of stream or + * the limit has been reached. + * @throws IOException if an I/O error occurs + */ + @Override + public int read() throws IOException { + if (max >= 0 && pos >= max) { + return EOF; + } + final int result = in.read(); + pos++; + return result; + } + + /** + * Invokes the delegate's read(byte[]) method. + * @param b the buffer to read the bytes into + * @return the number of bytes read or -1 if the end of stream or + * the limit has been reached. + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final byte[] b) throws IOException { + return this.read(b, 0, b.length); + } + + /** + * Invokes the delegate's read(byte[], int, int) method. + * @param b the buffer to read the bytes into + * @param off The start offset + * @param len The number of bytes to read + * @return the number of bytes read or -1 if the end of stream or + * the limit has been reached. + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final byte[] b, final int off, final int len) throws IOException { + if (max>=0 && pos>=max) { + return EOF; + } + final long maxRead = max>=0 ? Math.min(len, max-pos) : len; + final int bytesRead = in.read(b, off, (int)maxRead); + + if (bytesRead==EOF) { + return EOF; + } + + pos+=bytesRead; + return bytesRead; + } + + /** + * Invokes the delegate's skip(long) method. + * @param n the number of bytes to skip + * @return the actual number of bytes skipped + * @throws IOException if an I/O error occurs + */ + @Override + public long skip(final long n) throws IOException { + final long toSkip = max>=0 ? Math.min(n, max-pos) : n; + final long skippedBytes = in.skip(toSkip); + pos+=skippedBytes; + return skippedBytes; + } + + /** + * {@inheritDoc} + */ + @Override + public int available() throws IOException { + if (max>=0 && pos>=max) { + return 0; + } + return in.available(); + } + + /** + * Invokes the delegate's toString() method. + * @return the delegate's toString() + */ + @Override + public String toString() { + return in.toString(); + } + + /** + * Invokes the delegate's close() method + * if {@link #isPropagateClose()} is {@code true}. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + if (propagateClose) { + in.close(); + } + } + + /** + * Invokes the delegate's reset() method. + * @throws IOException if an I/O error occurs + */ + @Override + public synchronized void reset() throws IOException { + in.reset(); + pos = mark; + } + + /** + * Invokes the delegate's mark(int) method. + * @param readlimit read ahead limit + */ + @Override + public synchronized void mark(final int readlimit) { + in.mark(readlimit); + mark = pos; + } + + /** + * Invokes the delegate's markSupported() method. + * @return true if mark is supported, otherwise false + */ + @Override + public boolean markSupported() { + return in.markSupported(); + } + + /** + * Indicates whether the {@link #close()} method + * should propagate to the underling {@link InputStream}. + * + * @return {@code true} if calling {@link #close()} + * propagates to the close() method of the + * underlying stream or {@code false} if it does not. + */ + public boolean isPropagateClose() { + return propagateClose; + } + + /** + * Set whether the {@link #close()} method + * should propagate to the underling {@link InputStream}. + * + * @param propagateClose {@code true} if calling + * {@link #close()} propagates to the close() + * method of the underlying stream or + * {@code false} if it does not. + */ + public void setPropagateClose(final boolean propagateClose) { + this.propagateClose = propagateClose; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BoundedReader.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BoundedReader.java" new file mode 100644 index 0000000000000000000000000000000000000000..a20b51c18a4cc3873b47fcb63ac746e8c603bb6b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BoundedReader.java" @@ -0,0 +1,148 @@ +/* + * 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.input; + +import java.io.IOException; +import java.io.Reader; + +/** + * A reader that imposes a limit to the number of characters that can be read from + * an underlying reader, returning eof when this limit is reached -regardless of state of + * underlying reader. + * + *

+ * One use case is to avoid overrunning the readAheadLimit supplied to + * java.io.Reader#mark(int), since reading too many characters removes the + * ability to do a successful reset. + *

+ * + * @since 2.5 + */ +public class BoundedReader + extends Reader +{ + + private static final int INVALID = -1; + + private final Reader target; + + private int charsRead = 0; + + private int markedAt = INVALID; + + private int readAheadLimit; // Internally, this value will never exceed the allowed size + + private final int maxCharsFromTargetReader; + + /** + * Constructs a bounded reader + * + * @param target The target stream that will be used + * @param maxCharsFromTargetReader The maximum number of characters that can be read from target + * @throws IOException if mark fails + */ + public BoundedReader( Reader target, int maxCharsFromTargetReader ) throws IOException { + this.target = target; + this.maxCharsFromTargetReader = maxCharsFromTargetReader; + } + + /** + * Closes the target + * + * @throws IOException If an I/O error occurs while calling the underlying reader's close method + */ + @Override + public void close() throws IOException { + target.close(); + } + + /** + * Resets the target to the latest mark, @see java.io.Reader#reset() + * + * @throws IOException If an I/O error occurs while calling the underlying reader's reset method + */ + @Override + public void reset() throws IOException { + charsRead = markedAt; + target.reset(); + } + + /** + * marks the target stream, @see java.io.Reader#mark(int). + * + * @param readAheadLimit The number of characters that can be read while + * still retaining the ability to do #reset(). + * Note that this parameter is not validated with respect to + * maxCharsFromTargetReader. There is no way to pass + * past maxCharsFromTargetReader, even if this value is + * greater. + * + * @throws IOException If an I/O error occurs while calling the underlying reader's mark method + */ + @Override + public void mark( int readAheadLimit ) throws IOException { + this.readAheadLimit = readAheadLimit - charsRead; + + markedAt = charsRead; + + target.mark( readAheadLimit ); + } + + /** + * Reads a single character, @see java.io.Reader#read() + * + * @return -1 on eof or the character read + * @throws IOException If an I/O error occurs while calling the underlying reader's read method + */ + @Override + public int read() throws IOException { + + if ( charsRead >= maxCharsFromTargetReader ) { + return -1; + } + + if ( markedAt >= 0 && ( charsRead - markedAt ) >= readAheadLimit ) { + return -1; + } + charsRead++; + return target.read(); + } + + /** + * Reads into an array, @see java.io.Reader#read(char[], int, int) + * + * @param cbuf The buffer to fill + * @param off The offset + * @param len The number of chars to read + * @return the number of chars read + * @throws IOException If an I/O error occurs while calling the underlying reader's read method + */ + @Override + public int read( char[] cbuf, int off, int len ) throws IOException { + int c; + for ( int i = 0; i < len; i++ ) { + c = read(); + if ( c == -1 ) { + return i; + } + cbuf[off + i] = (char) c; + } + return len; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BrokenInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BrokenInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..a8b0fe9073fbfe6fa42a97695c265e367723c897 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/BrokenInputStream.java" @@ -0,0 +1,108 @@ +/* + * 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.input; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Broken input stream. This stream always throws an {@link IOException} from + * all the {@link InputStream} methods where the exception is declared. + *

+ * This class is mostly useful for testing error handling in code that uses an + * input stream. + * + * @since 2.0 + */ +public class BrokenInputStream extends InputStream { + + /** + * The exception that is thrown by all methods of this class. + */ + private final IOException exception; + + /** + * Creates a new stream that always throws the given exception. + * + * @param exception the exception to be thrown + */ + public BrokenInputStream(final IOException exception) { + this.exception = exception; + } + + /** + * Creates a new stream that always throws an {@link IOException} + */ + public BrokenInputStream() { + this(new IOException("Broken input stream")); + } + + /** + * Throws the configured exception. + * + * @return nothing + * @throws IOException always thrown + */ + @Override + public int read() throws IOException { + throw exception; + } + + /** + * Throws the configured exception. + * + * @return nothing + * @throws IOException always thrown + */ + @Override + public int available() throws IOException { + throw exception; + } + + /** + * Throws the configured exception. + * + * @param n ignored + * @return nothing + * @throws IOException always thrown + */ + @Override + public long skip(final long n) throws IOException { + throw exception; + } + + /** + * Throws the configured exception. + * + * @throws IOException always thrown + */ + @Override + public synchronized void reset() throws IOException { + throw exception; + } + + /** + * Throws the configured exception. + * + * @throws IOException always thrown + */ + @Override + public void close() throws IOException { + throw exception; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..c7cdd558dd308fd96626c422dbfa6c9b7db65a9f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CharSequenceInputStream.java" @@ -0,0 +1,269 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.CharacterCodingException; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CoderResult; +import java.nio.charset.CodingErrorAction; + +/** + * {@link InputStream} implementation that can read from String, StringBuffer, + * StringBuilder or CharBuffer. + *

+ * Note: Supports {@link #mark(int)} and {@link #reset()}. + * + * @since 2.2 + */ +public class CharSequenceInputStream extends InputStream { + + private static final int BUFFER_SIZE = 2048; + + private static final int NO_MARK = -1; + + private final CharsetEncoder encoder; + private final CharBuffer cbuf; + private final ByteBuffer bbuf; + + private int mark_cbuf; // position in cbuf + private int mark_bbuf; // position in bbuf + + /** + * Constructor. + * + * @param cs the input character sequence + * @param charset the character set name to use + * @param bufferSize the buffer size to use. + * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character + */ + public CharSequenceInputStream(final CharSequence cs, final Charset charset, final int bufferSize) { + super(); + this.encoder = charset.newEncoder() + .onMalformedInput(CodingErrorAction.REPLACE) + .onUnmappableCharacter(CodingErrorAction.REPLACE); + // Ensure that buffer is long enough to hold a complete character + final float maxBytesPerChar = encoder.maxBytesPerChar(); + if (bufferSize < maxBytesPerChar) { + throw new IllegalArgumentException("Buffer size " + bufferSize + " is less than maxBytesPerChar " + + maxBytesPerChar); + } + this.bbuf = ByteBuffer.allocate(bufferSize); + this.bbuf.flip(); + this.cbuf = CharBuffer.wrap(cs); + this.mark_cbuf = NO_MARK; + this.mark_bbuf = NO_MARK; + } + + /** + * Constructor, calls {@link #CharSequenceInputStream(CharSequence, Charset, int)}. + * + * @param cs the input character sequence + * @param charset the character set name to use + * @param bufferSize the buffer size to use. + * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character + */ + public CharSequenceInputStream(final CharSequence cs, final String charset, final int bufferSize) { + this(cs, Charset.forName(charset), bufferSize); + } + + /** + * Constructor, calls {@link #CharSequenceInputStream(CharSequence, Charset, int)} + * with a buffer size of 2048. + * + * @param cs the input character sequence + * @param charset the character set name to use + * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character + */ + public CharSequenceInputStream(final CharSequence cs, final Charset charset) { + this(cs, charset, BUFFER_SIZE); + } + + /** + * Constructor, calls {@link #CharSequenceInputStream(CharSequence, String, int)} + * with a buffer size of 2048. + * + * @param cs the input character sequence + * @param charset the character set name to use + * @throws IllegalArgumentException if the buffer is not large enough to hold a complete character + */ + public CharSequenceInputStream(final CharSequence cs, final String charset) { + this(cs, charset, BUFFER_SIZE); + } + + /** + * Fills the byte output buffer from the input char buffer. + * + * @throws CharacterCodingException + * an error encoding data + */ + private void fillBuffer() throws CharacterCodingException { + this.bbuf.compact(); + final CoderResult result = this.encoder.encode(this.cbuf, this.bbuf, true); + if (result.isError()) { + result.throwException(); + } + this.bbuf.flip(); + } + + @Override + public int read(final byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException("Byte array is null"); + } + if (len < 0 || (off + len) > b.length) { + throw new IndexOutOfBoundsException("Array Size=" + b.length + + ", offset=" + off + ", length=" + len); + } + if (len == 0) { + return 0; // must return 0 for zero length read + } + if (!this.bbuf.hasRemaining() && !this.cbuf.hasRemaining()) { + return EOF; + } + int bytesRead = 0; + while (len > 0) { + if (this.bbuf.hasRemaining()) { + final int chunk = Math.min(this.bbuf.remaining(), len); + this.bbuf.get(b, off, chunk); + off += chunk; + len -= chunk; + bytesRead += chunk; + } else { + fillBuffer(); + if (!this.bbuf.hasRemaining() && !this.cbuf.hasRemaining()) { + break; + } + } + } + return bytesRead == 0 && !this.cbuf.hasRemaining() ? EOF : bytesRead; + } + + @Override + public int read() throws IOException { + for (;;) { + if (this.bbuf.hasRemaining()) { + return this.bbuf.get() & 0xFF; + } + fillBuffer(); + if (!this.bbuf.hasRemaining() && !this.cbuf.hasRemaining()) { + return EOF; + } + } + } + + @Override + public int read(final byte[] b) throws IOException { + return read(b, 0, b.length); + } + + @Override + public long skip(long n) throws IOException { + /* + * This could be made more efficient by using position to skip within the current buffer. + */ + long skipped = 0; + while (n > 0 && available() > 0) { + this.read(); + n--; + skipped++; + } + return skipped; + } + + /** + * Return an estimate of the number of bytes remaining in the byte stream. + * @return the count of bytes that can be read without blocking (or returning EOF). + * + * @throws IOException if an error occurs (probably not possible) + */ + @Override + public int available() throws IOException { + // The cached entries are in bbuf; since encoding always creates at least one byte + // per character, we can add the two to get a better estimate (e.g. if bbuf is empty) + // Note that the previous implementation (2.4) could return zero even though there were + // encoded bytes still available. + return this.bbuf.remaining() + this.cbuf.remaining(); + } + + @Override + public void close() throws IOException { + } + + /** + * {@inheritDoc} + * @param readlimit max read limit (ignored) + */ + @Override + public synchronized void mark(final int readlimit) { + this.mark_cbuf = this.cbuf.position(); + this.mark_bbuf = this.bbuf.position(); + this.cbuf.mark(); + this.bbuf.mark(); + // It would be nice to be able to use mark & reset on the cbuf and bbuf; + // however the bbuf is re-used so that won't work + } + + @Override + public synchronized void reset() throws IOException { + /* + * This is not the most efficient implementation, as it re-encodes from the beginning. + * + * Since the bbuf is re-used, in general it's necessary to re-encode the data. + * + * It should be possible to apply some optimisations however: + * + use mark/reset on the cbuf and bbuf. This would only work if the buffer had not been (re)filled since + * the mark. The code would have to catch InvalidMarkException - does not seem possible to check if mark is + * valid otherwise. + Try saving the state of the cbuf before each fillBuffer; it might be possible to + * restart from there. + */ + if (this.mark_cbuf != NO_MARK) { + // if cbuf is at 0, we have not started reading anything, so skip re-encoding + if (this.cbuf.position() != 0) { + this.encoder.reset(); + this.cbuf.rewind(); + this.bbuf.rewind(); + this.bbuf.limit(0); // rewind does not clear the buffer + while(this.cbuf.position() < this.mark_cbuf) { + this.bbuf.rewind(); // empty the buffer (we only refill when empty during normal processing) + this.bbuf.limit(0); + fillBuffer(); + } + } + if (this.cbuf.position() != this.mark_cbuf) { + throw new IllegalStateException("Unexpected CharBuffer postion: actual=" + cbuf.position() + " " + + "expected=" + this.mark_cbuf); + } + this.bbuf.position(this.mark_bbuf); + this.mark_cbuf = NO_MARK; + this.mark_bbuf = NO_MARK; + } + } + + @Override + public boolean markSupported() { + return true; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CharSequenceReader.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CharSequenceReader.java" new file mode 100644 index 0000000000000000000000000000000000000000..a290b747414f2119b6dd254371ed8276d267b993 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CharSequenceReader.java" @@ -0,0 +1,166 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.Reader; +import java.io.Serializable; + +/** + * {@link Reader} implementation that can read from String, StringBuffer, + * StringBuilder or CharBuffer. + *

+ * Note: Supports {@link #mark(int)} and {@link #reset()}. + * + * @version $Id: CharSequenceReader.java 1642757 2014-12-01 21:09:30Z sebb $ + * @since 1.4 + */ +public class CharSequenceReader extends Reader implements Serializable { + + private static final long serialVersionUID = 3724187752191401220L; + private final CharSequence charSequence; + private int idx; + private int mark; + + /** + * Construct a new instance with the specified character sequence. + * + * @param charSequence The character sequence, may be {@code null} + */ + public CharSequenceReader(final CharSequence charSequence) { + this.charSequence = charSequence != null ? charSequence : ""; + } + + /** + * Close resets the file back to the start and removes any marked position. + */ + @Override + public void close() { + idx = 0; + mark = 0; + } + + /** + * Mark the current position. + * + * @param readAheadLimit ignored + */ + @Override + public void mark(final int readAheadLimit) { + mark = idx; + } + + /** + * Mark is supported (returns true). + * + * @return {@code true} + */ + @Override + public boolean markSupported() { + return true; + } + + /** + * Read a single character. + * + * @return the next character from the character sequence + * or -1 if the end has been reached. + */ + @Override + public int read() { + if (idx >= charSequence.length()) { + return EOF; + } else { + return charSequence.charAt(idx++); + } + } + + /** + * Read the sepcified number of characters into the array. + * + * @param array The array to store the characters in + * @param offset The starting position in the array to store + * @param length The maximum number of characters to read + * @return The number of characters read or -1 if there are + * no more + */ + @Override + public int read(final char[] array, final int offset, final int length) { + if (idx >= charSequence.length()) { + return EOF; + } + if (array == null) { + throw new NullPointerException("Character array is missing"); + } + if (length < 0 || offset < 0 || offset + length > array.length) { + throw new IndexOutOfBoundsException("Array Size=" + array.length + + ", offset=" + offset + ", length=" + length); + } + int count = 0; + for (int i = 0; i < length; i++) { + final int c = read(); + if (c == EOF) { + return count; + } + array[offset + i] = (char)c; + count++; + } + return count; + } + + /** + * Reset the reader to the last marked position (or the beginning if + * mark has not been called). + */ + @Override + public void reset() { + idx = mark; + } + + /** + * Skip the specified number of characters. + * + * @param n The number of characters to skip + * @return The actual number of characters skipped + */ + @Override + public long skip(final long n) { + if (n < 0) { + throw new IllegalArgumentException( + "Number of characters to skip is less than zero: " + n); + } + if (idx >= charSequence.length()) { + return EOF; + } + final int dest = (int)Math.min(charSequence.length(), idx + n); + final int count = dest - idx; + idx = dest; + return count; + } + + /** + * Return a String representation of the underlying + * character sequence. + * + * @return The contents of the character sequence + */ + @Override + public String toString() { + return charSequence.toString(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..f801052530bf7fd0332eaceaaa51f68a734eef93 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ClassLoaderObjectInputStream.java" @@ -0,0 +1,101 @@ +/* + * 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.input; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import java.io.StreamCorruptedException; +import java.lang.reflect.Proxy; + +/** + * A special ObjectInputStream that loads a class based on a specified + * ClassLoader rather than the system default. + *

+ * This is useful in dynamic container environments. + * + * @version $Id: ClassLoaderObjectInputStream.java 1471767 2013-04-24 23:24:19Z sebb $ + * @since 1.1 + */ +public class ClassLoaderObjectInputStream extends ObjectInputStream { + + /** The class loader to use. */ + private final ClassLoader classLoader; + + /** + * Constructs a new ClassLoaderObjectInputStream. + * + * @param classLoader the ClassLoader from which classes should be loaded + * @param inputStream the InputStream to work on + * @throws IOException in case of an I/O error + * @throws StreamCorruptedException if the stream is corrupted + */ + public ClassLoaderObjectInputStream( + final ClassLoader classLoader, final InputStream inputStream) + throws IOException, StreamCorruptedException { + super(inputStream); + this.classLoader = classLoader; + } + + /** + * Resolve a class specified by the descriptor using the + * specified ClassLoader or the super ClassLoader. + * + * @param objectStreamClass descriptor of the class + * @return the Class object described by the ObjectStreamClass + * @throws IOException in case of an I/O error + * @throws ClassNotFoundException if the Class cannot be found + */ + @Override + protected Class resolveClass(final ObjectStreamClass objectStreamClass) + throws IOException, ClassNotFoundException { + + try { + return Class.forName(objectStreamClass.getName(), false, classLoader); + } catch (ClassNotFoundException cnfe) { + // delegate to super class loader which can resolve primitives + return super.resolveClass(objectStreamClass); + } + } + + /** + * Create a proxy class that implements the specified interfaces using + * the specified ClassLoader or the super ClassLoader. + * + * @param interfaces the interfaces to implement + * @return a proxy class implementing the interfaces + * @throws IOException in case of an I/O error + * @throws ClassNotFoundException if the Class cannot be found + * @see java.io.ObjectInputStream#resolveProxyClass(java.lang.String[]) + * @since 2.1 + */ + @Override + protected Class resolveProxyClass(final String[] interfaces) throws IOException, + ClassNotFoundException { + final Class[] interfaceClasses = new Class[interfaces.length]; + for (int i = 0; i < interfaces.length; i++) { + interfaceClasses[i] = Class.forName(interfaces[i], false, classLoader); + } + try { + return Proxy.getProxyClass(classLoader, interfaceClasses); + } catch (final IllegalArgumentException e) { + return super.resolveProxyClass(interfaces); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CloseShieldInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CloseShieldInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..6dcd3b7901376dc9628bf3354ba5067cfa781ab4 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CloseShieldInputStream.java" @@ -0,0 +1,53 @@ +/* + * 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.input; + +import java.io.InputStream; + +/** + * Proxy stream that prevents the underlying input stream from being closed. + *

+ * This class is typically used in cases where an input stream needs to be + * passed to a component that wants to explicitly close the stream even if + * more input would still be available to other components. + * + * @version $Id: CloseShieldInputStream.java 1415850 2012-11-30 20:51:39Z ggregory $ + * @since 1.4 + */ +public class CloseShieldInputStream extends ProxyInputStream { + + /** + * Creates a proxy that shields the given input stream from being + * closed. + * + * @param in underlying input stream + */ + public CloseShieldInputStream(final InputStream in) { + super(in); + } + + /** + * Replaces the underlying input stream with a {@link ClosedInputStream} + * sentinel. The original input stream will remain open, but this proxy + * will appear closed. + */ + @Override + public void close() { + in = new ClosedInputStream(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ClosedInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ClosedInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..4230905ce1ec2f9a802cfcee77ff70448c5c2ea5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ClosedInputStream.java" @@ -0,0 +1,51 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.InputStream; + +/** + * Closed input stream. This stream returns EOF to all attempts to read + * something from the stream. + *

+ * Typically uses of this class include testing for corner cases in methods + * that accept input streams and acting as a sentinel value instead of a + * {@code null} input stream. + * + * @version $Id: ClosedInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $ + * @since 1.4 + */ +public class ClosedInputStream extends InputStream { + + /** + * A singleton. + */ + public static final ClosedInputStream CLOSED_INPUT_STREAM = new ClosedInputStream(); + + /** + * Returns -1 to indicate that the stream is closed. + * + * @return always -1 + */ + @Override + public int read() { + return EOF; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CountingInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CountingInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..6d01a4e0eeb584da9c331ceb6eb6e56f7d8ce9e1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/CountingInputStream.java" @@ -0,0 +1,145 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; + +/** + * A decorating input stream that counts the number of bytes that have passed + * through the stream so far. + *

+ * A typical use case would be during debugging, to ensure that data is being + * read as expected. + * + * @version $Id: CountingInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $ + */ +public class CountingInputStream extends ProxyInputStream { + + /** The count of bytes that have passed. */ + private long count; + + /** + * Constructs a new CountingInputStream. + * + * @param in the InputStream to delegate to + */ + public CountingInputStream(final InputStream in) { + super(in); + } + + //----------------------------------------------------------------------- + + /** + * Skips the stream over the specified number of bytes, adding the skipped + * amount to the count. + * + * @param length the number of bytes to skip + * @return the actual number of bytes skipped + * @throws IOException if an I/O error occurs + * @see java.io.InputStream#skip(long) + */ + @Override + public synchronized long skip(final long length) throws IOException { + final long skip = super.skip(length); + this.count += skip; + return skip; + } + + /** + * Adds the number of read bytes to the count. + * + * @param n number of bytes read, or -1 if no more bytes are available + * @since 2.0 + */ + @Override + protected synchronized void afterRead(final int n) { + if (n != EOF) { + this.count += n; + } + } + + //----------------------------------------------------------------------- + /** + * The number of bytes that have passed through this stream. + *

+ * NOTE: From v1.3 this method throws an ArithmeticException if the + * count is greater than can be expressed by an int. + * See {@link #getByteCount()} for a method using a long. + * + * @return the number of bytes accumulated + * @throws ArithmeticException if the byte count is too large + */ + public int getCount() { + final long result = getByteCount(); + if (result > Integer.MAX_VALUE) { + throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int"); + } + return (int) result; + } + + /** + * Set the byte count back to 0. + *

+ * NOTE: From v1.3 this method throws an ArithmeticException if the + * count is greater than can be expressed by an int. + * See {@link #resetByteCount()} for a method using a long. + * + * @return the count previous to resetting + * @throws ArithmeticException if the byte count is too large + */ + public int resetCount() { + final long result = resetByteCount(); + if (result > Integer.MAX_VALUE) { + throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int"); + } + return (int) result; + } + + /** + * The number of bytes that have passed through this stream. + *

+ * NOTE: This method is an alternative for getCount() + * and was added because that method returns an integer which will + * result in incorrect count for files over 2GB. + * + * @return the number of bytes accumulated + * @since 1.3 + */ + public synchronized long getByteCount() { + return this.count; + } + + /** + * Set the byte count back to 0. + *

+ * NOTE: This method is an alternative for resetCount() + * and was added because that method returns an integer which will + * result in incorrect count for files over 2GB. + * + * @return the count previous to resetting + * @since 1.3 + */ + public synchronized long resetByteCount() { + final long tmp = this.count; + this.count = 0; + return tmp; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/DemuxInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/DemuxInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..d4c31ed04c8bd1f7cdb10e2e51c6dd6070d7e745 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/DemuxInputStream.java" @@ -0,0 +1,84 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; + +/** + * Data written to this stream is forwarded to a stream that has been associated + * with this thread. + * + * @version $Id: DemuxInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $ + */ +public class DemuxInputStream + extends InputStream +{ + private final InheritableThreadLocal m_streams = new InheritableThreadLocal(); + + /** + * Bind the specified stream to the current thread. + * + * @param input the stream to bind + * @return the InputStream that was previously active + */ + public InputStream bindStream( final InputStream input ) + { + final InputStream oldValue = m_streams.get(); + m_streams.set( input ); + return oldValue; + } + + /** + * Closes stream associated with current thread. + * + * @throws IOException if an error occurs + */ + @Override + public void close() + throws IOException + { + final InputStream input = m_streams.get(); + if( null != input ) + { + input.close(); + } + } + + /** + * Read byte from stream associated with current thread. + * + * @return the byte read from stream + * @throws IOException if an error occurs + */ + @Override + public int read() + throws IOException + { + final InputStream input = m_streams.get(); + if( null != input ) + { + return input.read(); + } + else + { + return EOF; + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/NullInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/NullInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..e2911753a934d2aa7220d8ac2e2313332802b8b9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/NullInputStream.java" @@ -0,0 +1,340 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; + +/** + * A functional, light weight {@link InputStream} that emulates + * a stream of a specified size. + *

+ * This implementation provides a light weight + * object for testing with an {@link InputStream} + * where the contents don't matter. + *

+ * One use case would be for testing the handling of + * large {@link InputStream} as it can emulate that + * scenario without the overhead of actually processing + * large numbers of bytes - significantly speeding up + * test execution times. + *

+ * This implementation returns zero from the method that + * reads a byte and leaves the array unchanged in the read + * methods that are passed a byte array. + * If alternative data is required the processByte() and + * processBytes() methods can be implemented to generate + * data, for example: + * + *

+ *  public class TestInputStream extends NullInputStream {
+ *      public TestInputStream(int size) {
+ *          super(size);
+ *      }
+ *      protected int processByte() {
+ *          return ... // return required value here
+ *      }
+ *      protected void processBytes(byte[] bytes, int offset, int length) {
+ *          for (int i = offset; i < length; i++) {
+ *              bytes[i] = ... // set array value here
+ *          }
+ *      }
+ *  }
+ * 
+ * + * @since 1.3 + * @version $Id: NullInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $ + */ +public class NullInputStream extends InputStream { + + private final long size; + private long position; + private long mark = -1; + private long readlimit; + private boolean eof; + private final boolean throwEofException; + private final boolean markSupported; + + /** + * Create an {@link InputStream} that emulates a specified size + * which supports marking and does not throw EOFException. + * + * @param size The size of the input stream to emulate. + */ + public NullInputStream(final long size) { + this(size, true, false); + } + + /** + * Create an {@link InputStream} that emulates a specified + * size with option settings. + * + * @param size The size of the input stream to emulate. + * @param markSupported Whether this instance will support + * the mark() functionality. + * @param throwEofException Whether this implementation + * will throw an {@link EOFException} or return -1 when the + * end of file is reached. + */ + public NullInputStream(final long size, final boolean markSupported, final boolean throwEofException) { + this.size = size; + this.markSupported = markSupported; + this.throwEofException = throwEofException; + } + + /** + * Return the current position. + * + * @return the current position. + */ + public long getPosition() { + return position; + } + + /** + * Return the size this {@link InputStream} emulates. + * + * @return The size of the input stream to emulate. + */ + public long getSize() { + return size; + } + + /** + * Return the number of bytes that can be read. + * + * @return The number of bytes that can be read. + */ + @Override + public int available() { + final long avail = size - position; + if (avail <= 0) { + return 0; + } else if (avail > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else { + return (int)avail; + } + } + + /** + * Close this input stream - resets the internal state to + * the initial values. + * + * @throws IOException If an error occurs. + */ + @Override + public void close() throws IOException { + eof = false; + position = 0; + mark = -1; + } + + /** + * Mark the current position. + * + * @param readlimit The number of bytes before this marked position + * is invalid. + * @throws UnsupportedOperationException if mark is not supported. + */ + @Override + public synchronized void mark(final int readlimit) { + if (!markSupported) { + throw new UnsupportedOperationException("Mark not supported"); + } + mark = position; + this.readlimit = readlimit; + } + + /** + * Indicates whether mark is supported. + * + * @return Whether mark is supported or not. + */ + @Override + public boolean markSupported() { + return markSupported; + } + + /** + * Read a byte. + * + * @return Either The byte value returned by processByte() + * or -1 if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public int read() throws IOException { + if (eof) { + throw new IOException("Read after end of file"); + } + if (position == size) { + return doEndOfFile(); + } + position++; + return processByte(); + } + + /** + * Read some bytes into the specified array. + * + * @param bytes The byte array to read into + * @return The number of bytes read or -1 + * if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public int read(final byte[] bytes) throws IOException { + return read(bytes, 0, bytes.length); + } + + /** + * Read the specified number bytes into an array. + * + * @param bytes The byte array to read into. + * @param offset The offset to start reading bytes into. + * @param length The number of bytes to read. + * @return The number of bytes read or -1 + * if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public int read(final byte[] bytes, final int offset, final int length) throws IOException { + if (eof) { + throw new IOException("Read after end of file"); + } + if (position == size) { + return doEndOfFile(); + } + position += length; + int returnLength = length; + if (position > size) { + returnLength = length - (int)(position - size); + position = size; + } + processBytes(bytes, offset, returnLength); + return returnLength; + } + + /** + * Reset the stream to the point when mark was last called. + * + * @throws UnsupportedOperationException if mark is not supported. + * @throws IOException If no position has been marked + * or the read limit has been exceed since the last position was + * marked. + */ + @Override + public synchronized void reset() throws IOException { + if (!markSupported) { + throw new UnsupportedOperationException("Mark not supported"); + } + if (mark < 0) { + throw new IOException("No position has been marked"); + } + if (position > mark + readlimit) { + throw new IOException("Marked position [" + mark + + "] is no longer valid - passed the read limit [" + + readlimit + "]"); + } + position = mark; + eof = false; + } + + /** + * Skip a specified number of bytes. + * + * @param numberOfBytes The number of bytes to skip. + * @return The number of bytes skipped or -1 + * if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public long skip(final long numberOfBytes) throws IOException { + if (eof) { + throw new IOException("Skip after end of file"); + } + if (position == size) { + return doEndOfFile(); + } + position += numberOfBytes; + long returnLength = numberOfBytes; + if (position > size) { + returnLength = numberOfBytes - (position - size); + position = size; + } + return returnLength; + } + + /** + * Return a byte value for the read() method. + *

+ * This implementation returns zero. + * + * @return This implementation always returns zero. + */ + protected int processByte() { + // do nothing - overridable by subclass + return 0; + } + + /** + * Process the bytes for the read(byte[], offset, length) + * method. + *

+ * This implementation leaves the byte array unchanged. + * + * @param bytes The byte array + * @param offset The offset to start at. + * @param length The number of bytes. + */ + protected void processBytes(final byte[] bytes, final int offset, final int length) { + // do nothing - overridable by subclass + } + + /** + * Handle End of File. + * + * @return -1 if throwEofException is + * set to {@code false} + * @throws EOFException if throwEofException is set + * to {@code true}. + */ + private int doEndOfFile() throws EOFException { + eof = true; + if (throwEofException) { + throw new EOFException(); + } + return EOF; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/NullReader.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/NullReader.java" new file mode 100644 index 0000000000000000000000000000000000000000..d7c7cd7d004550592ce76592d41ed8705e7fd1e4 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/NullReader.java" @@ -0,0 +1,323 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.EOFException; +import java.io.IOException; +import java.io.Reader; + +/** + * A functional, light weight {@link Reader} that emulates + * a reader of a specified size. + *

+ * This implementation provides a light weight + * object for testing with an {@link Reader} + * where the contents don't matter. + *

+ * One use case would be for testing the handling of + * large {@link Reader} as it can emulate that + * scenario without the overhead of actually processing + * large numbers of characters - significantly speeding up + * test execution times. + *

+ * This implementation returns a space from the method that + * reads a character and leaves the array unchanged in the read + * methods that are passed a character array. + * If alternative data is required the processChar() and + * processChars() methods can be implemented to generate + * data, for example: + * + *

+ *  public class TestReader extends NullReader {
+ *      public TestReader(int size) {
+ *          super(size);
+ *      }
+ *      protected char processChar() {
+ *          return ... // return required value here
+ *      }
+ *      protected void processChars(char[] chars, int offset, int length) {
+ *          for (int i = offset; i < length; i++) {
+ *              chars[i] = ... // set array value here
+ *          }
+ *      }
+ *  }
+ * 
+ * + * @since 1.3 + * @version $Id: NullReader.java 1586350 2014-04-10 15:57:20Z ggregory $ + */ +public class NullReader extends Reader { + + private final long size; + private long position; + private long mark = -1; + private long readlimit; + private boolean eof; + private final boolean throwEofException; + private final boolean markSupported; + + /** + * Create a {@link Reader} that emulates a specified size + * which supports marking and does not throw EOFException. + * + * @param size The size of the reader to emulate. + */ + public NullReader(final long size) { + this(size, true, false); + } + + /** + * Create a {@link Reader} that emulates a specified + * size with option settings. + * + * @param size The size of the reader to emulate. + * @param markSupported Whether this instance will support + * the mark() functionality. + * @param throwEofException Whether this implementation + * will throw an {@link EOFException} or return -1 when the + * end of file is reached. + */ + public NullReader(final long size, final boolean markSupported, final boolean throwEofException) { + this.size = size; + this.markSupported = markSupported; + this.throwEofException = throwEofException; + } + + /** + * Return the current position. + * + * @return the current position. + */ + public long getPosition() { + return position; + } + + /** + * Return the size this {@link Reader} emulates. + * + * @return The size of the reader to emulate. + */ + public long getSize() { + return size; + } + + /** + * Close this Reader - resets the internal state to + * the initial values. + * + * @throws IOException If an error occurs. + */ + @Override + public void close() throws IOException { + eof = false; + position = 0; + mark = -1; + } + + /** + * Mark the current position. + * + * @param readlimit The number of characters before this marked position + * is invalid. + * @throws UnsupportedOperationException if mark is not supported. + */ + @Override + public synchronized void mark(final int readlimit) { + if (!markSupported) { + throw new UnsupportedOperationException("Mark not supported"); + } + mark = position; + this.readlimit = readlimit; + } + + /** + * Indicates whether mark is supported. + * + * @return Whether mark is supported or not. + */ + @Override + public boolean markSupported() { + return markSupported; + } + + /** + * Read a character. + * + * @return Either The character value returned by processChar() + * or -1 if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public int read() throws IOException { + if (eof) { + throw new IOException("Read after end of file"); + } + if (position == size) { + return doEndOfFile(); + } + position++; + return processChar(); + } + + /** + * Read some characters into the specified array. + * + * @param chars The character array to read into + * @return The number of characters read or -1 + * if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public int read(final char[] chars) throws IOException { + return read(chars, 0, chars.length); + } + + /** + * Read the specified number characters into an array. + * + * @param chars The character array to read into. + * @param offset The offset to start reading characters into. + * @param length The number of characters to read. + * @return The number of characters read or -1 + * if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public int read(final char[] chars, final int offset, final int length) throws IOException { + if (eof) { + throw new IOException("Read after end of file"); + } + if (position == size) { + return doEndOfFile(); + } + position += length; + int returnLength = length; + if (position > size) { + returnLength = length - (int)(position - size); + position = size; + } + processChars(chars, offset, returnLength); + return returnLength; + } + + /** + * Reset the stream to the point when mark was last called. + * + * @throws UnsupportedOperationException if mark is not supported. + * @throws IOException If no position has been marked + * or the read limit has been exceed since the last position was + * marked. + */ + @Override + public synchronized void reset() throws IOException { + if (!markSupported) { + throw new UnsupportedOperationException("Mark not supported"); + } + if (mark < 0) { + throw new IOException("No position has been marked"); + } + if (position > mark + readlimit) { + throw new IOException("Marked position [" + mark + + "] is no longer valid - passed the read limit [" + + readlimit + "]"); + } + position = mark; + eof = false; + } + + /** + * Skip a specified number of characters. + * + * @param numberOfChars The number of characters to skip. + * @return The number of characters skipped or -1 + * if the end of file has been reached and + * throwEofException is set to {@code false}. + * @throws EOFException if the end of file is reached and + * throwEofException is set to {@code true}. + * @throws IOException if trying to read past the end of file. + */ + @Override + public long skip(final long numberOfChars) throws IOException { + if (eof) { + throw new IOException("Skip after end of file"); + } + if (position == size) { + return doEndOfFile(); + } + position += numberOfChars; + long returnLength = numberOfChars; + if (position > size) { + returnLength = numberOfChars - (position - size); + position = size; + } + return returnLength; + } + + /** + * Return a character value for the read() method. + *

+ * This implementation returns zero. + * + * @return This implementation always returns zero. + */ + protected int processChar() { + // do nothing - overridable by subclass + return 0; + } + + /** + * Process the characters for the read(char[], offset, length) + * method. + *

+ * This implementation leaves the character array unchanged. + * + * @param chars The character array + * @param offset The offset to start at. + * @param length The number of characters. + */ + protected void processChars(final char[] chars, final int offset, final int length) { + // do nothing - overridable by subclass + } + + /** + * Handle End of File. + * + * @return -1 if throwEofException is + * set to {@code false} + * @throws EOFException if throwEofException is set + * to {@code true}. + */ + private int doEndOfFile() throws EOFException { + eof = true; + if (throwEofException) { + throw new EOFException(); + } + return EOF; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ProxyInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ProxyInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..e5614f239683f84d88711a608006c0e3b27e81b3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ProxyInputStream.java" @@ -0,0 +1,240 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * A Proxy stream which acts as expected, that is it passes the method + * calls on to the proxied stream and doesn't change which methods are + * being called. + *

+ * It is an alternative base class to FilterInputStream + * to increase reusability, because FilterInputStream changes the + * methods being called, such as read(byte[]) to read(byte[], int, int). + *

+ * See the protected methods for ways in which a subclass can easily decorate + * a stream with custom pre-, post- or error processing functionality. + * + * @version $Id: ProxyInputStream.java 1603493 2014-06-18 15:46:07Z ggregory $ + */ +public abstract class ProxyInputStream extends FilterInputStream { + + /** + * Constructs a new ProxyInputStream. + * + * @param proxy the InputStream to delegate to + */ + public ProxyInputStream(final InputStream proxy) { + super(proxy); + // the proxy is stored in a protected superclass variable named 'in' + } + + /** + * Invokes the delegate's read() method. + * @return the byte read or -1 if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public int read() throws IOException { + try { + beforeRead(1); + final int b = in.read(); + afterRead(b != EOF ? 1 : EOF); + return b; + } catch (final IOException e) { + handleIOException(e); + return EOF; + } + } + + /** + * Invokes the delegate's read(byte[]) method. + * @param bts the buffer to read the bytes into + * @return the number of bytes read or EOF if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final byte[] bts) throws IOException { + try { + beforeRead(bts != null ? bts.length : 0); + final int n = in.read(bts); + afterRead(n); + return n; + } catch (final IOException e) { + handleIOException(e); + return EOF; + } + } + + /** + * Invokes the delegate's read(byte[], int, int) method. + * @param bts the buffer to read the bytes into + * @param off The start offset + * @param len The number of bytes to read + * @return the number of bytes read or -1 if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final byte[] bts, final int off, final int len) throws IOException { + try { + beforeRead(len); + final int n = in.read(bts, off, len); + afterRead(n); + return n; + } catch (final IOException e) { + handleIOException(e); + return EOF; + } + } + + /** + * Invokes the delegate's skip(long) method. + * @param ln the number of bytes to skip + * @return the actual number of bytes skipped + * @throws IOException if an I/O error occurs + */ + @Override + public long skip(final long ln) throws IOException { + try { + return in.skip(ln); + } catch (final IOException e) { + handleIOException(e); + return 0; + } + } + + /** + * Invokes the delegate's available() method. + * @return the number of available bytes + * @throws IOException if an I/O error occurs + */ + @Override + public int available() throws IOException { + try { + return super.available(); + } catch (final IOException e) { + handleIOException(e); + return 0; + } + } + + /** + * Invokes the delegate's close() method. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + try { + in.close(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's mark(int) method. + * @param readlimit read ahead limit + */ + @Override + public synchronized void mark(final int readlimit) { + in.mark(readlimit); + } + + /** + * Invokes the delegate's reset() method. + * @throws IOException if an I/O error occurs + */ + @Override + public synchronized void reset() throws IOException { + try { + in.reset(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's markSupported() method. + * @return true if mark is supported, otherwise false + */ + @Override + public boolean markSupported() { + return in.markSupported(); + } + + /** + * Invoked by the read methods before the call is proxied. The number + * of bytes that the caller wanted to read (1 for the {@link #read()} + * method, buffer length for {@link #read(byte[])}, etc.) is given as + * an argument. + *

+ * Subclasses can override this method to add common pre-processing + * functionality without having to override all the read methods. + * The default implementation does nothing. + *

+ * Note this method is not called from {@link #skip(long)} or + * {@link #reset()}. You need to explicitly override those methods if + * you want to add pre-processing steps also to them. + * + * @since 2.0 + * @param n number of bytes that the caller asked to be read + * @throws IOException if the pre-processing fails + */ + protected void beforeRead(final int n) throws IOException { + // no-op + } + + /** + * Invoked by the read methods after the proxied call has returned + * successfully. The number of bytes returned to the caller (or -1 if + * the end of stream was reached) is given as an argument. + *

+ * Subclasses can override this method to add common post-processing + * functionality without having to override all the read methods. + * The default implementation does nothing. + *

+ * Note this method is not called from {@link #skip(long)} or + * {@link #reset()}. You need to explicitly override those methods if + * you want to add post-processing steps also to them. + * + * @since 2.0 + * @param n number of bytes read, or -1 if the end of stream was reached + * @throws IOException if the post-processing fails + */ + protected void afterRead(final int n) throws IOException { + // no-op + } + + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + protected void handleIOException(final IOException e) throws IOException { + throw e; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ProxyReader.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ProxyReader.java" new file mode 100644 index 0000000000000000000000000000000000000000..b8cb9a9bb2e9908b607b42a60e6a02562a762958 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ProxyReader.java" @@ -0,0 +1,261 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.FilterReader; +import java.io.IOException; +import java.io.Reader; +import java.nio.CharBuffer; + +/** + * A Proxy stream which acts as expected, that is it passes the method + * calls on to the proxied stream and doesn't change which methods are + * being called. + *

+ * It is an alternative base class to FilterReader + * to increase reusability, because FilterReader changes the + * methods being called, such as read(char[]) to read(char[], int, int). + * + * @version $Id: ProxyReader.java 1586350 2014-04-10 15:57:20Z ggregory $ + */ +public abstract class ProxyReader extends FilterReader { + + /** + * Constructs a new ProxyReader. + * + * @param proxy the Reader to delegate to + */ + public ProxyReader(final Reader proxy) { + super(proxy); + // the proxy is stored in a protected superclass variable named 'in' + } + + /** + * Invokes the delegate's read() method. + * @return the character read or -1 if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public int read() throws IOException { + try { + beforeRead(1); + final int c = in.read(); + afterRead(c != EOF ? 1 : EOF); + return c; + } catch (final IOException e) { + handleIOException(e); + return EOF; + } + } + + /** + * Invokes the delegate's read(char[]) method. + * @param chr the buffer to read the characters into + * @return the number of characters read or -1 if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final char[] chr) throws IOException { + try { + beforeRead(chr != null ? chr.length : 0); + final int n = in.read(chr); + afterRead(n); + return n; + } catch (final IOException e) { + handleIOException(e); + return EOF; + } + } + + /** + * Invokes the delegate's read(char[], int, int) method. + * @param chr the buffer to read the characters into + * @param st The start offset + * @param len The number of bytes to read + * @return the number of characters read or -1 if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final char[] chr, final int st, final int len) throws IOException { + try { + beforeRead(len); + final int n = in.read(chr, st, len); + afterRead(n); + return n; + } catch (final IOException e) { + handleIOException(e); + return EOF; + } + } + + /** + * Invokes the delegate's read(CharBuffer) method. + * @param target the char buffer to read the characters into + * @return the number of characters read or -1 if the end of stream + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + @Override + public int read(final CharBuffer target) throws IOException { + try { + beforeRead(target != null ? target.length() : 0); + final int n = in.read(target); + afterRead(n); + return n; + } catch (final IOException e) { + handleIOException(e); + return EOF; + } + } + + /** + * Invokes the delegate's skip(long) method. + * @param ln the number of bytes to skip + * @return the number of bytes to skipped or EOF if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public long skip(final long ln) throws IOException { + try { + return in.skip(ln); + } catch (final IOException e) { + handleIOException(e); + return 0; + } + } + + /** + * Invokes the delegate's ready() method. + * @return true if the stream is ready to be read + * @throws IOException if an I/O error occurs + */ + @Override + public boolean ready() throws IOException { + try { + return in.ready(); + } catch (final IOException e) { + handleIOException(e); + return false; + } + } + + /** + * Invokes the delegate's close() method. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + try { + in.close(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's mark(int) method. + * @param idx read ahead limit + * @throws IOException if an I/O error occurs + */ + @Override + public synchronized void mark(final int idx) throws IOException { + try { + in.mark(idx); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's reset() method. + * @throws IOException if an I/O error occurs + */ + @Override + public synchronized void reset() throws IOException { + try { + in.reset(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's markSupported() method. + * @return true if mark is supported, otherwise false + */ + @Override + public boolean markSupported() { + return in.markSupported(); + } + + /** + * Invoked by the read methods before the call is proxied. The number + * of chars that the caller wanted to read (1 for the {@link #read()} + * method, buffer length for {@link #read(char[])}, etc.) is given as + * an argument. + *

+ * Subclasses can override this method to add common pre-processing + * functionality without having to override all the read methods. + * The default implementation does nothing. + *

+ * Note this method is not called from {@link #skip(long)} or + * {@link #reset()}. You need to explicitly override those methods if + * you want to add pre-processing steps also to them. + * + * @since 2.0 + * @param n number of chars that the caller asked to be read + * @throws IOException if the pre-processing fails + */ + protected void beforeRead(final int n) throws IOException { + } + + /** + * Invoked by the read methods after the proxied call has returned + * successfully. The number of chars returned to the caller (or -1 if + * the end of stream was reached) is given as an argument. + *

+ * Subclasses can override this method to add common post-processing + * functionality without having to override all the read methods. + * The default implementation does nothing. + *

+ * Note this method is not called from {@link #skip(long)} or + * {@link #reset()}. You need to explicitly override those methods if + * you want to add post-processing steps also to them. + * + * @since 2.0 + * @param n number of chars read, or -1 if the end of stream was reached + * @throws IOException if the post-processing fails + */ + protected void afterRead(final int n) throws IOException { + } + + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + protected void handleIOException(final IOException e) throws IOException { + throw e; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ReaderInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ReaderInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..b8e151fc6b407278491e904205fa2bcdd301e4dc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ReaderInputStream.java" @@ -0,0 +1,297 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; +import java.nio.charset.CoderResult; +import java.nio.charset.CodingErrorAction; + +/** + * {@link InputStream} implementation that reads a character stream from a {@link Reader} + * and transforms it to a byte stream using a specified charset encoding. The stream + * is transformed using a {@link CharsetEncoder} object, guaranteeing that all charset + * encodings supported by the JRE are handled correctly. In particular for charsets such as + * UTF-16, the implementation ensures that one and only one byte order marker + * is produced. + *

+ * Since in general it is not possible to predict the number of characters to be read from the + * {@link Reader} to satisfy a read request on the {@link ReaderInputStream}, all reads from + * the {@link Reader} are buffered. There is therefore no well defined correlation + * between the current position of the {@link Reader} and that of the {@link ReaderInputStream}. + * This also implies that in general there is no need to wrap the underlying {@link Reader} + * in a {@link java.io.BufferedReader}. + *

+ * {@link ReaderInputStream} implements the inverse transformation of {@link java.io.InputStreamReader}; + * in the following example, reading from {@code in2} would return the same byte + * sequence as reading from {@code in} (provided that the initial byte sequence is legal + * with respect to the charset encoding): + *

+ * InputStream in = ...
+ * Charset cs = ...
+ * InputStreamReader reader = new InputStreamReader(in, cs);
+ * ReaderInputStream in2 = new ReaderInputStream(reader, cs);
+ * {@link ReaderInputStream} implements the same transformation as {@link java.io.OutputStreamWriter}, + * except that the control flow is reversed: both classes transform a character stream + * into a byte stream, but {@link java.io.OutputStreamWriter} pushes data to the underlying stream, + * while {@link ReaderInputStream} pulls it from the underlying stream. + *

+ * Note that while there are use cases where there is no alternative to using + * this class, very often the need to use this class is an indication of a flaw + * in the design of the code. This class is typically used in situations where an existing + * API only accepts an {@link InputStream}, but where the most natural way to produce the data + * is as a character stream, i.e. by providing a {@link Reader} instance. An example of a situation + * where this problem may appear is when implementing the {@link javax.activation.DataSource} + * interface from the Java Activation Framework. + *

+ * Given the fact that the {@link Reader} class doesn't provide any way to predict whether the next + * read operation will block or not, it is not possible to provide a meaningful + * implementation of the {@link InputStream#available()} method. A call to this method + * will always return 0. Also, this class doesn't support {@link InputStream#mark(int)}. + *

+ * Instances of {@link ReaderInputStream} are not thread safe. + * + * @see org.apache.commons.io.output.WriterOutputStream + * + * @since 2.0 + */ +public class ReaderInputStream extends InputStream { + private static final int DEFAULT_BUFFER_SIZE = 1024; + + private final Reader reader; + private final CharsetEncoder encoder; + + /** + * CharBuffer used as input for the decoder. It should be reasonably + * large as we read data from the underlying Reader into this buffer. + */ + private final CharBuffer encoderIn; + + /** + * ByteBuffer used as output for the decoder. This buffer can be small + * as it is only used to transfer data from the decoder to the + * buffer provided by the caller. + */ + private final ByteBuffer encoderOut; + + private CoderResult lastCoderResult; + private boolean endOfInput; + + /** + * Construct a new {@link ReaderInputStream}. + * + * @param reader the target {@link Reader} + * @param encoder the charset encoder + * @since 2.1 + */ + public ReaderInputStream(final Reader reader, final CharsetEncoder encoder) { + this(reader, encoder, DEFAULT_BUFFER_SIZE); + } + + /** + * Construct a new {@link ReaderInputStream}. + * + * @param reader the target {@link Reader} + * @param encoder the charset encoder + * @param bufferSize the size of the input buffer in number of characters + * @since 2.1 + */ + public ReaderInputStream(final Reader reader, final CharsetEncoder encoder, final int bufferSize) { + this.reader = reader; + this.encoder = encoder; + this.encoderIn = CharBuffer.allocate(bufferSize); + this.encoderIn.flip(); + this.encoderOut = ByteBuffer.allocate(128); + this.encoderOut.flip(); + } + + /** + * Construct a new {@link ReaderInputStream}. + * + * @param reader the target {@link Reader} + * @param charset the charset encoding + * @param bufferSize the size of the input buffer in number of characters + */ + public ReaderInputStream(final Reader reader, final Charset charset, final int bufferSize) { + this(reader, + charset.newEncoder() + .onMalformedInput(CodingErrorAction.REPLACE) + .onUnmappableCharacter(CodingErrorAction.REPLACE), + bufferSize); + } + + /** + * Construct a new {@link ReaderInputStream} with a default input buffer size of + * 1024 characters. + * + * @param reader the target {@link Reader} + * @param charset the charset encoding + */ + public ReaderInputStream(final Reader reader, final Charset charset) { + this(reader, charset, DEFAULT_BUFFER_SIZE); + } + + /** + * Construct a new {@link ReaderInputStream}. + * + * @param reader the target {@link Reader} + * @param charsetName the name of the charset encoding + * @param bufferSize the size of the input buffer in number of characters + */ + public ReaderInputStream(final Reader reader, final String charsetName, final int bufferSize) { + this(reader, Charset.forName(charsetName), bufferSize); + } + + /** + * Construct a new {@link ReaderInputStream} with a default input buffer size of + * 1024 characters. + * + * @param reader the target {@link Reader} + * @param charsetName the name of the charset encoding + */ + public ReaderInputStream(final Reader reader, final String charsetName) { + this(reader, charsetName, DEFAULT_BUFFER_SIZE); + } + + /** + * Construct a new {@link ReaderInputStream} that uses the default character encoding + * with a default input buffer size of 1024 characters. + * + * @param reader the target {@link Reader} + * @deprecated 2.5 use {@link #ReaderInputStream(Reader, Charset)} instead + */ + @Deprecated + public ReaderInputStream(final Reader reader) { + this(reader, Charset.defaultCharset()); + } + + /** + * Fills the internal char buffer from the reader. + * + * @throws IOException + * If an I/O error occurs + */ + private void fillBuffer() throws IOException { + if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) { + encoderIn.compact(); + final int position = encoderIn.position(); + // We don't use Reader#read(CharBuffer) here because it is more efficient + // to write directly to the underlying char array (the default implementation + // copies data to a temporary char array). + final int c = reader.read(encoderIn.array(), position, encoderIn.remaining()); + if (c == EOF) { + endOfInput = true; + } else { + encoderIn.position(position+c); + } + encoderIn.flip(); + } + encoderOut.compact(); + lastCoderResult = encoder.encode(encoderIn, encoderOut, endOfInput); + encoderOut.flip(); + } + + /** + * Read the specified number of bytes into an array. + * + * @param b the byte array to read into + * @param off the offset to start reading bytes into + * @param len the number of bytes to read + * @return the number of bytes read or -1 + * if the end of the stream has been reached + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final byte[] b, int off, int len) throws IOException { + if (b == null) { + throw new NullPointerException("Byte array must not be null"); + } + if (len < 0 || off < 0 || (off + len) > b.length) { + throw new IndexOutOfBoundsException("Array Size=" + b.length + + ", offset=" + off + ", length=" + len); + } + int read = 0; + if (len == 0) { + return 0; // Always return 0 if len == 0 + } + while (len > 0) { + if (encoderOut.hasRemaining()) { + final int c = Math.min(encoderOut.remaining(), len); + encoderOut.get(b, off, c); + off += c; + len -= c; + read += c; + } else { + fillBuffer(); + if (endOfInput && !encoderOut.hasRemaining()) { + break; + } + } + } + return read == 0 && endOfInput ? EOF : read; + } + + /** + * Read the specified number of bytes into an array. + * + * @param b the byte array to read into + * @return the number of bytes read or -1 + * if the end of the stream has been reached + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final byte[] b) throws IOException { + return read(b, 0, b.length); + } + + /** + * Read a single byte. + * + * @return either the byte read or -1 if the end of the stream + * has been reached + * @throws IOException if an I/O error occurs + */ + @Override + public int read() throws IOException { + for (;;) { + if (encoderOut.hasRemaining()) { + return encoderOut.get() & 0xFF; + } + fillBuffer(); + if (endOfInput && !encoderOut.hasRemaining()) { + return EOF; + } + } + } + + /** + * Close the stream. This method will cause the underlying {@link Reader} + * to be closed. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + reader.close(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java" new file mode 100644 index 0000000000000000000000000000000000000000..7522d84f46fbf43e7489d39986bba648a17e3d04 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/ReversedLinesFileReader.java" @@ -0,0 +1,365 @@ +/* + * 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.input; + +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; + +import org.apache.commons.io.Charsets; + +/** + * Reads lines in a file reversely (similar to a BufferedReader, but starting at + * the last line). Useful for e.g. searching in log files. + * + * @since 2.2 + */ +public class ReversedLinesFileReader implements Closeable { + + private final int blockSize; + private final Charset encoding; + + private final RandomAccessFile randomAccessFile; + + private final long totalByteLength; + private final long totalBlockCount; + + private final byte[][] newLineSequences; + private final int avoidNewlineSplitBufferSize; + private final int byteDecrement; + + private FilePart currentFilePart; + + private boolean trailingNewlineOfFileSkipped = false; + + /** + * Creates a ReversedLinesFileReader with default block size of 4KB and the + * platform's default encoding. + * + * @param file + * the file to be read + * @throws IOException if an I/O error occurs + * @deprecated 2.5 use {@link #ReversedLinesFileReader(File, Charset)} instead + */ + @Deprecated + public ReversedLinesFileReader(final File file) throws IOException { + this(file, 4096, Charset.defaultCharset()); + } + + /** + * Creates a ReversedLinesFileReader with default block size of 4KB and the + * specified encoding. + * + * @param file + * the file to be read + * @param charset the encoding to use + * @throws IOException if an I/O error occurs + * @since 2.5 + */ + public ReversedLinesFileReader(final File file, final Charset charset) throws IOException { + this(file, 4096, charset); + } + + /** + * Creates a ReversedLinesFileReader with the given block size and encoding. + * + * @param file + * the file to be read + * @param blockSize + * size of the internal buffer (for ideal performance this should + * match with the block size of the underlying file system). + * @param encoding + * the encoding of the file + * @throws IOException if an I/O error occurs + * @since 2.3 + */ + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public ReversedLinesFileReader(final File file, final int blockSize, final Charset encoding) throws IOException { + this.blockSize = blockSize; + this.encoding = encoding; + + // --- check & prepare encoding --- + final Charset charset = Charsets.toCharset(encoding); + final CharsetEncoder charsetEncoder = charset.newEncoder(); + final float maxBytesPerChar = charsetEncoder.maxBytesPerChar(); + if (maxBytesPerChar == 1f) { + // all one byte encodings are no problem + byteDecrement = 1; + } else if (charset == Charsets.UTF_8) { + // UTF-8 works fine out of the box, for multibyte sequences a second UTF-8 byte can never be a newline byte + // http://en.wikipedia.org/wiki/UTF-8 + byteDecrement = 1; + } else if(charset == Charset.forName("Shift_JIS") || // Same as for UTF-8 + // http://www.herongyang.com/Unicode/JIS-Shift-JIS-Encoding.html + charset == Charset.forName("windows-31j") || // Windows code page 932 (Japanese) + charset == Charset.forName("x-windows-949") || // Windows code page 949 (Korean) + charset == Charset.forName("gbk") || // Windows code page 936 (Simplified Chinese) + charset == Charset.forName("x-windows-950")) { // Windows code page 950 (Traditional Chinese) + byteDecrement = 1; + } else if (charset == Charsets.UTF_16BE || charset == Charsets.UTF_16LE) { + // UTF-16 new line sequences are not allowed as second tuple of four byte sequences, + // however byte order has to be specified + byteDecrement = 2; + } else if (charset == Charsets.UTF_16) { + throw new UnsupportedEncodingException("For UTF-16, you need to specify the byte order (use UTF-16BE or " + + "UTF-16LE)"); + } else { + throw new UnsupportedEncodingException("Encoding " + encoding + " is not supported yet (feel free to " + + "submit a patch)"); + } + + // NOTE: The new line sequences are matched in the order given, so it is important that \r\n is BEFORE \n + newLineSequences = new byte[][] { "\r\n".getBytes(encoding), "\n".getBytes(encoding), "\r".getBytes(encoding) }; + + avoidNewlineSplitBufferSize = newLineSequences[0].length; + + // Open file + randomAccessFile = new RandomAccessFile(file, "r"); + totalByteLength = randomAccessFile.length(); + int lastBlockLength = (int) (totalByteLength % blockSize); + if (lastBlockLength > 0) { + totalBlockCount = totalByteLength / blockSize + 1; + } else { + totalBlockCount = totalByteLength / blockSize; + if (totalByteLength > 0) { + lastBlockLength = blockSize; + } + } + currentFilePart = new FilePart(totalBlockCount, lastBlockLength, null); + + } + + /** + * Creates a ReversedLinesFileReader with the given block size and encoding. + * + * @param file + * the file to be read + * @param blockSize + * size of the internal buffer (for ideal performance this should + * match with the block size of the underlying file system). + * @param encoding + * the encoding of the file + * @throws IOException if an I/O error occurs + * @throws java.nio.charset.UnsupportedCharsetException thrown instead of {@link UnsupportedEncodingException} in + * version 2.2 if the encoding is not supported. + */ + public ReversedLinesFileReader(final File file, final int blockSize, final String encoding) throws IOException { + this(file, blockSize, Charsets.toCharset(encoding)); + } + + /** + * Returns the lines of the file from bottom to top. + * + * @return the next line or null if the start of the file is reached + * @throws IOException if an I/O error occurs + */ + public String readLine() throws IOException { + + String line = currentFilePart.readLine(); + while (line == null) { + currentFilePart = currentFilePart.rollOver(); + if (currentFilePart != null) { + line = currentFilePart.readLine(); + } else { + // no more fileparts: we're done, leave line set to null + break; + } + } + + // aligned behaviour with BufferedReader that doesn't return a last, empty line + if("".equals(line) && !trailingNewlineOfFileSkipped) { + trailingNewlineOfFileSkipped = true; + line = readLine(); + } + + return line; + } + + /** + * Closes underlying resources. + * + * @throws IOException if an I/O error occurs + */ + public void close() throws IOException { + randomAccessFile.close(); + } + + private class FilePart { + private final long no; + + private final byte[] data; + + private byte[] leftOver; + + private int currentLastBytePos; + + /** + * ctor + * @param no the part number + * @param length its length + * @param leftOverOfLastFilePart remainder + * @throws IOException if there is a problem reading the file + */ + private FilePart(final long no, final int length, final byte[] leftOverOfLastFilePart) throws IOException { + this.no = no; + final int dataLength = length + (leftOverOfLastFilePart != null ? leftOverOfLastFilePart.length : 0); + this.data = new byte[dataLength]; + final long off = (no - 1) * blockSize; + + // read data + if (no > 0 /* file not empty */) { + randomAccessFile.seek(off); + final int countRead = randomAccessFile.read(data, 0, length); + if (countRead != length) { + throw new IllegalStateException("Count of requested bytes and actually read bytes don't match"); + } + } + // copy left over part into data arr + if (leftOverOfLastFilePart != null) { + System.arraycopy(leftOverOfLastFilePart, 0, data, length, leftOverOfLastFilePart.length); + } + this.currentLastBytePos = data.length - 1; + this.leftOver = null; + } + + /** + * Handles block rollover + * + * @return the new FilePart or null + * @throws IOException if there was a problem reading the file + */ + private FilePart rollOver() throws IOException { + + if (currentLastBytePos > -1) { + throw new IllegalStateException("Current currentLastCharPos unexpectedly positive... " + + "last readLine() should have returned something! currentLastCharPos=" + currentLastBytePos); + } + + if (no > 1) { + return new FilePart(no - 1, blockSize, leftOver); + } else { + // NO 1 was the last FilePart, we're finished + if (leftOver != null) { + throw new IllegalStateException("Unexpected leftover of the last block: leftOverOfThisFilePart=" + + new String(leftOver, encoding)); + } + return null; + } + } + + /** + * Reads a line. + * + * @return the line or null + * @throws IOException if there is an error reading from the file + */ + private String readLine() throws IOException { + + String line = null; + int newLineMatchByteCount; + + final boolean isLastFilePart = no == 1; + + int i = currentLastBytePos; + while (i > -1) { + + if (!isLastFilePart && i < avoidNewlineSplitBufferSize) { + // avoidNewlineSplitBuffer: for all except the last file part we + // take a few bytes to the next file part to avoid splitting of newlines + createLeftOver(); + break; // skip last few bytes and leave it to the next file part + } + + // --- check for newline --- + if ((newLineMatchByteCount = getNewLineMatchByteCount(data, i)) > 0 /* found newline */) { + final int lineStart = i + 1; + final int lineLengthBytes = currentLastBytePos - lineStart + 1; + + if (lineLengthBytes < 0) { + throw new IllegalStateException("Unexpected negative line length="+lineLengthBytes); + } + final byte[] lineData = new byte[lineLengthBytes]; + System.arraycopy(data, lineStart, lineData, 0, lineLengthBytes); + + line = new String(lineData, encoding); + + currentLastBytePos = i - newLineMatchByteCount; + break; // found line + } + + // --- move cursor --- + i -= byteDecrement; + + // --- end of file part handling --- + if (i < 0) { + createLeftOver(); + break; // end of file part + } + } + + // --- last file part handling --- + if (isLastFilePart && leftOver != null) { + // there will be no line break anymore, this is the first line of the file + line = new String(leftOver, encoding); + leftOver = null; + } + + return line; + } + + /** + * Creates the buffer containing any left over bytes. + */ + private void createLeftOver() { + final int lineLengthBytes = currentLastBytePos + 1; + if (lineLengthBytes > 0) { + // create left over for next block + leftOver = new byte[lineLengthBytes]; + System.arraycopy(data, 0, leftOver, 0, lineLengthBytes); + } else { + leftOver = null; + } + currentLastBytePos = -1; + } + + /** + * Finds the new-line sequence and return its length. + * + * @param data buffer to scan + * @param i start offset in buffer + * @return length of newline sequence or 0 if none found + */ + private int getNewLineMatchByteCount(final byte[] data, final int i) { + for (final byte[] newLineSequence : newLineSequences) { + boolean match = true; + for (int j = newLineSequence.length - 1; j >= 0; j--) { + final int k = i + j - (newLineSequence.length - 1); + match &= k >= 0 && data[k] == newLineSequence[j]; + } + if (match) { + return newLineSequence.length; + } + } + return 0; + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..bde5bebd98ca7530460bd334efa524291628f23a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/SwappedDataInputStream.java" @@ -0,0 +1,252 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.DataInput; +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.commons.io.EndianUtils; + +/** + * DataInput for systems relying on little endian data formats. + * When read, values will be changed from little endian to big + * endian formats for internal usage. + *

+ * Origin of code: Avalon Excalibur (IO) + * + * @version CVS $Revision: 1302050 $ + */ +public class SwappedDataInputStream extends ProxyInputStream + implements DataInput +{ + + /** + * Constructs a SwappedDataInputStream. + * + * @param input InputStream to read from + */ + public SwappedDataInputStream( final InputStream input ) + { + super( input ); + } + + /** + * Return {@link #readByte()} != 0 + * @return false if the byte read is zero, otherwise true + * @throws IOException if an I/O error occurs + * @throws EOFException if an end of file is reached unexpectedly + */ + public boolean readBoolean() + throws IOException, EOFException + { + return 0 != readByte(); + } + + /** + * Invokes the delegate's read() method. + * @return the byte read or -1 if the end of stream + * @throws IOException if an I/O error occurs + * @throws EOFException if an end of file is reached unexpectedly + */ + public byte readByte() + throws IOException, EOFException + { + return (byte)in.read(); + } + + /** + * Reads a character delegating to {@link #readShort()}. + * @return the byte read or -1 if the end of stream + * @throws IOException if an I/O error occurs + * @throws EOFException if an end of file is reached unexpectedly + */ + public char readChar() + throws IOException, EOFException + { + return (char)readShort(); + } + + /** + * Delegates to {@link EndianUtils#readSwappedDouble(InputStream)}. + * @return the read long + * @throws IOException if an I/O error occurs + * @throws EOFException if an end of file is reached unexpectedly + */ + public double readDouble() + throws IOException, EOFException + { + return EndianUtils.readSwappedDouble( in ); + } + + /** + * Delegates to {@link EndianUtils#readSwappedFloat(InputStream)}. + * @return the read long + * @throws IOException if an I/O error occurs + * @throws EOFException if an end of file is reached unexpectedly + */ + public float readFloat() + throws IOException, EOFException + { + return EndianUtils.readSwappedFloat( in ); + } + + /** + * Invokes the delegate's read(byte[] data, int, int) method. + * + * @param data the buffer to read the bytes into + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public void readFully( final byte[] data ) + throws IOException, EOFException + { + readFully( data, 0, data.length ); + } + + + /** + * Invokes the delegate's read(byte[] data, int, int) method. + * + * @param data the buffer to read the bytes into + * @param offset The start offset + * @param length The number of bytes to read + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public void readFully( final byte[] data, final int offset, final int length ) + throws IOException, EOFException + { + int remaining = length; + + while( remaining > 0 ) + { + final int location = offset + length - remaining; + final int count = read( data, location, remaining ); + + if (EOF == count) + { + throw new EOFException(); + } + + remaining -= count; + } + } + + /** + * Delegates to {@link EndianUtils#readSwappedInteger(InputStream)}. + * @return the read long + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public int readInt() + throws IOException, EOFException + { + return EndianUtils.readSwappedInteger( in ); + } + + /** + * Not currently supported - throws {@link UnsupportedOperationException}. + * @return the line read + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public String readLine() + throws IOException, EOFException + { + throw new UnsupportedOperationException( + "Operation not supported: readLine()" ); + } + + /** + * Delegates to {@link EndianUtils#readSwappedLong(InputStream)}. + * @return the read long + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public long readLong() + throws IOException, EOFException + { + return EndianUtils.readSwappedLong( in ); + } + + /** + * Delegates to {@link EndianUtils#readSwappedShort(InputStream)}. + * @return the read long + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public short readShort() + throws IOException, EOFException + { + return EndianUtils.readSwappedShort( in ); + } + + /** + * Invokes the delegate's read() method. + * @return the byte read or -1 if the end of stream + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public int readUnsignedByte() + throws IOException, EOFException + { + return in.read(); + } + + /** + * Delegates to {@link EndianUtils#readSwappedUnsignedShort(InputStream)}. + * @return the read long + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public int readUnsignedShort() + throws IOException, EOFException + { + return EndianUtils.readSwappedUnsignedShort( in ); + } + + /** + * Not currently supported - throws {@link UnsupportedOperationException}. + * @return UTF String read + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public String readUTF() + throws IOException, EOFException + { + throw new UnsupportedOperationException( + "Operation not supported: readUTF()" ); + } + + /** + * Invokes the delegate's skip(int) method. + * @param count the number of bytes to skip + * @return the number of bytes to skipped or -1 if the end of stream + * @throws EOFException if an end of file is reached unexpectedly + * @throws IOException if an I/O error occurs + */ + public int skipBytes( final int count ) + throws IOException, EOFException + { + return (int)in.skip( count ); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TaggedInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TaggedInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..451e2bd1815eabff78bc008fe590768947bc43bd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TaggedInputStream.java" @@ -0,0 +1,116 @@ +/* + * 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.input; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.util.UUID; + +import org.apache.commons.io.TaggedIOException; + +/** + * An input stream decorator that tags potential exceptions so that the + * stream that caused the exception can easily be identified. This is + * done by using the {@link TaggedIOException} class to wrap all thrown + * {@link IOException}s. See below for an example of using this class. + *

+ * TaggedInputStream stream = new TaggedInputStream(...);
+ * try {
+ *     // Processing that may throw an IOException either from this stream
+ *     // or from some other IO activity like temporary files, etc.
+ *     processStream(stream);
+ * } catch (IOException e) {
+ *     if (stream.isCauseOf(e)) {
+ *         // The exception was caused by this stream.
+ *         // Use e.getCause() to get the original exception.
+ *     } else {
+ *         // The exception was caused by something else.
+ *     }
+ * }
+ * 
+ *

+ * Alternatively, the {@link #throwIfCauseOf(Throwable)} method can be + * used to let higher levels of code handle the exception caused by this + * stream while other processing errors are being taken care of at this + * lower level. + *

+ * TaggedInputStream stream = new TaggedInputStream(...);
+ * try {
+ *     processStream(stream);
+ * } catch (IOException e) {
+ *     stream.throwIfCauseOf(e);
+ *     // ... or process the exception that was caused by something else
+ * }
+ * 
+ * + * @see TaggedIOException + * @since 2.0 + */ +public class TaggedInputStream extends ProxyInputStream { + + /** + * The unique tag associated with exceptions from stream. + */ + private final Serializable tag = UUID.randomUUID(); + + /** + * Creates a tagging decorator for the given input stream. + * + * @param proxy input stream to be decorated + */ + public TaggedInputStream(final InputStream proxy) { + super(proxy); + } + + /** + * Tests if the given exception was caused by this stream. + * + * @param exception an exception + * @return {@code true} if the exception was thrown by this stream, + * {@code false} otherwise + */ + public boolean isCauseOf(final Throwable exception) { + return TaggedIOException.isTaggedWith(exception, tag); + } + + /** + * Re-throws the original exception thrown by this stream. This method + * first checks whether the given exception is a {@link TaggedIOException} + * wrapper created by this decorator, and then unwraps and throws the + * original wrapped exception. Returns normally if the exception was + * not thrown by this stream. + * + * @param throwable an exception + * @throws IOException original exception, if any, thrown by this stream + */ + public void throwIfCauseOf(final Throwable throwable) throws IOException { + TaggedIOException.throwCauseIfTaggedWith(throwable, tag); + } + + /** + * Tags any IOExceptions thrown, wrapping and re-throwing. + * + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + */ + @Override + protected void handleIOException(final IOException e) throws IOException { + throw new TaggedIOException(e, tag); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/Tailer.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/Tailer.java" new file mode 100644 index 0000000000000000000000000000000000000000..e7ec91a9d39c462d162d05a7aee348cdfd46eaa1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/Tailer.java" @@ -0,0 +1,560 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.charset.Charset; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +/** + * Simple implementation of the unix "tail -f" functionality. + * + *

1. Create a TailerListener implementation

+ *

+ * First you need to create a {@link TailerListener} implementation + * ({@link TailerListenerAdapter} is provided for convenience so that you don't have to + * implement every method). + *

+ * + *

For example:

+ *
+ *  public class MyTailerListener extends TailerListenerAdapter {
+ *      public void handle(String line) {
+ *          System.out.println(line);
+ *      }
+ *  }
+ * + *

2. Using a Tailer

+ * + *

+ * You can create and use a Tailer in one of three ways: + *

+ *
    + *
  • Using one of the static helper methods: + *
      + *
    • {@link Tailer#create(File, TailerListener)}
    • + *
    • {@link Tailer#create(File, TailerListener, long)}
    • + *
    • {@link Tailer#create(File, TailerListener, long, boolean)}
    • + *
    + *
  • + *
  • Using an {@link java.util.concurrent.Executor}
  • + *
  • Using an {@link Thread}
  • + *
+ * + *

+ * An example of each of these is shown below. + *

+ * + *

2.1 Using the static helper method

+ * + *
+ *      TailerListener listener = new MyTailerListener();
+ *      Tailer tailer = Tailer.create(file, listener, delay);
+ * + *

2.2 Using an Executor

+ * + *
+ *      TailerListener listener = new MyTailerListener();
+ *      Tailer tailer = new Tailer(file, listener, delay);
+ *
+ *      // stupid executor impl. for demo purposes
+ *      Executor executor = new Executor() {
+ *          public void execute(Runnable command) {
+ *              command.run();
+ *           }
+ *      };
+ *
+ *      executor.execute(tailer);
+ * 
+ * + * + *

2.3 Using a Thread

+ *
+ *      TailerListener listener = new MyTailerListener();
+ *      Tailer tailer = new Tailer(file, listener, delay);
+ *      Thread thread = new Thread(tailer);
+ *      thread.setDaemon(true); // optional
+ *      thread.start();
+ * + *

3. Stopping a Tailer

+ *

Remember to stop the tailer when you have done with it:

+ *
+ *      tailer.stop();
+ * 
+ * + *

4. Interrupting a Tailer

+ *

You can interrupt the thread a tailer is running on by calling {@link Thread#interrupt()}.

+ *
+ *      thread.interrupt();
+ * 
+ *

If you interrupt a tailer, the tailer listener is called with the {@link InterruptedException}.

+ * + *

The file is read using the default charset; this can be overriden if necessary

+ * @see TailerListener + * @see TailerListenerAdapter + * @version $Id: Tailer.java 1714076 2015-11-12 16:06:41Z krosenvold $ + * @since 2.0 + * @since 2.5 Updated behavior and documentation for {@link Thread#interrupt()} + */ +public class Tailer implements Runnable { + + private static final int DEFAULT_DELAY_MILLIS = 1000; + + private static final String RAF_MODE = "r"; + + private static final int DEFAULT_BUFSIZE = 4096; + + // The default charset used for reading files + private static final Charset DEFAULT_CHARSET = Charset.defaultCharset(); + + /** + * Buffer on top of RandomAccessFile. + */ + private final byte inbuf[]; + + /** + * The file which will be tailed. + */ + private final File file; + + /** + * The character set that will be used to read the file. + */ + private final Charset cset; + + /** + * The amount of time to wait for the file to be updated. + */ + private final long delayMillis; + + /** + * Whether to tail from the end or start of file + */ + private final boolean end; + + /** + * The listener to notify of events when tailing. + */ + private final TailerListener listener; + + /** + * Whether to close and reopen the file whilst waiting for more input. + */ + private final boolean reOpen; + + /** + * The tailer will run as long as this value is true. + */ + private volatile boolean run = true; + + /** + * Creates a Tailer for the given file, starting from the beginning, with the default delay of 1.0s. + * @param file The file to follow. + * @param listener the TailerListener to use. + */ + public Tailer(final File file, final TailerListener listener) { + this(file, listener, DEFAULT_DELAY_MILLIS); + } + + /** + * Creates a Tailer for the given file, starting from the beginning. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + */ + public Tailer(final File file, final TailerListener listener, final long delayMillis) { + this(file, listener, delayMillis, false); + } + + /** + * Creates a Tailer for the given file, with a delay other than the default 1.0s. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + */ + public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end) { + this(file, listener, delayMillis, end, DEFAULT_BUFSIZE); + } + + /** + * Creates a Tailer for the given file, with a delay other than the default 1.0s. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen if true, close and reopen the file between reading chunks + */ + public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, + final boolean reOpen) { + this(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE); + } + + /** + * Creates a Tailer for the given file, with a specified buffer size. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param bufSize Buffer size + */ + public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, + final int bufSize) { + this(file, listener, delayMillis, end, false, bufSize); + } + + /** + * Creates a Tailer for the given file, with a specified buffer size. + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen if true, close and reopen the file between reading chunks + * @param bufSize Buffer size + */ + public Tailer(final File file, final TailerListener listener, final long delayMillis, final boolean end, + final boolean reOpen, final int bufSize) { + this(file, DEFAULT_CHARSET, listener, delayMillis, end, reOpen, bufSize); + } + + /** + * Creates a Tailer for the given file, with a specified buffer size. + * @param file the file to follow. + * @param cset the Charset to be used for reading the file + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen if true, close and reopen the file between reading chunks + * @param bufSize Buffer size + */ + public Tailer(final File file, final Charset cset, final TailerListener listener, final long delayMillis, + final boolean end, final boolean reOpen + , final int bufSize) { + this.file = file; + this.delayMillis = delayMillis; + this.end = end; + + this.inbuf = new byte[bufSize]; + + // Save and prepare the listener + this.listener = listener; + listener.init(this); + this.reOpen = reOpen; + this.cset = cset; + } + + /** + * Creates and starts a Tailer for the given file. + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param bufSize buffer size. + * @return The new tailer + */ + public static Tailer create(final File file, final TailerListener listener, final long delayMillis, + final boolean end, final int bufSize) { + return create(file, listener, delayMillis, end, false, bufSize); + } + + /** + * Creates and starts a Tailer for the given file. + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen whether to close/reopen the file between chunks + * @param bufSize buffer size. + * @return The new tailer + */ + public static Tailer create(final File file, final TailerListener listener, final long delayMillis, + final boolean end, final boolean reOpen, + final int bufSize) { + return create(file, DEFAULT_CHARSET, listener, delayMillis, end, reOpen, bufSize); + } + + /** + * Creates and starts a Tailer for the given file. + * + * @param file the file to follow. + * @param charset the character set to use for reading the file + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen whether to close/reopen the file between chunks + * @param bufSize buffer size. + * @return The new tailer + */ + public static Tailer create(final File file, final Charset charset, final TailerListener listener, + final long delayMillis, final boolean end, final boolean reOpen + ,final int bufSize) { + final Tailer tailer = new Tailer(file, charset, listener, delayMillis, end, reOpen, bufSize); + final Thread thread = new Thread(tailer); + thread.setDaemon(true); + thread.start(); + return tailer; + } + + /** + * Creates and starts a Tailer for the given file with default buffer size. + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @return The new tailer + */ + public static Tailer create(final File file, final TailerListener listener, final long delayMillis, + final boolean end) { + return create(file, listener, delayMillis, end, DEFAULT_BUFSIZE); + } + + /** + * Creates and starts a Tailer for the given file with default buffer size. + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. + * @param reOpen whether to close/reopen the file between chunks + * @return The new tailer + */ + public static Tailer create(final File file, final TailerListener listener, final long delayMillis, + final boolean end, final boolean reOpen) { + return create(file, listener, delayMillis, end, reOpen, DEFAULT_BUFSIZE); + } + + /** + * Creates and starts a Tailer for the given file, starting at the beginning of the file + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @param delayMillis the delay between checks of the file for new content in milliseconds. + * @return The new tailer + */ + public static Tailer create(final File file, final TailerListener listener, final long delayMillis) { + return create(file, listener, delayMillis, false); + } + + /** + * Creates and starts a Tailer for the given file, starting at the beginning of the file + * with the default delay of 1.0s + * + * @param file the file to follow. + * @param listener the TailerListener to use. + * @return The new tailer + */ + public static Tailer create(final File file, final TailerListener listener) { + return create(file, listener, DEFAULT_DELAY_MILLIS, false); + } + + /** + * Return the file. + * + * @return the file + */ + public File getFile() { + return file; + } + + /** + * Gets whether to keep on running. + * + * @return whether to keep on running. + * @since 2.5 + */ + protected boolean getRun() { + return run; + } + + /** + * Return the delay in milliseconds. + * + * @return the delay in milliseconds. + */ + public long getDelay() { + return delayMillis; + } + + /** + * Follows changes in the file, calling the TailerListener's handle method for each new line. + */ + public void run() { + RandomAccessFile reader = null; + try { + long last = 0; // The last time the file was checked for changes + long position = 0; // position within the file + // Open the file + while (getRun() && reader == null) { + try { + reader = new RandomAccessFile(file, RAF_MODE); + } catch (final FileNotFoundException e) { + listener.fileNotFound(); + } + if (reader == null) { + Thread.sleep(delayMillis); + } else { + // The current position in the file + position = end ? file.length() : 0; + last = file.lastModified(); + reader.seek(position); + } + } + while (getRun()) { + final boolean newer = FileUtils.isFileNewer(file, last); // IO-279, must be done first + // Check the file length to see if it was rotated + final long length = file.length(); + if (length < position) { + // File was rotated + listener.fileRotated(); + // Reopen the reader after rotation + try { + // Ensure that the old file is closed iff we re-open it successfully + final RandomAccessFile save = reader; + reader = new RandomAccessFile(file, RAF_MODE); + // At this point, we're sure that the old file is rotated + // Finish scanning the old file and then we'll start with the new one + try { + readLines(save); + } catch (IOException ioe) { + listener.handle(ioe); + } + position = 0; + // close old file explicitly rather than relying on GC picking up previous RAF + IOUtils.closeQuietly(save); + } catch (final FileNotFoundException e) { + // in this case we continue to use the previous reader and position values + listener.fileNotFound(); + } + continue; + } else { + // File was not rotated + // See if the file needs to be read again + if (length > position) { + // The file has more content than it did last time + position = readLines(reader); + last = file.lastModified(); + } else if (newer) { + /* + * This can happen if the file is truncated or overwritten with the exact same length of + * information. In cases like this, the file position needs to be reset + */ + position = 0; + reader.seek(position); // cannot be null here + + // Now we can read new lines + position = readLines(reader); + last = file.lastModified(); + } + } + if (reOpen) { + IOUtils.closeQuietly(reader); + } + Thread.sleep(delayMillis); + if (getRun() && reOpen) { + reader = new RandomAccessFile(file, RAF_MODE); + reader.seek(position); + } + } + } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); + stop(e); + } catch (final Exception e) { + stop(e); + } finally { + IOUtils.closeQuietly(reader); + } + } + + /** + * Stops the tailer with an exception + * @param e The exception to send to listener + */ + private void stop(final Exception e) { + listener.handle(e); + stop(); + } + + /** + * Allows the tailer to complete its current loop and return. + */ + public void stop() { + this.run = false; + } + + /** + * Read new lines. + * + * @param reader The file to read + * @return The new position after the lines have been read + * @throws java.io.IOException if an I/O error occurs. + */ + private long readLines(final RandomAccessFile reader) throws IOException { + ByteArrayOutputStream lineBuf = new ByteArrayOutputStream(64); + long pos = reader.getFilePointer(); + long rePos = pos; // position to re-read + int num; + boolean seenCR = false; + while (getRun() && ((num = reader.read(inbuf)) != EOF)) { + for (int i = 0; i < num; i++) { + final byte ch = inbuf[i]; + switch (ch) { + case '\n': + seenCR = false; // swallow CR before LF + listener.handle(new String(lineBuf.toByteArray(), cset)); + lineBuf.reset(); + rePos = pos + i + 1; + break; + case '\r': + if (seenCR) { + lineBuf.write('\r'); + } + seenCR = true; + break; + default: + if (seenCR) { + seenCR = false; // swallow final CR + listener.handle(new String(lineBuf.toByteArray(), cset)); + lineBuf.reset(); + rePos = pos + i + 1; + } + lineBuf.write(ch); + } + } + pos = reader.getFilePointer(); + } + IOUtils.closeQuietly(lineBuf); // not strictly necessary + reader.seek(rePos); // Ensure we can re-read if necessary + + if (listener instanceof TailerListenerAdapter) { + ((TailerListenerAdapter) listener).endOfFileReached(); + } + + return rePos; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TailerListener.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TailerListener.java" new file mode 100644 index 0000000000000000000000000000000000000000..b8f7f2f9543d22e5c4633956b26d792de836f640 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TailerListener.java" @@ -0,0 +1,67 @@ +/* + * 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.input; + +/** + * Listener for events from a {@link Tailer}. + * + * @version $Id: TailerListener.java 1714076 2015-11-12 16:06:41Z krosenvold $ + * @since 2.0 + */ +public interface TailerListener { + + /** + * The tailer will call this method during construction, + * giving the listener a method of stopping the tailer. + * @param tailer the tailer. + */ + void init(Tailer tailer); + + /** + * This method is called if the tailed file is not found. + *

+ * Note: this is called from the tailer thread. + */ + void fileNotFound(); + + /** + * Called if a file rotation is detected. + * + * This method is called before the file is reopened, and fileNotFound may + * be called if the new file has not yet been created. + *

+ * Note: this is called from the tailer thread. + */ + void fileRotated(); + + /** + * Handles a line from a Tailer. + *

+ * Note: this is called from the tailer thread. + * @param line the line. + */ + void handle(String line); + + /** + * Handles an Exception . + *

+ * Note: this is called from the tailer thread. + * @param ex the exception. + */ + void handle(Exception ex); + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java" new file mode 100644 index 0000000000000000000000000000000000000000..c9626412e96d0c000684891444f108ba9cc26645 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TailerListenerAdapter.java" @@ -0,0 +1,76 @@ +/* + * 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.input; + +/** + * {@link TailerListener} Adapter. + * + * @version $Id: TailerListenerAdapter.java 1714076 2015-11-12 16:06:41Z krosenvold $ + * @since 2.0 + */ +public class TailerListenerAdapter implements TailerListener { + + /** + * The tailer will call this method during construction, + * giving the listener a method of stopping the tailer. + * @param tailer the tailer. + */ + public void init(final Tailer tailer) { + } + + /** + * This method is called if the tailed file is not found. + */ + public void fileNotFound() { + } + + /** + * Called if a file rotation is detected. + * + * This method is called before the file is reopened, and fileNotFound may + * be called if the new file has not yet been created. + */ + public void fileRotated() { + } + + /** + * Handles a line from a Tailer. + * @param line the line. + */ + public void handle(final String line) { + } + + /** + * Handles an Exception . + * @param ex the exception. + */ + public void handle(final Exception ex) { + } + + /** + * Called each time the Tailer reaches the end of the file. + * + * Note: this is called from the tailer thread. + * + * Note: a future version of commons-io will pull this method up to the TailerListener interface, + * for now clients must subclass this class to use this feature. + * + * @since 2.5 + */ + public void endOfFileReached() { + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TeeInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TeeInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..1f01b36c873b24ba0f8bdd96c0e8a372ae36fe0d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/TeeInputStream.java" @@ -0,0 +1,153 @@ +/* + * 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.input; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * InputStream proxy that transparently writes a copy of all bytes read + * from the proxied stream to a given OutputStream. Using {@link #skip(long)} + * or {@link #mark(int)}/{@link #reset()} on the stream will result on some + * bytes from the input stream being skipped or duplicated in the output + * stream. + *

+ * The proxied input stream is closed when the {@link #close()} method is + * called on this proxy. It is configurable whether the associated output + * stream will also closed. + * + * @version $Id: TeeInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $ + * @since 1.4 + */ +public class TeeInputStream extends ProxyInputStream { + + /** + * The output stream that will receive a copy of all bytes read from the + * proxied input stream. + */ + private final OutputStream branch; + + /** + * Flag for closing also the associated output stream when this + * stream is closed. + */ + private final boolean closeBranch; + + /** + * Creates a TeeInputStream that proxies the given {@link InputStream} + * and copies all read bytes to the given {@link OutputStream}. The given + * output stream will not be closed when this stream gets closed. + * + * @param input input stream to be proxied + * @param branch output stream that will receive a copy of all bytes read + */ + public TeeInputStream(final InputStream input, final OutputStream branch) { + this(input, branch, false); + } + + /** + * Creates a TeeInputStream that proxies the given {@link InputStream} + * and copies all read bytes to the given {@link OutputStream}. The given + * output stream will be closed when this stream gets closed if the + * closeBranch parameter is {@code true}. + * + * @param input input stream to be proxied + * @param branch output stream that will receive a copy of all bytes read + * @param closeBranch flag for closing also the output stream when this + * stream is closed + */ + public TeeInputStream( + final InputStream input, final OutputStream branch, final boolean closeBranch) { + super(input); + this.branch = branch; + this.closeBranch = closeBranch; + } + + /** + * Closes the proxied input stream and, if so configured, the associated + * output stream. An exception thrown from one stream will not prevent + * closing of the other stream. + * + * @throws IOException if either of the streams could not be closed + */ + @Override + public void close() throws IOException { + try { + super.close(); + } finally { + if (closeBranch) { + branch.close(); + } + } + } + + /** + * Reads a single byte from the proxied input stream and writes it to + * the associated output stream. + * + * @return next byte from the stream, or -1 if the stream has ended + * @throws IOException if the stream could not be read (or written) + */ + @Override + public int read() throws IOException { + final int ch = super.read(); + if (ch != EOF) { + branch.write(ch); + } + return ch; + } + + /** + * Reads bytes from the proxied input stream and writes the read bytes + * to the associated output stream. + * + * @param bts byte buffer + * @param st start offset within the buffer + * @param end maximum number of bytes to read + * @return number of bytes read, or -1 if the stream has ended + * @throws IOException if the stream could not be read (or written) + */ + @Override + public int read(final byte[] bts, final int st, final int end) throws IOException { + final int n = super.read(bts, st, end); + if (n != -1) { + branch.write(bts, st, n); + } + return n; + } + + /** + * Reads bytes from the proxied input stream and writes the read bytes + * to the associated output stream. + * + * @param bts byte buffer + * @return number of bytes read, or -1 if the stream has ended + * @throws IOException if the stream could not be read (or written) + */ + @Override + public int read(final byte[] bts) throws IOException { + final int n = super.read(bts); + if (n != EOF) { + branch.write(bts, 0, n); + } + return n; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..7464c359ce1f8930f82f1f65e06f5c7bd6d03090 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/UnixLineEndingInputStream.java" @@ -0,0 +1,128 @@ +/* + * 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.input; + + +import java.io.IOException; +import java.io.InputStream; + +/** + * A filtering input stream that ensures the content will have unix-style line endings, LF. + * + * @since 2.5 + */ +public class UnixLineEndingInputStream extends InputStream { + + private boolean slashNSeen = false; + + private boolean slashRSeen = false; + + private boolean eofSeen = false; + + private final InputStream target; + + private final boolean ensureLineFeedAtEndOfFile; + + /** + * Create an input stream that filters another stream + * + * @param in The input stream to wrap + * @param ensureLineFeedAtEndOfFile true to ensure that the file ends with LF + */ + public UnixLineEndingInputStream( InputStream in, boolean ensureLineFeedAtEndOfFile ) { + this.target = in; + this.ensureLineFeedAtEndOfFile = ensureLineFeedAtEndOfFile; + } + + /** + * Reads the next item from the target, updating internal flags in the process + * @return the next int read from the target stream + * @throws IOException upon error + */ + private int readWithUpdate() throws IOException { + final int target = this.target.read(); + eofSeen = target == -1; + if ( eofSeen ) { + return target; + } + slashNSeen = target == '\n'; + slashRSeen = target == '\r'; + return target; + } + + /** + * {@inheritDoc} + */ + @Override + public int read() throws IOException { + boolean previousWasSlashR = slashRSeen; + if ( eofSeen ) { + return eofGame(previousWasSlashR); + } + else { + int target = readWithUpdate(); + if ( eofSeen ) { + return eofGame(previousWasSlashR); + } + if (slashRSeen) + { + return '\n'; + } + + if ( previousWasSlashR && slashNSeen){ + return read(); + } + + return target; + } + } + + /** + * Handles the eof-handling at the end of the stream + * @param previousWasSlashR Indicates if the last seen was a \r + * @return The next char to output to the stream + */ + private int eofGame(boolean previousWasSlashR) { + if ( previousWasSlashR || !ensureLineFeedAtEndOfFile ) { + return -1; + } + if ( !slashNSeen ) { + slashNSeen = true; + return '\n'; + } else { + return -1; + } + } + + /** + * Closes the stream. Also closes the underlying stream. + * @throws IOException upon error + */ + @Override + public void close() throws IOException { + super.close(); + target.close(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized void mark( int readlimit ) { + throw new UnsupportedOperationException( "Mark notsupported" ); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..e1665188f393d2875e0d92ae62e06f4e77500293 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/WindowsLineEndingInputStream.java" @@ -0,0 +1,134 @@ +/* + * 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.input; + +import java.io.IOException; +import java.io.InputStream; + +/** + * A filtering input stream that ensures the content will have windows line endings, CRLF. + * + * @since 2.5 + */ +public class WindowsLineEndingInputStream extends InputStream { + + private boolean slashRSeen = false; + + private boolean slashNSeen = false; + + private boolean injectSlashN = false; + + private boolean eofSeen = false; + + private final InputStream target; + + private final boolean ensureLineFeedAtEndOfFile; + + /** + * Create an input stream that filters another stream + * + * @param in The input stream to wrap + * @param ensureLineFeedAtEndOfFile true to ensure that the file ends with CRLF + */ + public WindowsLineEndingInputStream( InputStream in, boolean ensureLineFeedAtEndOfFile ) { + this.target = in; + this.ensureLineFeedAtEndOfFile = ensureLineFeedAtEndOfFile; + } + + /** + * Reads the next item from the target, updating internal flags in the process + * @return the next int read from the target stream + * @throws IOException upon error + */ + private int readWithUpdate() throws IOException { + final int target = this.target.read(); + eofSeen = target == -1; + if ( eofSeen ) { + return target; + } + slashRSeen = target == '\r'; + slashNSeen = target == '\n'; + return target; + } + + /** + * {@inheritDoc} + */ + @Override + public int read() throws IOException { + if ( eofSeen ) { + return eofGame(); + } else if ( injectSlashN ) { + injectSlashN = false; + return '\n'; + } else { + boolean prevWasSlashR = slashRSeen; + int target = readWithUpdate(); + if ( eofSeen ) { + return eofGame(); + } + if ( target == '\n' ) { + if ( !prevWasSlashR ) + { + injectSlashN = true; + return '\r'; + } + } + return target; + } + } + + /** + * Handles the eof-handling at the end of the stream + * @return The next char to output to the stream + */ + + private int eofGame() { + if ( !ensureLineFeedAtEndOfFile ) { + return -1; + } + if ( !slashNSeen && !slashRSeen ) { + slashRSeen = true; + return '\r'; + } + if ( !slashNSeen ) { + slashRSeen = false; + slashNSeen = true; + return '\n'; + } else { + return -1; + } + } + + /** + * Closes the stream. Also closes the underlying stream. + * @throws IOException upon error + */ + @Override + public void close() throws IOException { + super.close(); + target.close(); + } + + /** + * {@inheritDoc} + */ + @Override + public synchronized void mark( int readlimit ) { + throw new UnsupportedOperationException( "Mark not supported" ); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/XmlStreamReader.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/XmlStreamReader.java" new file mode 100644 index 0000000000000000000000000000000000000000..5ac60e2ff25d62cec5185b1d4b8d6ef40126519f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/XmlStreamReader.java" @@ -0,0 +1,797 @@ +/* + * 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.input; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.text.MessageFormat; +import java.util.Locale; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.io.ByteOrderMark; + +/** + * Character stream that handles all the necessary Voodo to figure out the + * charset encoding of the XML document within the stream. + *

+ * IMPORTANT: This class is not related in any way to the org.xml.sax.XMLReader. + * This one IS a character stream. + *

+ * All this has to be done without consuming characters from the stream, if not + * the XML parser will not recognized the document as a valid XML. This is not + * 100% true, but it's close enough (UTF-8 BOM is not handled by all parsers + * right now, XmlStreamReader handles it and things work in all parsers). + *

+ * The XmlStreamReader class handles the charset encoding of XML documents in + * Files, raw streams and HTTP streams by offering a wide set of constructors. + *

+ * By default the charset encoding detection is lenient, the constructor with + * the lenient flag can be used for an script (following HTTP MIME and XML + * specifications). All this is nicely explained by Mark Pilgrim in his blog, + * Determining the character encoding of a feed. + *

+ * Originally developed for ROME under + * Apache License 2.0. + * + * @version $Id: XmlStreamReader.java 1686747 2015-06-21 18:44:49Z krosenvold $ + * @see org.apache.commons.io.output.XmlStreamWriter + * @since 2.0 + */ +public class XmlStreamReader extends Reader { + private static final int BUFFER_SIZE = 4096; + + private static final String UTF_8 = "UTF-8"; + + private static final String US_ASCII = "US-ASCII"; + + private static final String UTF_16BE = "UTF-16BE"; + + private static final String UTF_16LE = "UTF-16LE"; + + private static final String UTF_32BE = "UTF-32BE"; + + private static final String UTF_32LE = "UTF-32LE"; + + private static final String UTF_16 = "UTF-16"; + + private static final String UTF_32 = "UTF-32"; + + private static final String EBCDIC = "CP1047"; + + private static final ByteOrderMark[] BOMS = new ByteOrderMark[] { + ByteOrderMark.UTF_8, + ByteOrderMark.UTF_16BE, + ByteOrderMark.UTF_16LE, + ByteOrderMark.UTF_32BE, + ByteOrderMark.UTF_32LE + }; + + // UTF_16LE and UTF_32LE have the same two starting BOM bytes. + private static final ByteOrderMark[] XML_GUESS_BYTES = new ByteOrderMark[] { + new ByteOrderMark(UTF_8, 0x3C, 0x3F, 0x78, 0x6D), + new ByteOrderMark(UTF_16BE, 0x00, 0x3C, 0x00, 0x3F), + new ByteOrderMark(UTF_16LE, 0x3C, 0x00, 0x3F, 0x00), + new ByteOrderMark(UTF_32BE, 0x00, 0x00, 0x00, 0x3C, + 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x6D), + new ByteOrderMark(UTF_32LE, 0x3C, 0x00, 0x00, 0x00, + 0x3F, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00), + new ByteOrderMark(EBCDIC, 0x4C, 0x6F, 0xA7, 0x94) + }; + + private final Reader reader; + + private final String encoding; + + private final String defaultEncoding; + + /** + * Returns the default encoding to use if none is set in HTTP content-type, + * XML prolog and the rules based on content-type are not adequate. + *

+ * If it is NULL the content-type based rules are used. + * + * @return the default encoding to use. + */ + public String getDefaultEncoding() { + return defaultEncoding; + } + + /** + * Creates a Reader for a File. + *

+ * It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset, + * if this is also missing defaults to UTF-8. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param file File to create a Reader from. + * @throws IOException thrown if there is a problem reading the file. + */ + public XmlStreamReader(final File file) throws IOException { + this(new FileInputStream(file)); + } + + /** + * Creates a Reader for a raw InputStream. + *

+ * It follows the same logic used for files. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param is InputStream to create a Reader from. + * @throws IOException thrown if there is a problem reading the stream. + */ + public XmlStreamReader(final InputStream is) throws IOException { + this(is, true); + } + + /** + * Creates a Reader for a raw InputStream. + *

+ * It follows the same logic used for files. + *

+ * If lenient detection is indicated and the detection above fails as per + * specifications it then attempts the following: + *

+ * If the content type was 'text/html' it replaces it with 'text/xml' and + * tries the detection again. + *

+ * Else if the XML prolog had a charset encoding that encoding is used. + *

+ * Else if the content type had a charset encoding that encoding is used. + *

+ * Else 'UTF-8' is used. + *

+ * If lenient detection is indicated an XmlStreamReaderException is never + * thrown. + * + * @param is InputStream to create a Reader from. + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @throws IOException thrown if there is a problem reading the stream. + * @throws XmlStreamReaderException thrown if the charset encoding could not + * be determined according to the specs. + */ + public XmlStreamReader(final InputStream is, final boolean lenient) throws IOException { + this(is, lenient, null); + } + + /** + * Creates a Reader for a raw InputStream. + *

+ * It follows the same logic used for files. + *

+ * If lenient detection is indicated and the detection above fails as per + * specifications it then attempts the following: + *

+ * If the content type was 'text/html' it replaces it with 'text/xml' and + * tries the detection again. + *

+ * Else if the XML prolog had a charset encoding that encoding is used. + *

+ * Else if the content type had a charset encoding that encoding is used. + *

+ * Else 'UTF-8' is used. + *

+ * If lenient detection is indicated an XmlStreamReaderException is never + * thrown. + * + * @param is InputStream to create a Reader from. + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @param defaultEncoding The default encoding + * @throws IOException thrown if there is a problem reading the stream. + * @throws XmlStreamReaderException thrown if the charset encoding could not + * be determined according to the specs. + */ + public XmlStreamReader(final InputStream is, final boolean lenient, final String defaultEncoding) + throws IOException { + this.defaultEncoding = defaultEncoding; + final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS); + final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES); + this.encoding = doRawStream(bom, pis, lenient); + this.reader = new InputStreamReader(pis, encoding); + } + + /** + * Creates a Reader using the InputStream of a URL. + *

+ * If the URL is not of type HTTP and there is not 'content-type' header in + * the fetched data it uses the same logic used for Files. + *

+ * If the URL is a HTTP Url or there is a 'content-type' header in the + * fetched data it uses the same logic used for an InputStream with + * content-type. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param url URL to create a Reader from. + * @throws IOException thrown if there is a problem reading the stream of + * the URL. + */ + public XmlStreamReader(final URL url) throws IOException { + this(url.openConnection(), null); + } + + /** + * Creates a Reader using the InputStream of a URLConnection. + *

+ * If the URLConnection is not of type HttpURLConnection and there is not + * 'content-type' header in the fetched data it uses the same logic used for + * files. + *

+ * If the URLConnection is a HTTP Url or there is a 'content-type' header in + * the fetched data it uses the same logic used for an InputStream with + * content-type. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param conn URLConnection to create a Reader from. + * @param defaultEncoding The default encoding + * @throws IOException thrown if there is a problem reading the stream of + * the URLConnection. + */ + public XmlStreamReader(final URLConnection conn, final String defaultEncoding) throws IOException { + this.defaultEncoding = defaultEncoding; + final boolean lenient = true; + final String contentType = conn.getContentType(); + final InputStream is = conn.getInputStream(); + final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS); + final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES); + if (conn instanceof HttpURLConnection || contentType != null) { + this.encoding = doHttpStream(bom, pis, contentType, lenient); + } else { + this.encoding = doRawStream(bom, pis, lenient); + } + this.reader = new InputStreamReader(pis, encoding); + } + + /** + * Creates a Reader using an InputStream an the associated content-type + * header. + *

+ * First it checks if the stream has BOM. If there is not BOM checks the + * content-type encoding. If there is not content-type encoding checks the + * XML prolog encoding. If there is not XML prolog encoding uses the default + * encoding mandated by the content-type MIME type. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param is InputStream to create the reader from. + * @param httpContentType content-type header to use for the resolution of + * the charset encoding. + * @throws IOException thrown if there is a problem reading the file. + */ + public XmlStreamReader(final InputStream is, final String httpContentType) + throws IOException { + this(is, httpContentType, true); + } + + /** + * Creates a Reader using an InputStream an the associated content-type + * header. This constructor is lenient regarding the encoding detection. + *

+ * First it checks if the stream has BOM. If there is not BOM checks the + * content-type encoding. If there is not content-type encoding checks the + * XML prolog encoding. If there is not XML prolog encoding uses the default + * encoding mandated by the content-type MIME type. + *

+ * If lenient detection is indicated and the detection above fails as per + * specifications it then attempts the following: + *

+ * If the content type was 'text/html' it replaces it with 'text/xml' and + * tries the detection again. + *

+ * Else if the XML prolog had a charset encoding that encoding is used. + *

+ * Else if the content type had a charset encoding that encoding is used. + *

+ * Else 'UTF-8' is used. + *

+ * If lenient detection is indicated an XmlStreamReaderException is never + * thrown. + * + * @param is InputStream to create the reader from. + * @param httpContentType content-type header to use for the resolution of + * the charset encoding. + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @param defaultEncoding The default encoding + * @throws IOException thrown if there is a problem reading the file. + * @throws XmlStreamReaderException thrown if the charset encoding could not + * be determined according to the specs. + */ + public XmlStreamReader(final InputStream is, final String httpContentType, + final boolean lenient, final String defaultEncoding) throws IOException { + this.defaultEncoding = defaultEncoding; + final BOMInputStream bom = new BOMInputStream(new BufferedInputStream(is, BUFFER_SIZE), false, BOMS); + final BOMInputStream pis = new BOMInputStream(bom, true, XML_GUESS_BYTES); + this.encoding = doHttpStream(bom, pis, httpContentType, lenient); + this.reader = new InputStreamReader(pis, encoding); + } + + /** + * Creates a Reader using an InputStream an the associated content-type + * header. This constructor is lenient regarding the encoding detection. + *

+ * First it checks if the stream has BOM. If there is not BOM checks the + * content-type encoding. If there is not content-type encoding checks the + * XML prolog encoding. If there is not XML prolog encoding uses the default + * encoding mandated by the content-type MIME type. + *

+ * If lenient detection is indicated and the detection above fails as per + * specifications it then attempts the following: + *

+ * If the content type was 'text/html' it replaces it with 'text/xml' and + * tries the detection again. + *

+ * Else if the XML prolog had a charset encoding that encoding is used. + *

+ * Else if the content type had a charset encoding that encoding is used. + *

+ * Else 'UTF-8' is used. + *

+ * If lenient detection is indicated an XmlStreamReaderException is never + * thrown. + * + * @param is InputStream to create the reader from. + * @param httpContentType content-type header to use for the resolution of + * the charset encoding. + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @throws IOException thrown if there is a problem reading the file. + * @throws XmlStreamReaderException thrown if the charset encoding could not + * be determined according to the specs. + */ + public XmlStreamReader(final InputStream is, final String httpContentType, + final boolean lenient) throws IOException { + this(is, httpContentType, lenient, null); + } + + /** + * Returns the charset encoding of the XmlStreamReader. + * + * @return charset encoding. + */ + public String getEncoding() { + return encoding; + } + + /** + * Invokes the underlying reader's read(char[], int, int) method. + * @param buf the buffer to read the characters into + * @param offset The start offset + * @param len The number of bytes to read + * @return the number of characters read or -1 if the end of stream + * @throws IOException if an I/O error occurs + */ + @Override + public int read(final char[] buf, final int offset, final int len) throws IOException { + return reader.read(buf, offset, len); + } + + /** + * Closes the XmlStreamReader stream. + * + * @throws IOException thrown if there was a problem closing the stream. + */ + @Override + public void close() throws IOException { + reader.close(); + } + + /** + * Process the raw stream. + * + * @param bom BOMInputStream to detect byte order marks + * @param pis BOMInputStream to guess XML encoding + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @return the encoding to be used + * @throws IOException thrown if there is a problem reading the stream. + */ + private String doRawStream(final BOMInputStream bom, final BOMInputStream pis, final boolean lenient) + throws IOException { + final String bomEnc = bom.getBOMCharsetName(); + final String xmlGuessEnc = pis.getBOMCharsetName(); + final String xmlEnc = getXmlProlog(pis, xmlGuessEnc); + try { + return calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc); + } catch (final XmlStreamReaderException ex) { + if (lenient) { + return doLenientDetection(null, ex); + } else { + throw ex; + } + } + } + + /** + * Process a HTTP stream. + * + * @param bom BOMInputStream to detect byte order marks + * @param pis BOMInputStream to guess XML encoding + * @param httpContentType The HTTP content type + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @return the encoding to be used + * @throws IOException thrown if there is a problem reading the stream. + */ + private String doHttpStream(final BOMInputStream bom, final BOMInputStream pis, final String httpContentType, + final boolean lenient) throws IOException { + final String bomEnc = bom.getBOMCharsetName(); + final String xmlGuessEnc = pis.getBOMCharsetName(); + final String xmlEnc = getXmlProlog(pis, xmlGuessEnc); + try { + return calculateHttpEncoding(httpContentType, bomEnc, + xmlGuessEnc, xmlEnc, lenient); + } catch (final XmlStreamReaderException ex) { + if (lenient) { + return doLenientDetection(httpContentType, ex); + } else { + throw ex; + } + } + } + + /** + * Do lenient detection. + * + * @param httpContentType content-type header to use for the resolution of + * the charset encoding. + * @param ex The thrown exception + * @return the encoding + * @throws IOException thrown if there is a problem reading the stream. + */ + private String doLenientDetection(String httpContentType, + XmlStreamReaderException ex) throws IOException { + if (httpContentType != null && httpContentType.startsWith("text/html")) { + httpContentType = httpContentType.substring("text/html".length()); + httpContentType = "text/xml" + httpContentType; + try { + return calculateHttpEncoding(httpContentType, ex.getBomEncoding(), + ex.getXmlGuessEncoding(), ex.getXmlEncoding(), true); + } catch (final XmlStreamReaderException ex2) { + ex = ex2; + } + } + String encoding = ex.getXmlEncoding(); + if (encoding == null) { + encoding = ex.getContentTypeEncoding(); + } + if (encoding == null) { + encoding = defaultEncoding == null ? UTF_8 : defaultEncoding; + } + return encoding; + } + + /** + * Calculate the raw encoding. + * + * @param bomEnc BOM encoding + * @param xmlGuessEnc XML Guess encoding + * @param xmlEnc XML encoding + * @return the raw encoding + * @throws IOException thrown if there is a problem reading the stream. + */ + String calculateRawEncoding(final String bomEnc, final String xmlGuessEnc, + final String xmlEnc) throws IOException { + + // BOM is Null + if (bomEnc == null) { + if (xmlGuessEnc == null || xmlEnc == null) { + return defaultEncoding == null ? UTF_8 : defaultEncoding; + } + if (xmlEnc.equals(UTF_16) && + (xmlGuessEnc.equals(UTF_16BE) || xmlGuessEnc.equals(UTF_16LE))) { + return xmlGuessEnc; + } + return xmlEnc; + } + + // BOM is UTF-8 + if (bomEnc.equals(UTF_8)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) { + final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + if (xmlEnc != null && !xmlEnc.equals(UTF_8)) { + final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + return bomEnc; + } + + // BOM is UTF-16BE or UTF-16LE + if (bomEnc.equals(UTF_16BE) || bomEnc.equals(UTF_16LE)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) { + final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + if (xmlEnc != null && !xmlEnc.equals(UTF_16) && !xmlEnc.equals(bomEnc)) { + final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + return bomEnc; + } + + // BOM is UTF-32BE or UTF-32LE + if (bomEnc.equals(UTF_32BE) || bomEnc.equals(UTF_32LE)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) { + final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + if (xmlEnc != null && !xmlEnc.equals(UTF_32) && !xmlEnc.equals(bomEnc)) { + final String msg = MessageFormat.format(RAW_EX_1, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + return bomEnc; + } + + // BOM is something else + final String msg = MessageFormat.format(RAW_EX_2, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, bomEnc, xmlGuessEnc, xmlEnc); + } + + + /** + * Calculate the HTTP encoding. + * + * @param httpContentType The HTTP content type + * @param bomEnc BOM encoding + * @param xmlGuessEnc XML Guess encoding + * @param xmlEnc XML encoding + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @return the HTTP encoding + * @throws IOException thrown if there is a problem reading the stream. + */ + String calculateHttpEncoding(final String httpContentType, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc, + final boolean lenient) throws IOException { + + // Lenient and has XML encoding + if (lenient && xmlEnc != null) { + return xmlEnc; + } + + // Determine mime/encoding content types from HTTP Content Type + final String cTMime = getContentTypeMime(httpContentType); + final String cTEnc = getContentTypeEncoding(httpContentType); + final boolean appXml = isAppXml(cTMime); + final boolean textXml = isTextXml(cTMime); + + // Mime type NOT "application/xml" or "text/xml" + if (!appXml && !textXml) { + final String msg = MessageFormat.format(HTTP_EX_3, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + } + + // No content type encoding + if (cTEnc == null) { + if (appXml) { + return calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc); + } else { + return defaultEncoding == null ? US_ASCII : defaultEncoding; + } + } + + // UTF-16BE or UTF-16LE content type encoding + if (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE)) { + if (bomEnc != null) { + final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + } + return cTEnc; + } + + // UTF-16 content type encoding + if (cTEnc.equals(UTF_16)) { + if (bomEnc != null && bomEnc.startsWith(UTF_16)) { + return bomEnc; + } + final String msg = MessageFormat.format(HTTP_EX_2, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + } + + // UTF-32BE or UTF-132E content type encoding + if (cTEnc.equals(UTF_32BE) || cTEnc.equals(UTF_32LE)) { + if (bomEnc != null) { + final String msg = MessageFormat.format(HTTP_EX_1, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + } + return cTEnc; + } + + // UTF-32 content type encoding + if (cTEnc.equals(UTF_32)) { + if (bomEnc != null && bomEnc.startsWith(UTF_32)) { + return bomEnc; + } + final String msg = MessageFormat.format(HTTP_EX_2, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + throw new XmlStreamReaderException(msg, cTMime, cTEnc, bomEnc, xmlGuessEnc, xmlEnc); + } + + return cTEnc; + } + + /** + * Returns MIME type or NULL if httpContentType is NULL. + * + * @param httpContentType the HTTP content type + * @return The mime content type + */ + static String getContentTypeMime(final String httpContentType) { + String mime = null; + if (httpContentType != null) { + final int i = httpContentType.indexOf(";"); + if (i >= 0) { + mime = httpContentType.substring(0, i); + } else { + mime = httpContentType; + } + mime = mime.trim(); + } + return mime; + } + + private static final Pattern CHARSET_PATTERN = Pattern + .compile("charset=[\"']?([.[^; \"']]*)[\"']?"); + + /** + * Returns charset parameter value, NULL if not present, NULL if + * httpContentType is NULL. + * + * @param httpContentType the HTTP content type + * @return The content type encoding (upcased) + */ + static String getContentTypeEncoding(final String httpContentType) { + String encoding = null; + if (httpContentType != null) { + final int i = httpContentType.indexOf(";"); + if (i > -1) { + final String postMime = httpContentType.substring(i + 1); + final Matcher m = CHARSET_PATTERN.matcher(postMime); + encoding = m.find() ? m.group(1) : null; + encoding = encoding != null ? encoding.toUpperCase(Locale.US) : null; + } + } + return encoding; + } + + public static final Pattern ENCODING_PATTERN = Pattern.compile( + "<\\?xml.*encoding[\\s]*=[\\s]*((?:\".[^\"]*\")|(?:'.[^']*'))", + Pattern.MULTILINE); + + /** + * Returns the encoding declared in the , NULL if none. + * + * @param is InputStream to create the reader from. + * @param guessedEnc guessed encoding + * @return the encoding declared in the + * @throws IOException thrown if there is a problem reading the stream. + */ + private static String getXmlProlog(final InputStream is, final String guessedEnc) + throws IOException { + String encoding = null; + if (guessedEnc != null) { + final byte[] bytes = new byte[BUFFER_SIZE]; + is.mark(BUFFER_SIZE); + int offset = 0; + int max = BUFFER_SIZE; + int c = is.read(bytes, offset, max); + int firstGT = -1; + String xmlProlog = ""; // avoid possible NPE warning (cannot happen; this just silences the warning) + while (c != -1 && firstGT == -1 && offset < BUFFER_SIZE) { + offset += c; + max -= c; + c = is.read(bytes, offset, max); + xmlProlog = new String(bytes, 0, offset, guessedEnc); + firstGT = xmlProlog.indexOf('>'); + } + if (firstGT == -1) { + if (c == -1) { + throw new IOException("Unexpected end of XML stream"); + } else { + throw new IOException( + "XML prolog or ROOT element not found on first " + + offset + " bytes"); + } + } + final int bytesRead = offset; + if (bytesRead > 0) { + is.reset(); + final BufferedReader bReader = new BufferedReader(new StringReader( + xmlProlog.substring(0, firstGT + 1))); + final StringBuffer prolog = new StringBuffer(); + String line = bReader.readLine(); + while (line != null) { + prolog.append(line); + line = bReader.readLine(); + } + final Matcher m = ENCODING_PATTERN.matcher(prolog); + if (m.find()) { + encoding = m.group(1).toUpperCase(); + encoding = encoding.substring(1, encoding.length() - 1); + } + } + } + return encoding; + } + + /** + * Indicates if the MIME type belongs to the APPLICATION XML family. + * + * @param mime The mime type + * @return true if the mime type belongs to the APPLICATION XML family, + * otherwise false + */ + static boolean isAppXml(final String mime) { + return mime != null && + (mime.equals("application/xml") || + mime.equals("application/xml-dtd") || + mime.equals("application/xml-external-parsed-entity") || + mime.startsWith("application/") && mime.endsWith("+xml")); + } + + /** + * Indicates if the MIME type belongs to the TEXT XML family. + * + * @param mime The mime type + * @return true if the mime type belongs to the TEXT XML family, + * otherwise false + */ + static boolean isTextXml(final String mime) { + return mime != null && + (mime.equals("text/xml") || + mime.equals("text/xml-external-parsed-entity") || + mime.startsWith("text/") && mime.endsWith("+xml")); + } + + private static final String RAW_EX_1 = + "Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] encoding mismatch"; + + private static final String RAW_EX_2 = + "Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] unknown BOM"; + + private static final String HTTP_EX_1 = + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], BOM must be NULL"; + + private static final String HTTP_EX_2 = + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], encoding mismatch"; + + private static final String HTTP_EX_3 = + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], Invalid MIME"; + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java" new file mode 100644 index 0000000000000000000000000000000000000000..0037100c3d977c22bebdb1d11a5b0323629de5ef --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/XmlStreamReaderException.java" @@ -0,0 +1,136 @@ +/* + * 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.input; + +import java.io.IOException; + +/** + * The XmlStreamReaderException is thrown by the XmlStreamReader constructors if + * the charset encoding can not be determined according to the XML 1.0 + * specification and RFC 3023. + *

+ * The exception returns the unconsumed InputStream to allow the application to + * do an alternate processing with the stream. Note that the original + * InputStream given to the XmlStreamReader cannot be used as that one has been + * already read. + * + * @version $Id: XmlStreamReaderException.java 1415850 2012-11-30 20:51:39Z ggregory $ + * @since 2.0 + */ +public class XmlStreamReaderException extends IOException { + + private static final long serialVersionUID = 1L; + + private final String bomEncoding; + + private final String xmlGuessEncoding; + + private final String xmlEncoding; + + private final String contentTypeMime; + + private final String contentTypeEncoding; + + /** + * Creates an exception instance if the charset encoding could not be + * determined. + *

+ * Instances of this exception are thrown by the XmlStreamReader. + * + * @param msg message describing the reason for the exception. + * @param bomEnc BOM encoding. + * @param xmlGuessEnc XML guess encoding. + * @param xmlEnc XML prolog encoding. + */ + public XmlStreamReaderException(final String msg, final String bomEnc, + final String xmlGuessEnc, final String xmlEnc) { + this(msg, null, null, bomEnc, xmlGuessEnc, xmlEnc); + } + + /** + * Creates an exception instance if the charset encoding could not be + * determined. + *

+ * Instances of this exception are thrown by the XmlStreamReader. + * + * @param msg message describing the reason for the exception. + * @param ctMime MIME type in the content-type. + * @param ctEnc encoding in the content-type. + * @param bomEnc BOM encoding. + * @param xmlGuessEnc XML guess encoding. + * @param xmlEnc XML prolog encoding. + */ + public XmlStreamReaderException(final String msg, final String ctMime, final String ctEnc, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc) { + super(msg); + contentTypeMime = ctMime; + contentTypeEncoding = ctEnc; + bomEncoding = bomEnc; + xmlGuessEncoding = xmlGuessEnc; + xmlEncoding = xmlEnc; + } + + /** + * Returns the BOM encoding found in the InputStream. + * + * @return the BOM encoding, null if none. + */ + public String getBomEncoding() { + return bomEncoding; + } + + /** + * Returns the encoding guess based on the first bytes of the InputStream. + * + * @return the encoding guess, null if it couldn't be guessed. + */ + public String getXmlGuessEncoding() { + return xmlGuessEncoding; + } + + /** + * Returns the encoding found in the XML prolog of the InputStream. + * + * @return the encoding of the XML prolog, null if none. + */ + public String getXmlEncoding() { + return xmlEncoding; + } + + /** + * Returns the MIME type in the content-type used to attempt determining the + * encoding. + * + * @return the MIME type in the content-type, null if there was not + * content-type or the encoding detection did not involve HTTP. + */ + public String getContentTypeMime() { + return contentTypeMime; + } + + /** + * Returns the encoding in the content-type used to attempt determining the + * encoding. + * + * @return the encoding in the content-type, null if there was not + * content-type, no encoding in it or the encoding detection did not + * involve HTTP. + */ + public String getContentTypeEncoding() { + return contentTypeEncoding; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/package.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/package.html" new file mode 100644 index 0000000000000000000000000000000000000000..440fa0f7ee52a73adc66a0d95aadb56cc3ebea7c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/input/package.html" @@ -0,0 +1,25 @@ + + + + +

+This package provides implementations of input classes, such as +InputStream and Reader. +

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationListener.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationListener.java" new file mode 100644 index 0000000000000000000000000000000000000000..1bff081f07bee6b665efcb4fd300105d84637a8c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationListener.java" @@ -0,0 +1,86 @@ +/* + * 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.monitor; +import java.io.File; + +/** + * A listener that receives events of file system modifications. + *

+ * Register {@link FileAlterationListener}s with a {@link FileAlterationObserver}. + * + * @see FileAlterationObserver + * @version $Id: FileAlterationListener.java 1304052 2012-03-22 20:55:29Z ggregory $ + * @since 2.0 + */ +public interface FileAlterationListener { + + /** + * File system observer started checking event. + * + * @param observer The file system observer + */ + void onStart(final FileAlterationObserver observer); + + /** + * Directory created Event. + * + * @param directory The directory created + */ + void onDirectoryCreate(final File directory); + + /** + * Directory changed Event. + * + * @param directory The directory changed + */ + void onDirectoryChange(final File directory); + + /** + * Directory deleted Event. + * + * @param directory The directory deleted + */ + void onDirectoryDelete(final File directory); + + /** + * File created Event. + * + * @param file The file created + */ + void onFileCreate(final File file); + + /** + * File changed Event. + * + * @param file The file changed + */ + void onFileChange(final File file); + + /** + * File deleted Event. + * + * @param file The file deleted + */ + void onFileDelete(final File file); + + /** + * File system observer finished checking event. + * + * @param observer The file system observer + */ + void onStop(final FileAlterationObserver observer); +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.java" new file mode 100644 index 0000000000000000000000000000000000000000..9afad6e853839d5448502ffb89bb66ef2df8fecd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.java" @@ -0,0 +1,94 @@ +/* + * 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.monitor; + +import java.io.File; + +/** + * Convenience {@link FileAlterationListener} implementation that does nothing. + * + * @see FileAlterationObserver + * @version $Id: FileAlterationListenerAdaptor.java 1304062 2012-03-22 21:10:46Z sebb $ + * @since 2.0 + */ +public class FileAlterationListenerAdaptor implements FileAlterationListener { + + /** + * File system observer started checking event. + * + * @param observer The file system observer (ignored) + */ + public void onStart(final FileAlterationObserver observer) { + } + + /** + * Directory created Event. + * + * @param directory The directory created (ignored) + */ + public void onDirectoryCreate(final File directory) { + } + + /** + * Directory changed Event. + * + * @param directory The directory changed (ignored) + */ + public void onDirectoryChange(final File directory) { + } + + /** + * Directory deleted Event. + * + * @param directory The directory deleted (ignored) + */ + public void onDirectoryDelete(final File directory) { + } + + /** + * File created Event. + * + * @param file The file created (ignored) + */ + public void onFileCreate(final File file) { + } + + /** + * File changed Event. + * + * @param file The file changed (ignored) + */ + public void onFileChange(final File file) { + } + + /** + * File deleted Event. + * + * @param file The file deleted (ignored) + */ + public void onFileDelete(final File file) { + } + + /** + * File system observer finished checking event. + * + * @param observer The file system observer (ignored) + */ + public void onStop(final FileAlterationObserver observer) { + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java" new file mode 100644 index 0000000000000000000000000000000000000000..344371998db12de38d9db350998661d47df114f6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationMonitor.java" @@ -0,0 +1,193 @@ +/* + * 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.monitor; + +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ThreadFactory; + +/** + * A runnable that spawns a monitoring thread triggering any + * registered {@link FileAlterationObserver} at a specified interval. + * + * @see FileAlterationObserver + * @version $Id: FileAlterationMonitor.java 1415850 2012-11-30 20:51:39Z ggregory $ + * @since 2.0 + */ +public final class FileAlterationMonitor implements Runnable { + + private final long interval; + private final List observers = new CopyOnWriteArrayList(); + private Thread thread = null; + private ThreadFactory threadFactory; + private volatile boolean running = false; + + /** + * Construct a monitor with a default interval of 10 seconds. + */ + public FileAlterationMonitor() { + this(10000); + } + + /** + * Construct a monitor with the specified interval. + * + * @param interval The amount of time in miliseconds to wait between + * checks of the file system + */ + public FileAlterationMonitor(final long interval) { + this.interval = interval; + } + + /** + * Construct a monitor with the specified interval and set of observers. + * + * @param interval The amount of time in miliseconds to wait between + * checks of the file system + * @param observers The set of observers to add to the monitor. + */ + public FileAlterationMonitor(final long interval, final FileAlterationObserver... observers) { + this(interval); + if (observers != null) { + for (final FileAlterationObserver observer : observers) { + addObserver(observer); + } + } + } + + /** + * Return the interval. + * + * @return the interval + */ + public long getInterval() { + return interval; + } + + /** + * Set the thread factory. + * + * @param threadFactory the thread factory + */ + public synchronized void setThreadFactory(final ThreadFactory threadFactory) { + this.threadFactory = threadFactory; + } + + /** + * Add a file system observer to this monitor. + * + * @param observer The file system observer to add + */ + public void addObserver(final FileAlterationObserver observer) { + if (observer != null) { + observers.add(observer); + } + } + + /** + * Remove a file system observer from this monitor. + * + * @param observer The file system observer to remove + */ + public void removeObserver(final FileAlterationObserver observer) { + if (observer != null) { + while (observers.remove(observer)) { + } + } + } + + /** + * Returns the set of {@link FileAlterationObserver} registered with + * this monitor. + * + * @return The set of {@link FileAlterationObserver} + */ + public Iterable getObservers() { + return observers; + } + + /** + * Start monitoring. + * + * @throws Exception if an error occurs initializing the observer + */ + public synchronized void start() throws Exception { + if (running) { + throw new IllegalStateException("Monitor is already running"); + } + for (final FileAlterationObserver observer : observers) { + observer.initialize(); + } + running = true; + if (threadFactory != null) { + thread = threadFactory.newThread(this); + } else { + thread = new Thread(this); + } + thread.start(); + } + + /** + * Stop monitoring. + * + * @throws Exception if an error occurs initializing the observer + */ + public synchronized void stop() throws Exception { + stop(interval); + } + + /** + * Stop monitoring. + * + * @param stopInterval the amount of time in milliseconds to wait for the thread to finish. + * A value of zero will wait until the thread is finished (see {@link Thread#join(long)}). + * @throws Exception if an error occurs initializing the observer + * @since 2.1 + */ + public synchronized void stop(final long stopInterval) throws Exception { + if (running == false) { + throw new IllegalStateException("Monitor is not running"); + } + running = false; + try { + thread.join(stopInterval); + } catch (final InterruptedException e) { + Thread.currentThread().interrupt(); + } + for (final FileAlterationObserver observer : observers) { + observer.destroy(); + } + } + + /** + * Run. + */ + public void run() { + while (running) { + for (final FileAlterationObserver observer : observers) { + observer.checkAndNotify(); + } + if (!running) { + break; + } + try { + Thread.sleep(interval); + } catch (final InterruptedException ignored) { + } + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java" new file mode 100644 index 0000000000000000000000000000000000000000..d28248dbff1ffe535f91d3b6752ca851695468bc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileAlterationObserver.java" @@ -0,0 +1,474 @@ +/* + * 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.monitor; + +import java.io.File; +import java.io.FileFilter; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOCase; +import org.apache.commons.io.comparator.NameFileComparator; + +/** + * FileAlterationObserver represents the state of files below a root directory, + * checking the filesystem and notifying listeners of create, change or + * delete events. + *

+ * To use this implementation: + *

    + *
  • Create {@link FileAlterationListener} implementation(s) that process + * the file/directory create, change and delete events
  • + *
  • Register the listener(s) with a {@link FileAlterationObserver} for + * the appropriate directory.
  • + *
  • Either register the observer(s) with a {@link FileAlterationMonitor} or + * run manually.
  • + *
+ * + *

Basic Usage

+ * Create a {@link FileAlterationObserver} for the directory and register the listeners: + *
+ *      File directory = new File(new File("."), "src");
+ *      FileAlterationObserver observer = new FileAlterationObserver(directory);
+ *      observer.addListener(...);
+ *      observer.addListener(...);
+ * 
+ * To manually observe a directory, initialize the observer and invoked the + * {@link #checkAndNotify()} method as required: + *
+ *      // intialize
+ *      observer.init();
+ *      ...
+ *      // invoke as required
+ *      observer.checkAndNotify();
+ *      ...
+ *      observer.checkAndNotify();
+ *      ...
+ *      // finished
+ *      observer.finish();
+ * 
+ * Alternatively, register the oberver(s) with a {@link FileAlterationMonitor}, + * which creates a new thread, invoking the observer at the specified interval: + *
+ *      long interval = ...
+ *      FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
+ *      monitor.addObserver(observer);
+ *      monitor.start();
+ *      ...
+ *      monitor.stop();
+ * 
+ * + *

File Filters

+ * This implementation can monitor portions of the file system + * by using {@link FileFilter}s to observe only the files and/or directories + * that are of interest. This makes it more efficient and reduces the + * noise from unwanted file system events. + *

+ * Commons IO has a good range of + * useful, ready made + * File Filter + * implementations for this purpose. + *

+ * For example, to only observe 1) visible directories and 2) files with a ".java" suffix + * in a root directory called "src" you could set up a {@link FileAlterationObserver} in the following + * way: + *

+ *      // Create a FileFilter
+ *      IOFileFilter directories = FileFilterUtils.and(
+ *                                      FileFilterUtils.directoryFileFilter(),
+ *                                      HiddenFileFilter.VISIBLE);
+ *      IOFileFilter files       = FileFilterUtils.and(
+ *                                      FileFilterUtils.fileFileFilter(),
+ *                                      FileFilterUtils.suffixFileFilter(".java"));
+ *      IOFileFilter filter = FileFilterUtils.or(directories, files);
+ *
+ *      // Create the File system observer and register File Listeners
+ *      FileAlterationObserver observer = new FileAlterationObserver(new File("src"), filter);
+ *      observer.addListener(...);
+ *      observer.addListener(...);
+ * 
+ * + *

FileEntry

+ * {@link FileEntry} represents the state of a file or directory, capturing + * {@link File} attributes at a point in time. Custom implementations of + * {@link FileEntry} can be used to capture additional properties that the + * basic implementation does not support. The {@link FileEntry#refresh(File)} + * method is used to determine if a file or directory has changed since the last + * check and stores the current state of the {@link File}'s properties. + * + * @see FileAlterationListener + * @see FileAlterationMonitor + * @version $Id: FileAlterationObserver.java 1686747 2015-06-21 18:44:49Z krosenvold $ + * @since 2.0 + */ +public class FileAlterationObserver implements Serializable { + + private static final long serialVersionUID = 1185122225658782848L; + private final List listeners = new CopyOnWriteArrayList(); + private final FileEntry rootEntry; + private final FileFilter fileFilter; + private final Comparator comparator; + + /** + * Construct an observer for the specified directory. + * + * @param directoryName the name of the directory to observe + */ + public FileAlterationObserver(final String directoryName) { + this(new File(directoryName)); + } + + /** + * Construct an observer for the specified directory and file filter. + * + * @param directoryName the name of the directory to observe + * @param fileFilter The file filter or null if none + */ + public FileAlterationObserver(final String directoryName, final FileFilter fileFilter) { + this(new File(directoryName), fileFilter); + } + + /** + * Construct an observer for the specified directory, file filter and + * file comparator. + * + * @param directoryName the name of the directory to observe + * @param fileFilter The file filter or null if none + * @param caseSensitivity what case sensitivity to use comparing file names, null means system sensitive + */ + public FileAlterationObserver(final String directoryName, final FileFilter fileFilter, + final IOCase caseSensitivity) { + this(new File(directoryName), fileFilter, caseSensitivity); + } + + /** + * Construct an observer for the specified directory. + * + * @param directory the directory to observe + */ + public FileAlterationObserver(final File directory) { + this(directory, null); + } + + /** + * Construct an observer for the specified directory and file filter. + * + * @param directory the directory to observe + * @param fileFilter The file filter or null if none + */ + public FileAlterationObserver(final File directory, final FileFilter fileFilter) { + this(directory, fileFilter, null); + } + + /** + * Construct an observer for the specified directory, file filter and + * file comparator. + * + * @param directory the directory to observe + * @param fileFilter The file filter or null if none + * @param caseSensitivity what case sensitivity to use comparing file names, null means system sensitive + */ + public FileAlterationObserver(final File directory, final FileFilter fileFilter, final IOCase caseSensitivity) { + this(new FileEntry(directory), fileFilter, caseSensitivity); + } + + /** + * Construct an observer for the specified directory, file filter and + * file comparator. + * + * @param rootEntry the root directory to observe + * @param fileFilter The file filter or null if none + * @param caseSensitivity what case sensitivity to use comparing file names, null means system sensitive + */ + protected FileAlterationObserver(final FileEntry rootEntry, final FileFilter fileFilter, + final IOCase caseSensitivity) { + if (rootEntry == null) { + throw new IllegalArgumentException("Root entry is missing"); + } + if (rootEntry.getFile() == null) { + throw new IllegalArgumentException("Root directory is missing"); + } + this.rootEntry = rootEntry; + this.fileFilter = fileFilter; + if (caseSensitivity == null || caseSensitivity.equals(IOCase.SYSTEM)) { + this.comparator = NameFileComparator.NAME_SYSTEM_COMPARATOR; + } else if (caseSensitivity.equals(IOCase.INSENSITIVE)) { + this.comparator = NameFileComparator.NAME_INSENSITIVE_COMPARATOR; + } else { + this.comparator = NameFileComparator.NAME_COMPARATOR; + } + } + + /** + * Return the directory being observed. + * + * @return the directory being observed + */ + public File getDirectory() { + return rootEntry.getFile(); + } + + /** + * Return the fileFilter. + * + * @return the fileFilter + * @since 2.1 + */ + public FileFilter getFileFilter() { + return fileFilter; + } + + /** + * Add a file system listener. + * + * @param listener The file system listener + */ + public void addListener(final FileAlterationListener listener) { + if (listener != null) { + listeners.add(listener); + } + } + + /** + * Remove a file system listener. + * + * @param listener The file system listener + */ + public void removeListener(final FileAlterationListener listener) { + if (listener != null) { + while (listeners.remove(listener)) { + } + } + } + + /** + * Returns the set of registered file system listeners. + * + * @return The file system listeners + */ + public Iterable getListeners() { + return listeners; + } + + /** + * Initialize the observer. + * + * @throws Exception if an error occurs + */ + public void initialize() throws Exception { + rootEntry.refresh(rootEntry.getFile()); + final FileEntry[] children = doListFiles(rootEntry.getFile(), rootEntry); + rootEntry.setChildren(children); + } + + /** + * Final processing. + * + * @throws Exception if an error occurs + */ + public void destroy() throws Exception { + } + + /** + * Check whether the file and its chlidren have been created, modified or deleted. + */ + public void checkAndNotify() { + + /* fire onStart() */ + for (final FileAlterationListener listener : listeners) { + listener.onStart(this); + } + + /* fire directory/file events */ + final File rootFile = rootEntry.getFile(); + if (rootFile.exists()) { + checkAndNotify(rootEntry, rootEntry.getChildren(), listFiles(rootFile)); + } else if (rootEntry.isExists()) { + checkAndNotify(rootEntry, rootEntry.getChildren(), FileUtils.EMPTY_FILE_ARRAY); + } else { + // Didn't exist and still doesn't + } + + /* fire onStop() */ + for (final FileAlterationListener listener : listeners) { + listener.onStop(this); + } + } + + /** + * Compare two file lists for files which have been created, modified or deleted. + * + * @param parent The parent entry + * @param previous The original list of files + * @param files The current list of files + */ + private void checkAndNotify(final FileEntry parent, final FileEntry[] previous, final File[] files) { + int c = 0; + final FileEntry[] current = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES; + for (final FileEntry entry : previous) { + while (c < files.length && comparator.compare(entry.getFile(), files[c]) > 0) { + current[c] = createFileEntry(parent, files[c]); + doCreate(current[c]); + c++; + } + if (c < files.length && comparator.compare(entry.getFile(), files[c]) == 0) { + doMatch(entry, files[c]); + checkAndNotify(entry, entry.getChildren(), listFiles(files[c])); + current[c] = entry; + c++; + } else { + checkAndNotify(entry, entry.getChildren(), FileUtils.EMPTY_FILE_ARRAY); + doDelete(entry); + } + } + for (; c < files.length; c++) { + current[c] = createFileEntry(parent, files[c]); + doCreate(current[c]); + } + parent.setChildren(current); + } + + /** + * Create a new file entry for the specified file. + * + * @param parent The parent file entry + * @param file The file to create an entry for + * @return A new file entry + */ + private FileEntry createFileEntry(final FileEntry parent, final File file) { + final FileEntry entry = parent.newChildInstance(file); + entry.refresh(file); + final FileEntry[] children = doListFiles(file, entry); + entry.setChildren(children); + return entry; + } + + /** + * List the files + * @param file The file to list files for + * @param entry the parent entry + * @return The child files + */ + private FileEntry[] doListFiles(File file, FileEntry entry) { + final File[] files = listFiles(file); + final FileEntry[] children = files.length > 0 ? new FileEntry[files.length] : FileEntry.EMPTY_ENTRIES; + for (int i = 0; i < files.length; i++) { + children[i] = createFileEntry(entry, files[i]); + } + return children; + } + + /** + * Fire directory/file created events to the registered listeners. + * + * @param entry The file entry + */ + private void doCreate(final FileEntry entry) { + for (final FileAlterationListener listener : listeners) { + if (entry.isDirectory()) { + listener.onDirectoryCreate(entry.getFile()); + } else { + listener.onFileCreate(entry.getFile()); + } + } + final FileEntry[] children = entry.getChildren(); + for (final FileEntry aChildren : children) { + doCreate(aChildren); + } + } + + /** + * Fire directory/file change events to the registered listeners. + * + * @param entry The previous file system entry + * @param file The current file + */ + private void doMatch(final FileEntry entry, final File file) { + if (entry.refresh(file)) { + for (final FileAlterationListener listener : listeners) { + if (entry.isDirectory()) { + listener.onDirectoryChange(file); + } else { + listener.onFileChange(file); + } + } + } + } + + /** + * Fire directory/file delete events to the registered listeners. + * + * @param entry The file entry + */ + private void doDelete(final FileEntry entry) { + for (final FileAlterationListener listener : listeners) { + if (entry.isDirectory()) { + listener.onDirectoryDelete(entry.getFile()); + } else { + listener.onFileDelete(entry.getFile()); + } + } + } + + /** + * List the contents of a directory + * + * @param file The file to list the contents of + * @return the directory contents or a zero length array if + * the empty or the file is not a directory + */ + private File[] listFiles(final File file) { + File[] children = null; + if (file.isDirectory()) { + children = fileFilter == null ? file.listFiles() : file.listFiles(fileFilter); + } + if (children == null) { + children = FileUtils.EMPTY_FILE_ARRAY; + } + if (comparator != null && children.length > 1) { + Arrays.sort(children, comparator); + } + return children; + } + + /** + * Provide a String representation of this observer. + * + * @return a String representation of this observer + */ + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append(getClass().getSimpleName()); + builder.append("[file='"); + builder.append(getDirectory().getPath()); + builder.append('\''); + if (fileFilter != null) { + builder.append(", "); + builder.append(fileFilter.toString()); + } + builder.append(", listeners="); + builder.append(listeners.size()); + builder.append("]"); + return builder.toString(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileEntry.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileEntry.java" new file mode 100644 index 0000000000000000000000000000000000000000..bbd942bd5e58c37b6c864682b8bab9dd3145eff7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/FileEntry.java" @@ -0,0 +1,271 @@ +/* + * 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.monitor; + +import java.io.File; +import java.io.Serializable; + +/** + * The state of a file or directory, capturing the following {@link File} attributes at a point in time. + *
    + *
  • File Name (see {@link File#getName()})
  • + *
  • Exists - whether the file exists or not (see {@link File#exists()})
  • + *
  • Directory - whether the file is a directory or not (see {@link File#isDirectory()})
  • + *
  • Last Modified Date/Time (see {@link File#lastModified()})
  • + *
  • Length (see {@link File#length()}) - directories treated as zero
  • + *
  • Children - contents of a directory (see {@link File#listFiles(java.io.FileFilter)})
  • + *
+ * + *

Custom Implementations

+ *

+ * If the state of additional {@link File} attributes is required then create a custom + * {@link FileEntry} with properties for those attributes. Override the + * {@link #newChildInstance(File)} to return a new instance of the appropriate type. + * You may also want to override the {@link #refresh(File)} method. + *

+ * @see FileAlterationObserver + * @since 2.0 + */ +public class FileEntry implements Serializable { + + private static final long serialVersionUID = -2505664948818681153L; + + static final FileEntry[] EMPTY_ENTRIES = new FileEntry[0]; + + private final FileEntry parent; + private FileEntry[] children; + private final File file; + private String name; + private boolean exists; + private boolean directory; + private long lastModified; + private long length; + + /** + * Construct a new monitor for a specified {@link File}. + * + * @param file The file being monitored + */ + public FileEntry(final File file) { + this(null, file); + } + + /** + * Construct a new monitor for a specified {@link File}. + * + * @param parent The parent + * @param file The file being monitored + */ + public FileEntry(final FileEntry parent, final File file) { + if (file == null) { + throw new IllegalArgumentException("File is missing"); + } + this.file = file; + this.parent = parent; + this.name = file.getName(); + } + + /** + * Refresh the attributes from the {@link File}, indicating + * whether the file has changed. + *

+ * This implementation refreshes the name, exists, + * directory, lastModified and length + * properties. + *

+ * The exists, directory, lastModified + * and length properties are compared for changes + * + * @param file the file instance to compare to + * @return {@code true} if the file has changed, otherwise {@code false} + */ + public boolean refresh(final File file) { + + // cache original values + final boolean origExists = exists; + final long origLastModified = lastModified; + final boolean origDirectory = directory; + final long origLength = length; + + // refresh the values + name = file.getName(); + exists = file.exists(); + directory = exists && file.isDirectory(); + lastModified = exists ? file.lastModified() : 0; + length = exists && !directory ? file.length() : 0; + + // Return if there are changes + return exists != origExists || + lastModified != origLastModified || + directory != origDirectory || + length != origLength; + } + + /** + * Create a new child instance. + *

+ * Custom implementations should override this method to return + * a new instance of the appropriate type. + * + * @param file The child file + * @return a new child instance + */ + public FileEntry newChildInstance(final File file) { + return new FileEntry(this, file); + } + + /** + * Return the parent entry. + * + * @return the parent entry + */ + public FileEntry getParent() { + return parent; + } + + /** + * Return the level + * + * @return the level + */ + public int getLevel() { + return parent == null ? 0 : parent.getLevel() + 1; + } + + /** + * Return the directory's files. + * + * @return This directory's files or an empty + * array if the file is not a directory or the + * directory is empty + */ + public FileEntry[] getChildren() { + return children != null ? children : EMPTY_ENTRIES; + } + + /** + * Set the directory's files. + * + * @param children This directory's files, may be null + */ + public void setChildren(final FileEntry[] children) { + this.children = children; + } + + /** + * Return the file being monitored. + * + * @return the file being monitored + */ + public File getFile() { + return file; + } + + /** + * Return the file name. + * + * @return the file name + */ + public String getName() { + return name; + } + + /** + * Set the file name. + * + * @param name the file name + */ + public void setName(final String name) { + this.name = name; + } + + /** + * Return the last modified time from the last time it + * was checked. + * + * @return the last modified time + */ + public long getLastModified() { + return lastModified; + } + + /** + * Return the last modified time from the last time it + * was checked. + * + * @param lastModified The last modified time + */ + public void setLastModified(final long lastModified) { + this.lastModified = lastModified; + } + + /** + * Return the length. + * + * @return the length + */ + public long getLength() { + return length; + } + + /** + * Set the length. + * + * @param length the length + */ + public void setLength(final long length) { + this.length = length; + } + + /** + * Indicate whether the file existed the last time it + * was checked. + * + * @return whether the file existed + */ + public boolean isExists() { + return exists; + } + + /** + * Set whether the file existed the last time it + * was checked. + * + * @param exists whether the file exists or not + */ + public void setExists(final boolean exists) { + this.exists = exists; + } + + /** + * Indicate whether the file is a directory or not. + * + * @return whether the file is a directory or not + */ + public boolean isDirectory() { + return directory; + } + + /** + * Set whether the file is a directory or not. + * + * @param directory whether the file is a directory or not + */ + public void setDirectory(final boolean directory) { + this.directory = directory; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/package.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/package.html" new file mode 100644 index 0000000000000000000000000000000000000000..82c1eaede9472eb1cb323c8d5899ccb69050f987 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/monitor/package.html" @@ -0,0 +1,25 @@ + + + + +

+This package provides a component for monitoring file system events +(directory and file create, update and delete events). +

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/AppendableOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/AppendableOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..379be10e079f2a9230eb4bfd2225a89945594c76 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/AppendableOutputStream.java" @@ -0,0 +1,66 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * OutputStream implementation that writes the data to an {@link Appendable} + * Object. + *

+ * For example, can be used with any {@link java.io.Writer} or a {@link java.lang.StringBuilder} + * or {@link java.lang.StringBuffer}. + * + * @since 2.5 + * @see java.lang.Appendable + * @version $Id: AppendableOutputStream.java 1687815 2015-06-26 17:18:56Z krosenvold $ + */ +public class AppendableOutputStream extends OutputStream { + + private final T appendable; + + /** + * Construct a new instance with the specified appendable. + * + * @param appendable the appendable to write to + */ + public AppendableOutputStream(T appendable) { + this.appendable = appendable; + } + + /** + * Write a character to the underlying appendable. + * + * @param b the character to write + * @throws IOException upon error + */ + @Override + public void write(int b) throws IOException { + appendable.append((char)b); + } + + /** + * Return the target appendable. + * + * @return the target appendable + */ + public T getAppendable() { + return appendable; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..1f149ffa870d4f4d9e1945669f656fd9ebe2f973 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/BrokenOutputStream.java" @@ -0,0 +1,85 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * Broken output stream. This stream always throws an {@link IOException} from + * all {@link OutputStream} methods. + *

+ * This class is mostly useful for testing error handling in code that uses an + * output stream. + * + * @since 2.0 + */ +public class BrokenOutputStream extends OutputStream { + + /** + * The exception that is thrown by all methods of this class. + */ + private final IOException exception; + + /** + * Creates a new stream that always throws the given exception. + * + * @param exception the exception to be thrown + */ + public BrokenOutputStream(final IOException exception) { + this.exception = exception; + } + + /** + * Creates a new stream that always throws an {@link IOException} + */ + public BrokenOutputStream() { + this(new IOException("Broken output stream")); + } + + /** + * Throws the configured exception. + * + * @param b ignored + * @throws IOException always thrown + */ + @Override + public void write(final int b) throws IOException { + throw exception; + } + + /** + * Throws the configured exception. + * + * @throws IOException always thrown + */ + @Override + public void flush() throws IOException { + throw exception; + } + + /** + * Throws the configured exception. + * + * @throws IOException always thrown + */ + @Override + public void close() throws IOException { + throw exception; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..ba87e9b3dc1b4f605b1d6849bb7c8d639441bcf3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ByteArrayOutputStream.java" @@ -0,0 +1,420 @@ +/* + * 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.output; + +import static org.apache.commons.io.IOUtils.EOF; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.SequenceInputStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.io.input.ClosedInputStream; + +/** + * This class implements an output stream in which the data is + * written into a byte array. The buffer automatically grows as data + * is written to it. + *

+ * The data can be retrieved using toByteArray() and + * toString(). + *

+ * Closing a {@code ByteArrayOutputStream} has no effect. The methods in + * this class can be called after the stream has been closed without + * generating an {@code IOException}. + *

+ * This is an alternative implementation of the {@link java.io.ByteArrayOutputStream} + * class. The original implementation only allocates 32 bytes at the beginning. + * As this class is designed for heavy duty it starts at 1024 bytes. In contrast + * to the original it doesn't reallocate the whole memory block but allocates + * additional buffers. This way no buffers need to be garbage collected and + * the contents don't have to be copied to the new buffer. This class is + * designed to behave exactly like the original. The only exception is the + * deprecated toString(int) method that has been ignored. + * + * @version $Id: ByteArrayOutputStream.java 1612034 2014-07-20 06:35:19Z ggregory $ + */ +public class ByteArrayOutputStream extends OutputStream { + + /** A singleton empty byte array. */ + private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; + + /** The list of buffers, which grows and never reduces. */ + private final List buffers = new ArrayList(); + /** The index of the current buffer. */ + private int currentBufferIndex; + /** The total count of bytes in all the filled buffers. */ + private int filledBufferSum; + /** The current buffer. */ + private byte[] currentBuffer; + /** The total count of bytes written. */ + private int count; + /** Flag to indicate if the buffers can be reused after reset */ + private boolean reuseBuffers = true; + + /** + * Creates a new byte array output stream. The buffer capacity is + * initially 1024 bytes, though its size increases if necessary. + */ + public ByteArrayOutputStream() { + this(1024); + } + + /** + * Creates a new byte array output stream, with a buffer capacity of + * the specified size, in bytes. + * + * @param size the initial size + * @throws IllegalArgumentException if size is negative + */ + public ByteArrayOutputStream(final int size) { + if (size < 0) { + throw new IllegalArgumentException( + "Negative initial size: " + size); + } + synchronized (this) { + needNewBuffer(size); + } + } + + /** + * Makes a new buffer available either by allocating + * a new one or re-cycling an existing one. + * + * @param newcount the size of the buffer if one is created + */ + private void needNewBuffer(final int newcount) { + if (currentBufferIndex < buffers.size() - 1) { + //Recycling old buffer + filledBufferSum += currentBuffer.length; + + currentBufferIndex++; + currentBuffer = buffers.get(currentBufferIndex); + } else { + //Creating new buffer + int newBufferSize; + if (currentBuffer == null) { + newBufferSize = newcount; + filledBufferSum = 0; + } else { + newBufferSize = Math.max( + currentBuffer.length << 1, + newcount - filledBufferSum); + filledBufferSum += currentBuffer.length; + } + + currentBufferIndex++; + currentBuffer = new byte[newBufferSize]; + buffers.add(currentBuffer); + } + } + + /** + * Write the bytes to byte array. + * @param b the bytes to write + * @param off The start offset + * @param len The number of bytes to write + */ + @Override + public void write(final byte[] b, final int off, final int len) { + if ((off < 0) + || (off > b.length) + || (len < 0) + || ((off + len) > b.length) + || ((off + len) < 0)) { + throw new IndexOutOfBoundsException(); + } else if (len == 0) { + return; + } + synchronized (this) { + final int newcount = count + len; + int remaining = len; + int inBufferPos = count - filledBufferSum; + while (remaining > 0) { + final int part = Math.min(remaining, currentBuffer.length - inBufferPos); + System.arraycopy(b, off + len - remaining, currentBuffer, inBufferPos, part); + remaining -= part; + if (remaining > 0) { + needNewBuffer(newcount); + inBufferPos = 0; + } + } + count = newcount; + } + } + + /** + * Write a byte to byte array. + * @param b the byte to write + */ + @Override + public synchronized void write(final int b) { + int inBufferPos = count - filledBufferSum; + if (inBufferPos == currentBuffer.length) { + needNewBuffer(count + 1); + inBufferPos = 0; + } + currentBuffer[inBufferPos] = (byte) b; + count++; + } + + /** + * Writes the entire contents of the specified input stream to this + * byte stream. Bytes from the input stream are read directly into the + * internal buffers of this streams. + * + * @param in the input stream to read from + * @return total number of bytes read from the input stream + * (and written to this stream) + * @throws IOException if an I/O error occurs while reading the input stream + * @since 1.4 + */ + public synchronized int write(final InputStream in) throws IOException { + int readCount = 0; + int inBufferPos = count - filledBufferSum; + int n = in.read(currentBuffer, inBufferPos, currentBuffer.length - inBufferPos); + while (n != EOF) { + readCount += n; + inBufferPos += n; + count += n; + if (inBufferPos == currentBuffer.length) { + needNewBuffer(currentBuffer.length); + inBufferPos = 0; + } + n = in.read(currentBuffer, inBufferPos, currentBuffer.length - inBufferPos); + } + return readCount; + } + + /** + * Return the current size of the byte array. + * @return the current size of the byte array + */ + public synchronized int size() { + return count; + } + + /** + * Closing a {@code ByteArrayOutputStream} has no effect. The methods in + * this class can be called after the stream has been closed without + * generating an {@code IOException}. + * + * @throws IOException never (this method should not declare this exception + * but it has to now due to backwards compatibility) + */ + @Override + public void close() throws IOException { + //nop + } + + /** + * @see java.io.ByteArrayOutputStream#reset() + */ + public synchronized void reset() { + count = 0; + filledBufferSum = 0; + currentBufferIndex = 0; + if (reuseBuffers) { + currentBuffer = buffers.get(currentBufferIndex); + } else { + //Throw away old buffers + currentBuffer = null; + int size = buffers.get(0).length; + buffers.clear(); + needNewBuffer(size); + reuseBuffers = true; + } + } + + /** + * Writes the entire contents of this byte stream to the + * specified output stream. + * + * @param out the output stream to write to + * @throws IOException if an I/O error occurs, such as if the stream is closed + * @see java.io.ByteArrayOutputStream#writeTo(OutputStream) + */ + public synchronized void writeTo(final OutputStream out) throws IOException { + int remaining = count; + for (final byte[] buf : buffers) { + final int c = Math.min(buf.length, remaining); + out.write(buf, 0, c); + remaining -= c; + if (remaining == 0) { + break; + } + } + } + + /** + * Fetches entire contents of an InputStream and represent + * same data as result InputStream. + *

+ * This method is useful where, + *

    + *
  • Source InputStream is slow.
  • + *
  • It has network resources associated, so we cannot keep it open for + * long time.
  • + *
  • It has network timeout associated.
  • + *
+ * It can be used in favor of {@link #toByteArray()}, since it + * avoids unnecessary allocation and copy of byte[].
+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input Stream to be fully buffered. + * @return A fully buffered stream. + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + public static InputStream toBufferedInputStream(final InputStream input) + throws IOException { + return toBufferedInputStream(input, 1024); + } + + /** + * Fetches entire contents of an InputStream and represent + * same data as result InputStream. + *

+ * This method is useful where, + *

    + *
  • Source InputStream is slow.
  • + *
  • It has network resources associated, so we cannot keep it open for + * long time.
  • + *
  • It has network timeout associated.
  • + *
+ * It can be used in favor of {@link #toByteArray()}, since it + * avoids unnecessary allocation and copy of byte[].
+ * This method buffers the input internally, so there is no need to use a + * BufferedInputStream. + * + * @param input Stream to be fully buffered. + * @param size the initial buffer size + * @return A fully buffered stream. + * @throws IOException if an I/O error occurs + * @since 2.5 + */ + public static InputStream toBufferedInputStream(final InputStream input, int size) + throws IOException { + // It does not matter if a ByteArrayOutputStream is not closed as close() is a no-op + @SuppressWarnings("resource") + final ByteArrayOutputStream output = new ByteArrayOutputStream(size); + output.write(input); + return output.toInputStream(); + } + + /** + * Gets the current contents of this byte stream as a Input Stream. The + * returned stream is backed by buffers of this stream, + * avoiding memory allocation and copy, thus saving space and time.
+ * + * @return the current contents of this output stream. + * @see java.io.ByteArrayOutputStream#toByteArray() + * @see #reset() + * @since 2.5 + */ + public synchronized InputStream toInputStream() { + int remaining = count; + if (remaining == 0) { + return new ClosedInputStream(); + } + final List list = new ArrayList(buffers.size()); + for (final byte[] buf : buffers) { + final int c = Math.min(buf.length, remaining); + list.add(new ByteArrayInputStream(buf, 0, c)); + remaining -= c; + if (remaining == 0) { + break; + } + } + reuseBuffers = false; + return new SequenceInputStream(Collections.enumeration(list)); + } + + /** + * Gets the curent contents of this byte stream as a byte array. + * The result is independent of this stream. + * + * @return the current contents of this output stream, as a byte array + * @see java.io.ByteArrayOutputStream#toByteArray() + */ + public synchronized byte[] toByteArray() { + int remaining = count; + if (remaining == 0) { + return EMPTY_BYTE_ARRAY; + } + final byte newbuf[] = new byte[remaining]; + int pos = 0; + for (final byte[] buf : buffers) { + final int c = Math.min(buf.length, remaining); + System.arraycopy(buf, 0, newbuf, pos, c); + pos += c; + remaining -= c; + if (remaining == 0) { + break; + } + } + return newbuf; + } + + /** + * Gets the curent contents of this byte stream as a string + * using the platform default charset. + * @return the contents of the byte array as a String + * @see java.io.ByteArrayOutputStream#toString() + * @deprecated 2.5 use {@link #toString(String)} instead + */ + @Override + @Deprecated + public String toString() { + // make explicit the use of the default charset + return new String(toByteArray(), Charset.defaultCharset()); + } + + /** + * Gets the curent contents of this byte stream as a string + * using the specified encoding. + * + * @param enc the name of the character encoding + * @return the string converted from the byte array + * @throws UnsupportedEncodingException if the encoding is not supported + * @see java.io.ByteArrayOutputStream#toString(String) + */ + public String toString(final String enc) throws UnsupportedEncodingException { + return new String(toByteArray(), enc); + } + + /** + * Gets the curent contents of this byte stream as a string + * using the specified encoding. + * + * @param charset the character encoding + * @return the string converted from the byte array + * @see java.io.ByteArrayOutputStream#toString(String) + * @since 2.5 + */ + public String toString(final Charset charset) { + return new String(toByteArray(), charset); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..995ca0d10b091e7436c2c4c4da886049af5f4703 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ChunkedOutputStream.java" @@ -0,0 +1,87 @@ +/* + * 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.output; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * OutputStream which breaks larger output blocks into chunks. + * Native code may need to copy the input array; if the write buffer + * is very large this can cause OOME. + * + * @since 2.5 + */ +public class ChunkedOutputStream extends FilterOutputStream { + + /** + * The default chunk size to use, i.e. {@value} bytes. + */ + private static final int DEFAULT_CHUNK_SIZE = 1024 * 4; + + /** + * The maximum chunk size to us when writing data arrays + */ + private final int chunkSize; + + /** + * Creates a new stream that uses the specified chunk size. + * + * @param stream the stream to wrap + * @param chunkSize the chunk size to use; must be a positive number. + * @throws IllegalArgumentException if the chunk size is <= 0 + */ + public ChunkedOutputStream(final OutputStream stream, int chunkSize) { + super(stream); + if (chunkSize <= 0) { + throw new IllegalArgumentException(); + } + this.chunkSize = chunkSize; + } + + /** + * Creates a new stream that uses a chunk size of {@link #DEFAULT_CHUNK_SIZE}. + * + * @param stream the stream to wrap + */ + public ChunkedOutputStream(final OutputStream stream) { + this(stream, DEFAULT_CHUNK_SIZE); + } + + /** + * Writes the data buffer in chunks to the underlying stream + * + * @param data the data to write + * @param srcOffset the offset + * @param length the length of data to write + * + * @throws IOException if an I/O error occurs. + */ + @Override + public void write(byte[] data, int srcOffset, int length) throws IOException { + int bytes = length; + int dstOffset = srcOffset; + while(bytes > 0) { + int chunk = Math.min(bytes, chunkSize); + out.write(data, dstOffset, chunk); + bytes -= chunk; + dstOffset += chunk; + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ChunkedWriter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ChunkedWriter.java" new file mode 100644 index 0000000000000000000000000000000000000000..13826debc9ede17a8a0fcb0129cc82f031cc926e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ChunkedWriter.java" @@ -0,0 +1,85 @@ +/* + * 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.output; + +import java.io.FilterWriter; +import java.io.IOException; +import java.io.Writer; + +/** + * Writer which breaks larger output blocks into chunks. + * Native code may need to copy the input array; if the write buffer + * is very large this can cause OOME. + * + * @since 2.5 + */ +public class ChunkedWriter extends FilterWriter { + + /** + * The default chunk size to use, i.e. {@value} bytes. + */ + private static final int DEFAULT_CHUNK_SIZE = 1024 * 4; + + /** + * The maximum chunk size to us when writing data arrays + */ + private final int chunkSize; + + /** + * Creates a new writer that uses the specified chunk size. + * + * @param writer the writer to wrap + * @param chunkSize the chunk size to use; must be a positive number. + * @throws IllegalArgumentException if the chunk size is <= 0 + */ + public ChunkedWriter(final Writer writer, int chunkSize) { + super(writer); + if (chunkSize <= 0) { + throw new IllegalArgumentException(); + } + this.chunkSize = chunkSize; + } + + /** + * Creates a new writer that uses a chunk size of {@link #DEFAULT_CHUNK_SIZE} + * @param writer the writer to wrap + */ + public ChunkedWriter(final Writer writer) { + this(writer, DEFAULT_CHUNK_SIZE); + } + + /** + * writes the data buffer in chunks to the underlying writer + * @param data The data + * @param srcOffset the offset + * @param length the number of bytes to write + * + * @throws IOException upon error + */ + @Override + public void write(char[] data, int srcOffset, int length) throws IOException { + int bytes = length; + int dstOffset = srcOffset; + while(bytes > 0) { + int chunk = Math.min(bytes, chunkSize); + out.write(data, dstOffset, chunk); + bytes -= chunk; + dstOffset += chunk; + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..ded1c8887dbfd28e49e53f8caa15a53f903204fd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/CloseShieldOutputStream.java" @@ -0,0 +1,53 @@ +/* + * 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.output; + +import java.io.OutputStream; + +/** + * Proxy stream that prevents the underlying output stream from being closed. + *

+ * This class is typically used in cases where an output stream needs to be + * passed to a component that wants to explicitly close the stream even if + * other components would still use the stream for output. + *

+ * @version $Id: CloseShieldOutputStream.java 1674710 2015-04-20 00:25:55Z ggregory $ + * @since 1.4 + */ +public class CloseShieldOutputStream extends ProxyOutputStream { + + /** + * Creates a proxy that shields the given output stream from being + * closed. + * + * @param out underlying output stream + */ + public CloseShieldOutputStream(final OutputStream out) { + super(out); + } + + /** + * Replaces the underlying output stream with a {@link ClosedOutputStream} + * sentinel. The original output stream will remain open, but this proxy + * will appear closed. + */ + @Override + public void close() { + out = new ClosedOutputStream(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..d339abb546006c04270cfdbfdfcdd78459321491 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ClosedOutputStream.java" @@ -0,0 +1,51 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * Closed output stream. This stream throws an exception on all attempts to + * write something to the stream. + *

+ * Typically uses of this class include testing for corner cases in methods + * that accept an output stream and acting as a sentinel value instead of + * a {@code null} output stream. + * + * @version $Id: ClosedOutputStream.java 1471767 2013-04-24 23:24:19Z sebb $ + * @since 1.4 + */ +public class ClosedOutputStream extends OutputStream { + + /** + * A singleton. + */ + public static final ClosedOutputStream CLOSED_OUTPUT_STREAM = new ClosedOutputStream(); + + /** + * Throws an {@link IOException} to indicate that the stream is closed. + * + * @param b ignored + * @throws IOException always thrown + */ + @Override + public void write(final int b) throws IOException { + throw new IOException("write(" + b + ") failed: stream is closed"); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/CountingOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/CountingOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..7bad42b23fbbb4491f76650e5ffa231d8547dc6f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/CountingOutputStream.java" @@ -0,0 +1,124 @@ +/* + * 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.output; + +import java.io.OutputStream; + +/** + * A decorating output stream that counts the number of bytes that have passed + * through the stream so far. + *

+ * A typical use case would be during debugging, to ensure that data is being + * written as expected. + * + * @version $Id: CountingOutputStream.java 1415850 2012-11-30 20:51:39Z ggregory $ + */ +public class CountingOutputStream extends ProxyOutputStream { + + /** The count of bytes that have passed. */ + private long count = 0; + + /** + * Constructs a new CountingOutputStream. + * + * @param out the OutputStream to write to + */ + public CountingOutputStream( final OutputStream out ) { + super(out); + } + + //----------------------------------------------------------------------- + + /** + * Updates the count with the number of bytes that are being written. + * + * @param n number of bytes to be written to the stream + * @since 2.0 + */ + @Override + protected synchronized void beforeWrite(final int n) { + count += n; + } + + //----------------------------------------------------------------------- + /** + * The number of bytes that have passed through this stream. + *

+ * NOTE: From v1.3 this method throws an ArithmeticException if the + * count is greater than can be expressed by an int. + * See {@link #getByteCount()} for a method using a long. + * + * @return the number of bytes accumulated + * @throws ArithmeticException if the byte count is too large + */ + public int getCount() { + final long result = getByteCount(); + if (result > Integer.MAX_VALUE) { + throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int"); + } + return (int) result; + } + + /** + * Set the byte count back to 0. + *

+ * NOTE: From v1.3 this method throws an ArithmeticException if the + * count is greater than can be expressed by an int. + * See {@link #resetByteCount()} for a method using a long. + * + * @return the count previous to resetting + * @throws ArithmeticException if the byte count is too large + */ + public int resetCount() { + final long result = resetByteCount(); + if (result > Integer.MAX_VALUE) { + throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int"); + } + return (int) result; + } + + /** + * The number of bytes that have passed through this stream. + *

+ * NOTE: This method is an alternative for getCount(). + * It was added because that method returns an integer which will + * result in incorrect count for files over 2GB. + * + * @return the number of bytes accumulated + * @since 1.3 + */ + public synchronized long getByteCount() { + return this.count; + } + + /** + * Set the byte count back to 0. + *

+ * NOTE: This method is an alternative for resetCount(). + * It was added because that method returns an integer which will + * result in incorrect count for files over 2GB. + * + * @return the count previous to resetting + * @since 1.3 + */ + public synchronized long resetByteCount() { + final long tmp = this.count; + this.count = 0; + return tmp; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..56ad2ff8dc2c752f2f707c1f75843d38a48f3d03 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/DeferredFileOutputStream.java" @@ -0,0 +1,289 @@ +/* + * 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.output; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.io.IOUtils; + + +/** + * An output stream which will retain data in memory until a specified + * threshold is reached, and only then commit it to disk. If the stream is + * closed before the threshold is reached, the data will not be written to + * disk at all. + *

+ * This class originated in FileUpload processing. In this use case, you do + * not know in advance the size of the file being uploaded. If the file is small + * you want to store it in memory (for speed), but if the file is large you want + * to store it to file (to avoid memory issues). + * + * @version $Id: DeferredFileOutputStream.java 1686747 2015-06-21 18:44:49Z krosenvold $ + */ +public class DeferredFileOutputStream + extends ThresholdingOutputStream +{ + + // ----------------------------------------------------------- Data members + + + /** + * The output stream to which data will be written prior to the theshold + * being reached. + */ + private ByteArrayOutputStream memoryOutputStream; + + + /** + * The output stream to which data will be written at any given time. This + * will always be one of memoryOutputStream or + * diskOutputStream. + */ + private OutputStream currentOutputStream; + + + /** + * The file to which output will be directed if the threshold is exceeded. + */ + private File outputFile; + + /** + * The temporary file prefix. + */ + private final String prefix; + + /** + * The temporary file suffix. + */ + private final String suffix; + + /** + * The directory to use for temporary files. + */ + private final File directory; + + + /** + * True when close() has been called successfully. + */ + private boolean closed = false; + + // ----------------------------------------------------------- Constructors + + + /** + * Constructs an instance of this class which will trigger an event at the + * specified threshold, and save data to a file beyond that point. + * + * @param threshold The number of bytes at which to trigger an event. + * @param outputFile The file to which data is saved beyond the threshold. + */ + public DeferredFileOutputStream(final int threshold, final File outputFile) + { + this(threshold, outputFile, null, null, null); + } + + + /** + * Constructs an instance of this class which will trigger an event at the + * specified threshold, and save data to a temporary file beyond that point. + * + * @param threshold The number of bytes at which to trigger an event. + * @param prefix Prefix to use for the temporary file. + * @param suffix Suffix to use for the temporary file. + * @param directory Temporary file directory. + * + * @since 1.4 + */ + public DeferredFileOutputStream(final int threshold, final String prefix, final String suffix, final File directory) + { + this(threshold, null, prefix, suffix, directory); + if (prefix == null) { + throw new IllegalArgumentException("Temporary file prefix is missing"); + } + } + + /** + * Constructs an instance of this class which will trigger an event at the + * specified threshold, and save data either to a file beyond that point. + * + * @param threshold The number of bytes at which to trigger an event. + * @param outputFile The file to which data is saved beyond the threshold. + * @param prefix Prefix to use for the temporary file. + * @param suffix Suffix to use for the temporary file. + * @param directory Temporary file directory. + */ + private DeferredFileOutputStream(final int threshold, final File outputFile, final String prefix, + final String suffix, final File directory) { + super(threshold); + this.outputFile = outputFile; + + memoryOutputStream = new ByteArrayOutputStream(); + currentOutputStream = memoryOutputStream; + this.prefix = prefix; + this.suffix = suffix; + this.directory = directory; + } + + + // --------------------------------------- ThresholdingOutputStream methods + + + /** + * Returns the current output stream. This may be memory based or disk + * based, depending on the current state with respect to the threshold. + * + * @return The underlying output stream. + * + * @exception IOException if an error occurs. + */ + @Override + protected OutputStream getStream() throws IOException + { + return currentOutputStream; + } + + + /** + * Switches the underlying output stream from a memory based stream to one + * that is backed by disk. This is the point at which we realise that too + * much data is being written to keep in memory, so we elect to switch to + * disk-based storage. + * + * @exception IOException if an error occurs. + */ + @Override + protected void thresholdReached() throws IOException + { + if (prefix != null) { + outputFile = File.createTempFile(prefix, suffix, directory); + } + final FileOutputStream fos = new FileOutputStream(outputFile); + try { + memoryOutputStream.writeTo(fos); + } catch (IOException e){ + fos.close(); + throw e; + } + currentOutputStream = fos; + memoryOutputStream = null; + } + + + // --------------------------------------------------------- Public methods + + + /** + * Determines whether or not the data for this output stream has been + * retained in memory. + * + * @return {@code true} if the data is available in memory; + * {@code false} otherwise. + */ + public boolean isInMemory() + { + return !isThresholdExceeded(); + } + + + /** + * Returns the data for this output stream as an array of bytes, assuming + * that the data has been retained in memory. If the data was written to + * disk, this method returns {@code null}. + * + * @return The data for this output stream, or {@code null} if no such + * data is available. + */ + public byte[] getData() + { + if (memoryOutputStream != null) + { + return memoryOutputStream.toByteArray(); + } + return null; + } + + + /** + * Returns either the output file specified in the constructor or + * the temporary file created or null. + *

+ * If the constructor specifying the file is used then it returns that + * same output file, even when threshold has not been reached. + *

+ * If constructor specifying a temporary file prefix/suffix is used + * then the temporary file created once the threshold is reached is returned + * If the threshold was not reached then {@code null} is returned. + * + * @return The file for this output stream, or {@code null} if no such + * file exists. + */ + public File getFile() + { + return outputFile; + } + + + /** + * Closes underlying output stream, and mark this as closed + * + * @exception IOException if an error occurs. + */ + @Override + public void close() throws IOException + { + super.close(); + closed = true; + } + + + /** + * Writes the data from this output stream to the specified output stream, + * after it has been closed. + * + * @param out output stream to write to. + * @exception IOException if this stream is not yet closed or an error occurs. + */ + public void writeTo(final OutputStream out) throws IOException + { + // we may only need to check if this is closed if we are working with a file + // but we should force the habit of closing wether we are working with + // a file or memory. + if (!closed) + { + throw new IOException("Stream not closed"); + } + + if(isInMemory()) + { + memoryOutputStream.writeTo(out); + } + else + { + final FileInputStream fis = new FileInputStream(outputFile); + try { + IOUtils.copy(fis, out); + } finally { + IOUtils.closeQuietly(fis); + } + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/DemuxOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/DemuxOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..49db43b9d259a1b300b9fb139eb9cdf118706a0c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/DemuxOutputStream.java" @@ -0,0 +1,88 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * Forwards data to a stream that has been associated with this thread. + * + * @version $Id: DemuxOutputStream.java 1737901 2016-04-06 00:23:36Z ggregory $ + */ +public class DemuxOutputStream extends OutputStream { + private final InheritableThreadLocal outputStreamThreadLocal = new InheritableThreadLocal(); + + /** + * Binds the specified stream to the current thread. + * + * @param output + * the stream to bind + * @return the OutputStream that was previously active + */ + public OutputStream bindStream(final OutputStream output) { + final OutputStream stream = outputStreamThreadLocal.get(); + outputStreamThreadLocal.set(output); + return stream; + } + + /** + * Closes stream associated with current thread. + * + * @throws IOException + * if an error occurs + */ + @Override + public void close() throws IOException { + final OutputStream output = outputStreamThreadLocal.get(); + if (null != output) { + output.close(); + } + } + + /** + * Flushes stream associated with current thread. + * + * @throws IOException + * if an error occurs + */ + @Override + public void flush() throws IOException { + @SuppressWarnings("resource") + final OutputStream output = outputStreamThreadLocal.get(); + if (null != output) { + output.flush(); + } + } + + /** + * Writes byte to stream associated with current thread. + * + * @param ch + * the byte to write to stream + * @throws IOException + * if an error occurs + */ + @Override + public void write(final int ch) throws IOException { + @SuppressWarnings("resource") + final OutputStream output = outputStreamThreadLocal.get(); + if (null != output) { + output.write(ch); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java" new file mode 100644 index 0000000000000000000000000000000000000000..4959156a7efa2c0eef23c6def34b1262fdcc359d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/FileWriterWithEncoding.java" @@ -0,0 +1,335 @@ +/* + * 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.output; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +/** + * Writer of files that allows the encoding to be set. + *

+ * This class provides a simple alternative to FileWriter + * that allows an encoding to be set. Unfortunately, it cannot subclass + * FileWriter. + *

+ * By default, the file will be overwritten, but this may be changed to append. + *

+ * The encoding must be specified using either the name of the {@link Charset}, + * the {@link Charset}, or a {@link CharsetEncoder}. If the default encoding + * is required then use the {@link java.io.FileWriter} directly, rather than + * this implementation. + *

+ * + * + * @since 1.4 + * @version $Id: FileWriterWithEncoding.java 1686747 2015-06-21 18:44:49Z krosenvold $ + */ +public class FileWriterWithEncoding extends Writer { + // Cannot extend ProxyWriter, as requires writer to be + // known when super() is called + + /** The writer to decorate. */ + private final Writer out; + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param filename the name of the file to write to, not null + * @param encoding the encoding to use, not null + * @throws NullPointerException if the file name or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final String filename, final String encoding) throws IOException { + this(new File(filename), encoding, false); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param filename the name of the file to write to, not null + * @param encoding the encoding to use, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file name or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final String filename, final String encoding, final boolean append) + throws IOException { + this(new File(filename), encoding, append); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param filename the name of the file to write to, not null + * @param encoding the encoding to use, not null + * @throws NullPointerException if the file name or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final String filename, final Charset encoding) throws IOException { + this(new File(filename), encoding, false); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param filename the name of the file to write to, not null + * @param encoding the encoding to use, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file name or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final String filename, final Charset encoding, final boolean append) + throws IOException { + this(new File(filename), encoding, append); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param filename the name of the file to write to, not null + * @param encoding the encoding to use, not null + * @throws NullPointerException if the file name or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final String filename, final CharsetEncoder encoding) throws IOException { + this(new File(filename), encoding, false); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param filename the name of the file to write to, not null + * @param encoding the encoding to use, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file name or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final String filename, final CharsetEncoder encoding, final boolean append) + throws IOException { + this(new File(filename), encoding, append); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, not null + * @throws NullPointerException if the file or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final File file, final String encoding) throws IOException { + this(file, encoding, false); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final File file, final String encoding, final boolean append) throws IOException { + super(); + this.out = initWriter(file, encoding, append); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, not null + * @throws NullPointerException if the file or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final File file, final Charset encoding) throws IOException { + this(file, encoding, false); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final File file, final Charset encoding, final boolean append) throws IOException { + super(); + this.out = initWriter(file, encoding, append); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, not null + * @throws NullPointerException if the file or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final File file, final CharsetEncoder encoding) throws IOException { + this(file, encoding, false); + } + + /** + * Constructs a FileWriterWithEncoding with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file or encoding is null + * @throws IOException in case of an I/O error + */ + public FileWriterWithEncoding(final File file, final CharsetEncoder encoding, final boolean append) + throws IOException { + super(); + this.out = initWriter(file, encoding, append); + } + + //----------------------------------------------------------------------- + /** + * Initialise the wrapped file writer. + * Ensure that a cleanup occurs if the writer creation fails. + * + * @param file the file to be accessed + * @param encoding the encoding to use - may be Charset, CharsetEncoder or String + * @param append true to append + * @return the initialised writer + * @throws NullPointerException if the file or encoding is null + * @throws IOException if an error occurs + */ + private static Writer initWriter(final File file, final Object encoding, final boolean append) throws IOException { + if (file == null) { + throw new NullPointerException("File is missing"); + } + if (encoding == null) { + throw new NullPointerException("Encoding is missing"); + } + final boolean fileExistedAlready = file.exists(); + OutputStream stream = null; + Writer writer = null; + try { + stream = new FileOutputStream(file, append); + if (encoding instanceof Charset) { + writer = new OutputStreamWriter(stream, (Charset)encoding); + } else if (encoding instanceof CharsetEncoder) { + writer = new OutputStreamWriter(stream, (CharsetEncoder)encoding); + } else { + writer = new OutputStreamWriter(stream, (String)encoding); + } + } catch (final IOException ex) { + IOUtils.closeQuietly(writer); + IOUtils.closeQuietly(stream); + if (fileExistedAlready == false) { + FileUtils.deleteQuietly(file); + } + throw ex; + } catch (final RuntimeException ex) { + IOUtils.closeQuietly(writer); + IOUtils.closeQuietly(stream); + if (fileExistedAlready == false) { + FileUtils.deleteQuietly(file); + } + throw ex; + } + return writer; + } + + //----------------------------------------------------------------------- + /** + * Write a character. + * @param idx the character to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final int idx) throws IOException { + out.write(idx); + } + + /** + * Write the characters from an array. + * @param chr the characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final char[] chr) throws IOException { + out.write(chr); + } + + /** + * Write the specified characters from an array. + * @param chr the characters to write + * @param st The start offset + * @param end The number of characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final char[] chr, final int st, final int end) throws IOException { + out.write(chr, st, end); + } + + /** + * Write the characters from a string. + * @param str the string to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final String str) throws IOException { + out.write(str); + } + + /** + * Write the specified characters from a string. + * @param str the string to write + * @param st The start offset + * @param end The number of characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final String str, final int st, final int end) throws IOException { + out.write(str, st, end); + } + + /** + * Flush the stream. + * @throws IOException if an I/O error occurs + */ + @Override + public void flush() throws IOException { + out.flush(); + } + + /** + * Close the stream. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + out.close(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/LockableFileWriter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/LockableFileWriter.java" new file mode 100644 index 0000000000000000000000000000000000000000..a68289c88709875bbcca0abd94da8aeba9ff9452 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/LockableFileWriter.java" @@ -0,0 +1,374 @@ +/* + * 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.output; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.charset.Charset; + +import org.apache.commons.io.Charsets; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; + +/** + * FileWriter that will create and honor lock files to allow simple + * cross thread file lock handling. + *

+ * This class provides a simple alternative to FileWriter + * that will use a lock file to prevent duplicate writes. + *

+ * N.B. the lock file is deleted when {@link #close()} is called + * - or if the main file cannot be opened initially. + * In the (unlikely) event that the lockfile cannot be deleted, + * this is not reported, and subsequent requests using + * the same lockfile will fail. + *

+ * By default, the file will be overwritten, but this may be changed to append. + * The lock directory may be specified, but defaults to the system property + * java.io.tmpdir. + * The encoding may also be specified, and defaults to the platform default. + * + * @version $Id: LockableFileWriter.java 1686747 2015-06-21 18:44:49Z krosenvold $ + */ +public class LockableFileWriter extends Writer { + // Cannot extend ProxyWriter, as requires writer to be + // known when super() is called + + /** The extension for the lock file. */ + private static final String LCK = ".lck"; + + /** The writer to decorate. */ + private final Writer out; + /** The lock file. */ + private final File lockFile; + + /** + * Constructs a LockableFileWriter. + * If the file exists, it is overwritten. + * + * @param fileName the file to write to, not null + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + */ + public LockableFileWriter(final String fileName) throws IOException { + this(fileName, false, null); + } + + /** + * Constructs a LockableFileWriter. + * + * @param fileName file to write to, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + */ + public LockableFileWriter(final String fileName, final boolean append) throws IOException { + this(fileName, append, null); + } + + /** + * Constructs a LockableFileWriter. + * + * @param fileName the file to write to, not null + * @param append true if content should be appended, false to overwrite + * @param lockDir the directory in which the lock file should be held + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + */ + public LockableFileWriter(final String fileName, final boolean append, final String lockDir) throws IOException { + this(new File(fileName), append, lockDir); + } + + /** + * Constructs a LockableFileWriter. + * If the file exists, it is overwritten. + * + * @param file the file to write to, not null + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + */ + public LockableFileWriter(final File file) throws IOException { + this(file, false, null); + } + + /** + * Constructs a LockableFileWriter. + * + * @param file the file to write to, not null + * @param append true if content should be appended, false to overwrite + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + */ + public LockableFileWriter(final File file, final boolean append) throws IOException { + this(file, append, null); + } + + /** + * Constructs a LockableFileWriter. + * + * @param file the file to write to, not null + * @param append true if content should be appended, false to overwrite + * @param lockDir the directory in which the lock file should be held + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + * @deprecated 2.5 use {@link #LockableFileWriter(File, Charset, boolean, String)} instead + */ + @Deprecated + public LockableFileWriter(final File file, final boolean append, final String lockDir) throws IOException { + this(file, Charset.defaultCharset(), append, lockDir); + } + + /** + * Constructs a LockableFileWriter with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + * @since 2.3 + */ + public LockableFileWriter(final File file, final Charset encoding) throws IOException { + this(file, encoding, false, null); + } + + /** + * Constructs a LockableFileWriter with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, null means platform default + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + * @throws java.nio.charset.UnsupportedCharsetException + * thrown instead of {@link java.io.UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + */ + public LockableFileWriter(final File file, final String encoding) throws IOException { + this(file, encoding, false, null); + } + + /** + * Constructs a LockableFileWriter with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, null means platform default + * @param append true if content should be appended, false to overwrite + * @param lockDir the directory in which the lock file should be held + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + * @since 2.3 + */ + public LockableFileWriter(File file, final Charset encoding, final boolean append, + String lockDir) throws IOException { + super(); + // init file to create/append + file = file.getAbsoluteFile(); + if (file.getParentFile() != null) { + FileUtils.forceMkdir(file.getParentFile()); + } + if (file.isDirectory()) { + throw new IOException("File specified is a directory"); + } + + // init lock file + if (lockDir == null) { + lockDir = System.getProperty("java.io.tmpdir"); + } + final File lockDirFile = new File(lockDir); + FileUtils.forceMkdir(lockDirFile); + testLockDir(lockDirFile); + lockFile = new File(lockDirFile, file.getName() + LCK); + + // check if locked + createLock(); + + // init wrapped writer + out = initWriter(file, encoding, append); + } + + /** + * Constructs a LockableFileWriter with a file encoding. + * + * @param file the file to write to, not null + * @param encoding the encoding to use, null means platform default + * @param append true if content should be appended, false to overwrite + * @param lockDir the directory in which the lock file should be held + * @throws NullPointerException if the file is null + * @throws IOException in case of an I/O error + * @throws java.nio.charset.UnsupportedCharsetException + * thrown instead of {@link java.io.UnsupportedEncodingException} in version 2.2 if the encoding is not + * supported. + */ + public LockableFileWriter(final File file, final String encoding, final boolean append, + final String lockDir) throws IOException { + this(file, Charsets.toCharset(encoding), append, lockDir); + } + + //----------------------------------------------------------------------- + /** + * Tests that we can write to the lock directory. + * + * @param lockDir the File representing the lock directory + * @throws IOException if we cannot write to the lock directory + * @throws IOException if we cannot find the lock file + */ + private void testLockDir(final File lockDir) throws IOException { + if (!lockDir.exists()) { + throw new IOException( + "Could not find lockDir: " + lockDir.getAbsolutePath()); + } + if (!lockDir.canWrite()) { + throw new IOException( + "Could not write to lockDir: " + lockDir.getAbsolutePath()); + } + } + + /** + * Creates the lock file. + * + * @throws IOException if we cannot create the file + */ + private void createLock() throws IOException { + synchronized (LockableFileWriter.class) { + if (!lockFile.createNewFile()) { + throw new IOException("Can't write file, lock " + + lockFile.getAbsolutePath() + " exists"); + } + lockFile.deleteOnExit(); + } + } + + /** + * Initialise the wrapped file writer. + * Ensure that a cleanup occurs if the writer creation fails. + * + * @param file the file to be accessed + * @param encoding the encoding to use + * @param append true to append + * @return The initialised writer + * @throws IOException if an error occurs + */ + private Writer initWriter(final File file, final Charset encoding, final boolean append) throws IOException { + final boolean fileExistedAlready = file.exists(); + OutputStream stream = null; + Writer writer = null; + try { + stream = new FileOutputStream(file.getAbsolutePath(), append); + writer = new OutputStreamWriter(stream, Charsets.toCharset(encoding)); + } catch (final IOException ex) { + IOUtils.closeQuietly(writer); + IOUtils.closeQuietly(stream); + FileUtils.deleteQuietly(lockFile); + if (fileExistedAlready == false) { + FileUtils.deleteQuietly(file); + } + throw ex; + } catch (final RuntimeException ex) { + IOUtils.closeQuietly(writer); + IOUtils.closeQuietly(stream); + FileUtils.deleteQuietly(lockFile); + if (fileExistedAlready == false) { + FileUtils.deleteQuietly(file); + } + throw ex; + } + return writer; + } + + //----------------------------------------------------------------------- + /** + * Closes the file writer and deletes the lockfile (if possible). + * + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + try { + out.close(); + } finally { + lockFile.delete(); + } + } + + //----------------------------------------------------------------------- + /** + * Write a character. + * @param idx the character to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final int idx) throws IOException { + out.write(idx); + } + + /** + * Write the characters from an array. + * @param chr the characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final char[] chr) throws IOException { + out.write(chr); + } + + /** + * Write the specified characters from an array. + * @param chr the characters to write + * @param st The start offset + * @param end The number of characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final char[] chr, final int st, final int end) throws IOException { + out.write(chr, st, end); + } + + /** + * Write the characters from a string. + * @param str the string to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final String str) throws IOException { + out.write(str); + } + + /** + * Write the specified characters from a string. + * @param str the string to write + * @param st The start offset + * @param end The number of characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final String str, final int st, final int end) throws IOException { + out.write(str, st, end); + } + + /** + * Flush the stream. + * @throws IOException if an I/O error occurs + */ + @Override + public void flush() throws IOException { + out.flush(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/NullOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/NullOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..b933e2ed8098c715032846c87907f6bc06ec9ad0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/NullOutputStream.java" @@ -0,0 +1,67 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * This OutputStream writes all data to the famous /dev/null. + *

+ * This output stream has no destination (file/socket etc.) and all + * bytes written to it are ignored and lost. + *

+ * @version $Id: NullOutputStream.java 1674708 2015-04-20 00:02:45Z ggregory $ + */ +public class NullOutputStream extends OutputStream { + + /** + * A singleton. + */ + public static final NullOutputStream NULL_OUTPUT_STREAM = new NullOutputStream(); + + /** + * Does nothing - output to /dev/null. + * @param b The bytes to write + * @param off The start offset + * @param len The number of bytes to write + */ + @Override + public void write(final byte[] b, final int off, final int len) { + //to /dev/null + } + + /** + * Does nothing - output to /dev/null. + * @param b The byte to write + */ + @Override + public void write(final int b) { + //to /dev/null + } + + /** + * Does nothing - output to /dev/null. + * @param b The bytes to write + * @throws IOException never + */ + @Override + public void write(final byte[] b) throws IOException { + //to /dev/null + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/NullWriter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/NullWriter.java" new file mode 100644 index 0000000000000000000000000000000000000000..322dc82464266124e71635f6249ea465c3f3f355 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/NullWriter.java" @@ -0,0 +1,141 @@ +/* + * 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.output; + +import java.io.Writer; + +/** + * This {@link Writer} writes all data to the famous /dev/null. + *

+ * This Writer has no destination (file/socket etc.) and all + * characters written to it are ignored and lost. + * + * @version $Id: NullWriter.java 1471767 2013-04-24 23:24:19Z sebb $ + */ +public class NullWriter extends Writer { + + /** + * A singleton. + */ + public static final NullWriter NULL_WRITER = new NullWriter(); + + /** + * Constructs a new NullWriter. + */ + public NullWriter() { + } + + /** + * Does nothing - output to /dev/null. + * @param c The character to write + * @return this writer + * @since 2.0 + */ + @Override + public Writer append(final char c) { + //to /dev/null + return this; + } + + /** + * Does nothing - output to /dev/null. + * @param csq The character sequence to write + * @param start The index of the first character to write + * @param end The index of the first character to write (exclusive) + * @return this writer + * @since 2.0 + */ + @Override + public Writer append(final CharSequence csq, final int start, final int end) { + //to /dev/null + return this; + } + + /** + * Does nothing - output to /dev/null. + * @param csq The character sequence to write + * @return this writer + * @since 2.0 + */ + @Override + public Writer append(final CharSequence csq) { + //to /dev/null + return this; + } + + /** + * Does nothing - output to /dev/null. + * @param idx The character to write + */ + @Override + public void write(final int idx) { + //to /dev/null + } + + /** + * Does nothing - output to /dev/null. + * @param chr The characters to write + */ + @Override + public void write(final char[] chr) { + //to /dev/null + } + + /** + * Does nothing - output to /dev/null. + * @param chr The characters to write + * @param st The start offset + * @param end The number of characters to write + */ + @Override + public void write(final char[] chr, final int st, final int end) { + //to /dev/null + } + + /** + * Does nothing - output to /dev/null. + * @param str The string to write + */ + @Override + public void write(final String str) { + //to /dev/null + } + + /** + * Does nothing - output to /dev/null. + * @param str The string to write + * @param st The start offset + * @param end The number of characters to write + */ + @Override + public void write(final String str, final int st, final int end) { + //to /dev/null + } + + /** @see java.io.Writer#flush() */ + @Override + public void flush() { + //to /dev/null + } + + /** @see java.io.Writer#close() */ + @Override + public void close() { + //to /dev/null + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ProxyOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ProxyOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..8f78594589ff8f34774b669b1599db89dbb4740c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ProxyOutputStream.java" @@ -0,0 +1,169 @@ +/* + * 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.output; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +/** + * A Proxy stream which acts as expected, that is it passes the method + * calls on to the proxied stream and doesn't change which methods are + * being called. It is an alternative base class to FilterOutputStream + * to increase reusability. + *

+ * See the protected methods for ways in which a subclass can easily decorate + * a stream with custom pre-, post- or error processing functionality. + * + * @version $Id: ProxyOutputStream.java 1415850 2012-11-30 20:51:39Z ggregory $ + */ +public class ProxyOutputStream extends FilterOutputStream { + + /** + * Constructs a new ProxyOutputStream. + * + * @param proxy the OutputStream to delegate to + */ + public ProxyOutputStream(final OutputStream proxy) { + super(proxy); + // the proxy is stored in a protected superclass variable named 'out' + } + + /** + * Invokes the delegate's write(int) method. + * @param idx the byte to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final int idx) throws IOException { + try { + beforeWrite(1); + out.write(idx); + afterWrite(1); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's write(byte[]) method. + * @param bts the bytes to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final byte[] bts) throws IOException { + try { + final int len = bts != null ? bts.length : 0; + beforeWrite(len); + out.write(bts); + afterWrite(len); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's write(byte[]) method. + * @param bts the bytes to write + * @param st The start offset + * @param end The number of bytes to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final byte[] bts, final int st, final int end) throws IOException { + try { + beforeWrite(end); + out.write(bts, st, end); + afterWrite(end); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's flush() method. + * @throws IOException if an I/O error occurs + */ + @Override + public void flush() throws IOException { + try { + out.flush(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's close() method. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + try { + out.close(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invoked by the write methods before the call is proxied. The number + * of bytes to be written (1 for the {@link #write(int)} method, buffer + * length for {@link #write(byte[])}, etc.) is given as an argument. + *

+ * Subclasses can override this method to add common pre-processing + * functionality without having to override all the write methods. + * The default implementation does nothing. + * + * @since 2.0 + * @param n number of bytes to be written + * @throws IOException if the pre-processing fails + */ + protected void beforeWrite(final int n) throws IOException { + } + + /** + * Invoked by the write methods after the proxied call has returned + * successfully. The number of bytes written (1 for the + * {@link #write(int)} method, buffer length for {@link #write(byte[])}, + * etc.) is given as an argument. + *

+ * Subclasses can override this method to add common post-processing + * functionality without having to override all the write methods. + * The default implementation does nothing. + * + * @since 2.0 + * @param n number of bytes written + * @throws IOException if the post-processing fails + */ + protected void afterWrite(final int n) throws IOException { + } + + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + protected void handleIOException(final IOException e) throws IOException { + throw e; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ProxyWriter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ProxyWriter.java" new file mode 100644 index 0000000000000000000000000000000000000000..0e3eda756fbb536a19baafe123dfcc96037972fe --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ProxyWriter.java" @@ -0,0 +1,275 @@ +/* + * 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.output; + +import java.io.FilterWriter; +import java.io.IOException; +import java.io.Writer; + +/** + * A Proxy stream which acts as expected, that is it passes the method + * calls on to the proxied stream and doesn't change which methods are + * being called. It is an alternative base class to FilterWriter + * to increase reusability, because FilterWriter changes the + * methods being called, such as write(char[]) to write(char[], int, int) + * and write(String) to write(String, int, int). + * + * @version $Id: ProxyWriter.java 1415850 2012-11-30 20:51:39Z ggregory $ + */ +public class ProxyWriter extends FilterWriter { + + /** + * Constructs a new ProxyWriter. + * + * @param proxy the Writer to delegate to + */ + public ProxyWriter(final Writer proxy) { + super(proxy); + // the proxy is stored in a protected superclass variable named 'out' + } + + /** + * Invokes the delegate's append(char) method. + * @param c The character to write + * @return this writer + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + @Override + public Writer append(final char c) throws IOException { + try { + beforeWrite(1); + out.append(c); + afterWrite(1); + } catch (final IOException e) { + handleIOException(e); + } + return this; + } + + /** + * Invokes the delegate's append(CharSequence, int, int) method. + * @param csq The character sequence to write + * @param start The index of the first character to write + * @param end The index of the first character to write (exclusive) + * @return this writer + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + @Override + public Writer append(final CharSequence csq, final int start, final int end) throws IOException { + try { + beforeWrite(end - start); + out.append(csq, start, end); + afterWrite(end - start); + } catch (final IOException e) { + handleIOException(e); + } + return this; + } + + /** + * Invokes the delegate's append(CharSequence) method. + * @param csq The character sequence to write + * @return this writer + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + @Override + public Writer append(final CharSequence csq) throws IOException { + try { + int len = 0; + if (csq != null) { + len = csq.length(); + } + + beforeWrite(len); + out.append(csq); + afterWrite(len); + } catch (final IOException e) { + handleIOException(e); + } + return this; + } + + /** + * Invokes the delegate's write(int) method. + * @param idx the character to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final int idx) throws IOException { + try { + beforeWrite(1); + out.write(idx); + afterWrite(1); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's write(char[]) method. + * @param chr the characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final char[] chr) throws IOException { + try { + int len = 0; + if (chr != null) { + len = chr.length; + } + + beforeWrite(len); + out.write(chr); + afterWrite(len); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's write(char[], int, int) method. + * @param chr the characters to write + * @param st The start offset + * @param len The number of characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final char[] chr, final int st, final int len) throws IOException { + try { + beforeWrite(len); + out.write(chr, st, len); + afterWrite(len); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's write(String) method. + * @param str the string to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final String str) throws IOException { + try { + int len = 0; + if (str != null) { + len = str.length(); + } + + beforeWrite(len); + out.write(str); + afterWrite(len); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's write(String) method. + * @param str the string to write + * @param st The start offset + * @param len The number of characters to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final String str, final int st, final int len) throws IOException { + try { + beforeWrite(len); + out.write(str, st, len); + afterWrite(len); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's flush() method. + * @throws IOException if an I/O error occurs + */ + @Override + public void flush() throws IOException { + try { + out.flush(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invokes the delegate's close() method. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + try { + out.close(); + } catch (final IOException e) { + handleIOException(e); + } + } + + /** + * Invoked by the write methods before the call is proxied. The number + * of chars to be written (1 for the {@link #write(int)} method, buffer + * length for {@link #write(char[])}, etc.) is given as an argument. + *

+ * Subclasses can override this method to add common pre-processing + * functionality without having to override all the write methods. + * The default implementation does nothing. + * + * @since 2.0 + * @param n number of chars to be written + * @throws IOException if the pre-processing fails + */ + protected void beforeWrite(final int n) throws IOException { + } + + /** + * Invoked by the write methods after the proxied call has returned + * successfully. The number of chars written (1 for the + * {@link #write(int)} method, buffer length for {@link #write(char[])}, + * etc.) is given as an argument. + *

+ * Subclasses can override this method to add common post-processing + * functionality without having to override all the write methods. + * The default implementation does nothing. + * + * @since 2.0 + * @param n number of chars written + * @throws IOException if the post-processing fails + */ + protected void afterWrite(final int n) throws IOException { + } + + /** + * Handle any IOExceptions thrown. + *

+ * This method provides a point to implement custom exception + * handling. The default behaviour is to re-throw the exception. + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + * @since 2.0 + */ + protected void handleIOException(final IOException e) throws IOException { + throw e; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/StringBuilderWriter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/StringBuilderWriter.java" new file mode 100644 index 0000000000000000000000000000000000000000..df75627b3a17095addc67aef1598fff845f10078 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/StringBuilderWriter.java" @@ -0,0 +1,165 @@ +/* + * 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.output; + +import java.io.Serializable; +import java.io.Writer; + +/** + * {@link Writer} implementation that outputs to a {@link StringBuilder}. + *

+ * NOTE: This implementation, as an alternative to + * java.io.StringWriter, provides an un-synchronized + * (i.e. for use in a single thread) implementation for better performance. + * For safe usage with multiple {@link Thread}s then + * java.io.StringWriter should be used. + * + * @version $Id: StringBuilderWriter.java 1722253 2015-12-30 00:36:12Z ggregory $ + * @since 2.0 + */ +public class StringBuilderWriter extends Writer implements Serializable { + + private static final long serialVersionUID = -146927496096066153L; + private final StringBuilder builder; + + /** + * Constructs a new {@link StringBuilder} instance with default capacity. + */ + public StringBuilderWriter() { + this.builder = new StringBuilder(); + } + + /** + * Constructs a new {@link StringBuilder} instance with the specified capacity. + * + * @param capacity The initial capacity of the underlying {@link StringBuilder} + */ + public StringBuilderWriter(final int capacity) { + this.builder = new StringBuilder(capacity); + } + + /** + * Constructs a new instance with the specified {@link StringBuilder}. + * + *

If {@code builder} is null a new instance with default capacity will be created.

+ * + * @param builder The String builder. May be null. + */ + public StringBuilderWriter(final StringBuilder builder) { + this.builder = builder != null ? builder : new StringBuilder(); + } + + /** + * Appends a single character to this Writer. + * + * @param value The character to append + * @return This writer instance + */ + @Override + public Writer append(final char value) { + builder.append(value); + return this; + } + + /** + * Appends a character sequence to this Writer. + * + * @param value The character to append + * @return This writer instance + */ + @Override + public Writer append(final CharSequence value) { + builder.append(value); + return this; + } + + /** + * Appends a portion of a character sequence to the {@link StringBuilder}. + * + * @param value The character to append + * @param start The index of the first character + * @param end The index of the last character + 1 + * @return This writer instance + */ + @Override + public Writer append(final CharSequence value, final int start, final int end) { + builder.append(value, start, end); + return this; + } + + /** + * Closing this writer has no effect. + */ + @Override + public void close() { + // no-op + } + + /** + * Flushing this writer has no effect. + */ + @Override + public void flush() { + // no-op + } + + + /** + * Writes a String to the {@link StringBuilder}. + * + * @param value The value to write + */ + @Override + public void write(final String value) { + if (value != null) { + builder.append(value); + } + } + + /** + * Writes a portion of a character array to the {@link StringBuilder}. + * + * @param value The value to write + * @param offset The index of the first character + * @param length The number of characters to write + */ + @Override + public void write(final char[] value, final int offset, final int length) { + if (value != null) { + builder.append(value, offset, length); + } + } + + /** + * Returns the underlying builder. + * + * @return The underlying builder + */ + public StringBuilder getBuilder() { + return builder; + } + + /** + * Returns {@link StringBuilder#toString()}. + * + * @return The contents of the String builder. + */ + @Override + public String toString() { + return builder.toString(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/TaggedOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/TaggedOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..ae63a7d57f90623010fc7c6686d9b150ac91ca4e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/TaggedOutputStream.java" @@ -0,0 +1,116 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.Serializable; +import java.util.UUID; + +import org.apache.commons.io.TaggedIOException; + +/** + * An output stream decorator that tags potential exceptions so that the + * stream that caused the exception can easily be identified. This is + * done by using the {@link TaggedIOException} class to wrap all thrown + * {@link IOException}s. See below for an example of using this class. + *
+ * TaggedOutputStream stream = new TaggedOutputStream(...);
+ * try {
+ *     // Processing that may throw an IOException either from this stream
+ *     // or from some other IO activity like temporary files, etc.
+ *     writeToStream(stream);
+ * } catch (IOException e) {
+ *     if (stream.isCauseOf(e)) {
+ *         // The exception was caused by this stream.
+ *         // Use e.getCause() to get the original exception.
+ *     } else {
+ *         // The exception was caused by something else.
+ *     }
+ * }
+ * 
+ *

+ * Alternatively, the {@link #throwIfCauseOf(Exception)} method can be + * used to let higher levels of code handle the exception caused by this + * stream while other processing errors are being taken care of at this + * lower level. + *

+ * TaggedOutputStream stream = new TaggedOutputStream(...);
+ * try {
+ *     writeToStream(stream);
+ * } catch (IOException e) {
+ *     stream.throwIfCauseOf(e);
+ *     // ... or process the exception that was caused by something else
+ * }
+ * 
+ * + * @see TaggedIOException + * @since 2.0 + */ +public class TaggedOutputStream extends ProxyOutputStream { + + /** + * The unique tag associated with exceptions from stream. + */ + private final Serializable tag = UUID.randomUUID(); + + /** + * Creates a tagging decorator for the given output stream. + * + * @param proxy output stream to be decorated + */ + public TaggedOutputStream(final OutputStream proxy) { + super(proxy); + } + + /** + * Tests if the given exception was caused by this stream. + * + * @param exception an exception + * @return {@code true} if the exception was thrown by this stream, + * {@code false} otherwise + */ + public boolean isCauseOf(final Exception exception) { + return TaggedIOException.isTaggedWith(exception, tag); + } + + /** + * Re-throws the original exception thrown by this stream. This method + * first checks whether the given exception is a {@link TaggedIOException} + * wrapper created by this decorator, and then unwraps and throws the + * original wrapped exception. Returns normally if the exception was + * not thrown by this stream. + * + * @param exception an exception + * @throws IOException original exception, if any, thrown by this stream + */ + public void throwIfCauseOf(final Exception exception) throws IOException { + TaggedIOException.throwCauseIfTaggedWith(exception, tag); + } + + /** + * Tags any IOExceptions thrown, wrapping and re-throwing. + * + * @param e The IOException thrown + * @throws IOException if an I/O error occurs + */ + @Override + protected void handleIOException(final IOException e) throws IOException { + throw new TaggedIOException(e, tag); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/TeeOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/TeeOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..9200c26825e4946894022d42a82c7f818101a27d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/TeeOutputStream.java" @@ -0,0 +1,109 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * Classic splitter of OutputStream. Named after the unix 'tee' + * command. It allows a stream to be branched off so there + * are now two streams. + * + * @version $Id: TeeOutputStream.java 1686503 2015-06-19 21:32:13Z sebb $ + */ +public class TeeOutputStream extends ProxyOutputStream { + + /** the second OutputStream to write to */ + protected OutputStream branch; //TODO consider making this private + + /** + * Constructs a TeeOutputStream. + * @param out the main OutputStream + * @param branch the second OutputStream + */ + public TeeOutputStream(final OutputStream out, final OutputStream branch) { + super(out); + this.branch = branch; + } + + /** + * Write the bytes to both streams. + * @param b the bytes to write + * @throws IOException if an I/O error occurs + */ + @Override + public synchronized void write(final byte[] b) throws IOException { + super.write(b); + this.branch.write(b); + } + + /** + * Write the specified bytes to both streams. + * @param b the bytes to write + * @param off The start offset + * @param len The number of bytes to write + * @throws IOException if an I/O error occurs + */ + @Override + public synchronized void write(final byte[] b, final int off, final int len) throws IOException { + super.write(b, off, len); + this.branch.write(b, off, len); + } + + /** + * Write a byte to both streams. + * @param b the byte to write + * @throws IOException if an I/O error occurs + */ + @Override + public synchronized void write(final int b) throws IOException { + super.write(b); + this.branch.write(b); + } + + /** + * Flushes both streams. + * @throws IOException if an I/O error occurs + */ + @Override + public void flush() throws IOException { + super.flush(); + this.branch.flush(); + } + + /** + * Closes both output streams. + * + * If closing the main output stream throws an exception, attempt to close the branch output stream. + * + * If closing the main and branch output streams both throw exceptions, which exceptions is thrown by this method is + * currently unspecified and subject to change. + * + * @throws IOException + * if an I/O error occurs + */ + @Override + public void close() throws IOException { + try { + super.close(); + } finally { + this.branch.close(); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..bb7c34e2b89c72194d7ee485119a04949ce937dd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/ThresholdingOutputStream.java" @@ -0,0 +1,274 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; + + +/** + * An output stream which triggers an event when a specified number of bytes of + * data have been written to it. The event can be used, for example, to throw + * an exception if a maximum has been reached, or to switch the underlying + * stream type when the threshold is exceeded. + *

+ * This class overrides all OutputStream methods. However, these + * overrides ultimately call the corresponding methods in the underlying output + * stream implementation. + *

+ * NOTE: This implementation may trigger the event before the threshold + * is actually reached, since it triggers when a pending write operation would + * cause the threshold to be exceeded. + * + * @version $Id: ThresholdingOutputStream.java 1687815 2015-06-26 17:18:56Z krosenvold $ + */ +public abstract class ThresholdingOutputStream + extends OutputStream +{ + + // ----------------------------------------------------------- Data members + + + /** + * The threshold at which the event will be triggered. + */ + private final int threshold; + + + /** + * The number of bytes written to the output stream. + */ + private long written; + + + /** + * Whether or not the configured threshold has been exceeded. + */ + private boolean thresholdExceeded; + + + // ----------------------------------------------------------- Constructors + + + /** + * Constructs an instance of this class which will trigger an event at the + * specified threshold. + * + * @param threshold The number of bytes at which to trigger an event. + */ + public ThresholdingOutputStream(final int threshold) + { + this.threshold = threshold; + } + + + // --------------------------------------------------- OutputStream methods + + + /** + * Writes the specified byte to this output stream. + * + * @param b The byte to be written. + * + * @exception IOException if an error occurs. + */ + @Override + public void write(final int b) throws IOException + { + checkThreshold(1); + getStream().write(b); + written++; + } + + + /** + * Writes b.length bytes from the specified byte array to this + * output stream. + * + * @param b The array of bytes to be written. + * + * @exception IOException if an error occurs. + */ + @Override + public void write(final byte b[]) throws IOException + { + checkThreshold(b.length); + getStream().write(b); + written += b.length; + } + + + /** + * Writes len bytes from the specified byte array starting at + * offset off to this output stream. + * + * @param b The byte array from which the data will be written. + * @param off The start offset in the byte array. + * @param len The number of bytes to write. + * + * @exception IOException if an error occurs. + */ + @Override + public void write(final byte b[], final int off, final int len) throws IOException + { + checkThreshold(len); + getStream().write(b, off, len); + written += len; + } + + + /** + * Flushes this output stream and forces any buffered output bytes to be + * written out. + * + * @exception IOException if an error occurs. + */ + @Override + public void flush() throws IOException + { + getStream().flush(); + } + + + /** + * Closes this output stream and releases any system resources associated + * with this stream. + * + * @exception IOException if an error occurs. + */ + @Override + public void close() throws IOException + { + try + { + flush(); + } + catch (final IOException ignored) + { + // ignore + } + getStream().close(); + } + + + // --------------------------------------------------------- Public methods + + + /** + * Returns the threshold, in bytes, at which an event will be triggered. + * + * @return The threshold point, in bytes. + */ + public int getThreshold() + { + return threshold; + } + + + /** + * Returns the number of bytes that have been written to this output stream. + * + * @return The number of bytes written. + */ + public long getByteCount() + { + return written; + } + + + /** + * Determines whether or not the configured threshold has been exceeded for + * this output stream. + * + * @return {@code true} if the threshold has been reached; + * {@code false} otherwise. + */ + public boolean isThresholdExceeded() + { + return written > threshold; + } + + + // ------------------------------------------------------ Protected methods + + + /** + * Checks to see if writing the specified number of bytes would cause the + * configured threshold to be exceeded. If so, triggers an event to allow + * a concrete implementation to take action on this. + * + * @param count The number of bytes about to be written to the underlying + * output stream. + * + * @exception IOException if an error occurs. + */ + protected void checkThreshold(final int count) throws IOException + { + if (!thresholdExceeded && written + count > threshold) + { + thresholdExceeded = true; + thresholdReached(); + } + } + + /** + * Resets the byteCount to zero. You can call this from + * {@link #thresholdReached()} if you want the event to be triggered again. + */ + protected void resetByteCount() + { + this.thresholdExceeded = false; + this.written = 0; + } + + /** + * Sets the byteCount to count. Usefull for re-opening an output stream + * that been previously written to. + * + * @param count The number of bytes that have already been written to the + * output stream + * + * @since 2.5 + */ + protected void setByteCount(final long count) { + this.written = count; + } + + + // ------------------------------------------------------- Abstract methods + + + /** + * Returns the underlying output stream, to which the corresponding + * OutputStream methods in this class will ultimately delegate. + * + * @return The underlying output stream. + * + * @exception IOException if an error occurs. + */ + protected abstract OutputStream getStream() throws IOException; + + + /** + * Indicates that the configured threshold has been reached, and that a + * subclass should take whatever action necessary on this event. This may + * include changing the underlying output stream. + * + * @exception IOException if an error occurs. + */ + protected abstract void thresholdReached() throws IOException; +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/WriterOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/WriterOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..8f818cac0acb86a53a84dca4d0d3219d155d5972 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/WriterOutputStream.java" @@ -0,0 +1,340 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.CoderResult; +import java.nio.charset.CodingErrorAction; + +/** + * {@link OutputStream} implementation that transforms a byte stream to a + * character stream using a specified charset encoding and writes the resulting + * stream to a {@link Writer}. The stream is transformed using a + * {@link CharsetDecoder} object, guaranteeing that all charset + * encodings supported by the JRE are handled correctly. + *

+ * The output of the {@link CharsetDecoder} is buffered using a fixed size buffer. + * This implies that the data is written to the underlying {@link Writer} in chunks + * that are no larger than the size of this buffer. By default, the buffer is + * flushed only when it overflows or when {@link #flush()} or {@link #close()} + * is called. In general there is therefore no need to wrap the underlying {@link Writer} + * in a {@link java.io.BufferedWriter}. {@link WriterOutputStream} can also + * be instructed to flush the buffer after each write operation. In this case, all + * available data is written immediately to the underlying {@link Writer}, implying that + * the current position of the {@link Writer} is correlated to the current position + * of the {@link WriterOutputStream}. + *

+ * {@link WriterOutputStream} implements the inverse transformation of {@link java.io.OutputStreamWriter}; + * in the following example, writing to {@code out2} would have the same result as writing to + * {@code out} directly (provided that the byte sequence is legal with respect to the + * charset encoding): + *

+ * OutputStream out = ...
+ * Charset cs = ...
+ * OutputStreamWriter writer = new OutputStreamWriter(out, cs);
+ * WriterOutputStream out2 = new WriterOutputStream(writer, cs);
+ * {@link WriterOutputStream} implements the same transformation as {@link java.io.InputStreamReader}, + * except that the control flow is reversed: both classes transform a byte stream + * into a character stream, but {@link java.io.InputStreamReader} pulls data from the underlying stream, + * while {@link WriterOutputStream} pushes it to the underlying stream. + *

+ * Note that while there are use cases where there is no alternative to using + * this class, very often the need to use this class is an indication of a flaw + * in the design of the code. This class is typically used in situations where an existing + * API only accepts an {@link OutputStream} object, but where the stream is known to represent + * character data that must be decoded for further use. + *

+ * Instances of {@link WriterOutputStream} are not thread safe. + * + * @see org.apache.commons.io.input.ReaderInputStream + * + * @since 2.0 + */ +public class WriterOutputStream extends OutputStream { + private static final int DEFAULT_BUFFER_SIZE = 1024; + + private final Writer writer; + private final CharsetDecoder decoder; + private final boolean writeImmediately; + + /** + * ByteBuffer used as input for the decoder. This buffer can be small + * as it is used only to transfer the received data to the + * decoder. + */ + private final ByteBuffer decoderIn = ByteBuffer.allocate(128); + + /** + * CharBuffer used as output for the decoder. It should be + * somewhat larger as we write from this buffer to the + * underlying Writer. + */ + private final CharBuffer decoderOut; + + /** + * Constructs a new {@link WriterOutputStream} with a default output buffer size of + * 1024 characters. The output buffer will only be flushed when it overflows or when + * {@link #flush()} or {@link #close()} is called. + * + * @param writer the target {@link Writer} + * @param decoder the charset decoder + * @since 2.1 + */ + public WriterOutputStream(final Writer writer, final CharsetDecoder decoder) { + this(writer, decoder, DEFAULT_BUFFER_SIZE, false); + } + + /** + * Constructs a new {@link WriterOutputStream}. + * + * @param writer the target {@link Writer} + * @param decoder the charset decoder + * @param bufferSize the size of the output buffer in number of characters + * @param writeImmediately If {@code true} the output buffer will be flushed after each + * write operation, i.e. all available data will be written to the + * underlying {@link Writer} immediately. If {@code false}, the + * output buffer will only be flushed when it overflows or when + * {@link #flush()} or {@link #close()} is called. + * @since 2.1 + */ + public WriterOutputStream(final Writer writer, final CharsetDecoder decoder, final int bufferSize, + final boolean writeImmediately) { + checkIbmJdkWithBrokenUTF16( decoder.charset()); + this.writer = writer; + this.decoder = decoder; + this.writeImmediately = writeImmediately; + decoderOut = CharBuffer.allocate(bufferSize); + } + + /** + * Constructs a new {@link WriterOutputStream}. + * + * @param writer the target {@link Writer} + * @param charset the charset encoding + * @param bufferSize the size of the output buffer in number of characters + * @param writeImmediately If {@code true} the output buffer will be flushed after each + * write operation, i.e. all available data will be written to the + * underlying {@link Writer} immediately. If {@code false}, the + * output buffer will only be flushed when it overflows or when + * {@link #flush()} or {@link #close()} is called. + */ + public WriterOutputStream(final Writer writer, final Charset charset, final int bufferSize, + final boolean writeImmediately) { + this(writer, + charset.newDecoder() + .onMalformedInput(CodingErrorAction.REPLACE) + .onUnmappableCharacter(CodingErrorAction.REPLACE) + .replaceWith("?"), + bufferSize, + writeImmediately); + } + + /** + * Constructs a new {@link WriterOutputStream} with a default output buffer size of + * 1024 characters. The output buffer will only be flushed when it overflows or when + * {@link #flush()} or {@link #close()} is called. + * + * @param writer the target {@link Writer} + * @param charset the charset encoding + */ + public WriterOutputStream(final Writer writer, final Charset charset) { + this(writer, charset, DEFAULT_BUFFER_SIZE, false); + } + + /** + * Constructs a new {@link WriterOutputStream}. + * + * @param writer the target {@link Writer} + * @param charsetName the name of the charset encoding + * @param bufferSize the size of the output buffer in number of characters + * @param writeImmediately If {@code true} the output buffer will be flushed after each + * write operation, i.e. all available data will be written to the + * underlying {@link Writer} immediately. If {@code false}, the + * output buffer will only be flushed when it overflows or when + * {@link #flush()} or {@link #close()} is called. + */ + public WriterOutputStream(final Writer writer, final String charsetName, final int bufferSize, + final boolean writeImmediately) { + this(writer, Charset.forName(charsetName), bufferSize, writeImmediately); + } + + /** + * Constructs a new {@link WriterOutputStream} with a default output buffer size of + * 1024 characters. The output buffer will only be flushed when it overflows or when + * {@link #flush()} or {@link #close()} is called. + * + * @param writer the target {@link Writer} + * @param charsetName the name of the charset encoding + */ + public WriterOutputStream(final Writer writer, final String charsetName) { + this(writer, charsetName, DEFAULT_BUFFER_SIZE, false); + } + + /** + * Constructs a new {@link WriterOutputStream} that uses the default character encoding + * and with a default output buffer size of 1024 characters. The output buffer will only + * be flushed when it overflows or when {@link #flush()} or {@link #close()} is called. + * + * @param writer the target {@link Writer} + * @deprecated 2.5 use {@link #WriterOutputStream(Writer, Charset)} instead + */ + @Deprecated + public WriterOutputStream(final Writer writer) { + this(writer, Charset.defaultCharset(), DEFAULT_BUFFER_SIZE, false); + } + + /** + * Write bytes from the specified byte array to the stream. + * + * @param b the byte array containing the bytes to write + * @param off the start offset in the byte array + * @param len the number of bytes to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final byte[] b, int off, int len) throws IOException { + while (len > 0) { + final int c = Math.min(len, decoderIn.remaining()); + decoderIn.put(b, off, c); + processInput(false); + len -= c; + off += c; + } + if (writeImmediately) { + flushOutput(); + } + } + + /** + * Write bytes from the specified byte array to the stream. + * + * @param b the byte array containing the bytes to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final byte[] b) throws IOException { + write(b, 0, b.length); + } + + /** + * Write a single byte to the stream. + * + * @param b the byte to write + * @throws IOException if an I/O error occurs + */ + @Override + public void write(final int b) throws IOException { + write(new byte[] { (byte)b }, 0, 1); + } + + /** + * Flush the stream. Any remaining content accumulated in the output buffer + * will be written to the underlying {@link Writer}. After that + * {@link Writer#flush()} will be called. + * @throws IOException if an I/O error occurs + */ + @Override + public void flush() throws IOException { + flushOutput(); + writer.flush(); + } + + /** + * Close the stream. Any remaining content accumulated in the output buffer + * will be written to the underlying {@link Writer}. After that + * {@link Writer#close()} will be called. + * @throws IOException if an I/O error occurs + */ + @Override + public void close() throws IOException { + processInput(true); + flushOutput(); + writer.close(); + } + + /** + * Decode the contents of the input ByteBuffer into a CharBuffer. + * + * @param endOfInput indicates end of input + * @throws IOException if an I/O error occurs + */ + private void processInput(final boolean endOfInput) throws IOException { + // Prepare decoderIn for reading + decoderIn.flip(); + CoderResult coderResult; + while (true) { + coderResult = decoder.decode(decoderIn, decoderOut, endOfInput); + if (coderResult.isOverflow()) { + flushOutput(); + } else if (coderResult.isUnderflow()) { + break; + } else { + // The decoder is configured to replace malformed input and unmappable characters, + // so we should not get here. + throw new IOException("Unexpected coder result"); + } + } + // Discard the bytes that have been read + decoderIn.compact(); + } + + /** + * Flush the output. + * + * @throws IOException if an I/O error occurs + */ + private void flushOutput() throws IOException { + if (decoderOut.position() > 0) { + writer.write(decoderOut.array(), 0, decoderOut.position()); + decoderOut.rewind(); + } + } + + private static void checkIbmJdkWithBrokenUTF16(Charset charset){ + if (!"UTF-16".equals(charset.name())) return; + final String TEST_STRING_2 = "v\u00e9s"; + byte[] bytes = TEST_STRING_2.getBytes(charset); + + final CharsetDecoder charsetDecoder2 = charset.newDecoder(); + ByteBuffer bb2 = ByteBuffer.allocate(16); + CharBuffer cb2 = CharBuffer.allocate(TEST_STRING_2.length()); + final int len = bytes.length; + for (int i = 0; i < len; i++) { + bb2.put(bytes[i]); + bb2.flip(); + try { + charsetDecoder2.decode(bb2, cb2, i == (len - 1)); + } catch ( IllegalArgumentException e){ + throw new UnsupportedOperationException("UTF-16 requested when runninng on an IBM JDK with broken UTF-16 support. " + + "Please find a JDK that supports UTF-16 if you intend to use UF-16 with WriterOutputStream"); + } + bb2.compact(); + } + cb2.rewind(); + if (!TEST_STRING_2.equals(cb2.toString())){ + throw new UnsupportedOperationException("UTF-16 requested when runninng on an IBM JDK with broken UTF-16 support. " + + "Please find a JDK that supports UTF-16 if you intend to use UF-16 with WriterOutputStream"); + }; + + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java" new file mode 100644 index 0000000000000000000000000000000000000000..57d78bd55f08f8ded019ff02554422f9fcaa8d77 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/XmlStreamWriter.java" @@ -0,0 +1,220 @@ +/* + * 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.output; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.StringWriter; +import java.io.Writer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.io.input.XmlStreamReader; + +/** + * Character stream that handles all the necessary Voodo to figure out the + * charset encoding of the XML document written to the stream. + * + * @version $Id: XmlStreamWriter.java 1415850 2012-11-30 20:51:39Z ggregory $ + * @see XmlStreamReader + * @since 2.0 + */ +public class XmlStreamWriter extends Writer { + private static final int BUFFER_SIZE = 4096; + + private final OutputStream out; + + private final String defaultEncoding; + + private StringWriter xmlPrologWriter = new StringWriter(BUFFER_SIZE); + + private Writer writer; + + private String encoding; + + /** + * Construct an new XML stream writer for the specified output stream + * with a default encoding of UTF-8. + * + * @param out The output stream + */ + public XmlStreamWriter(final OutputStream out) { + this(out, null); + } + + /** + * Construct an new XML stream writer for the specified output stream + * with the specified default encoding. + * + * @param out The output stream + * @param defaultEncoding The default encoding if not encoding could be detected + */ + public XmlStreamWriter(final OutputStream out, final String defaultEncoding) { + this.out = out; + this.defaultEncoding = defaultEncoding != null ? defaultEncoding : "UTF-8"; + } + + /** + * Construct an new XML stream writer for the specified file + * with a default encoding of UTF-8. + * + * @param file The file to write to + * @throws FileNotFoundException if there is an error creating or + * opening the file + */ + public XmlStreamWriter(final File file) throws FileNotFoundException { + this(file, null); + } + + /** + * Construct an new XML stream writer for the specified file + * with the specified default encoding. + * + * @param file The file to write to + * @param defaultEncoding The default encoding if not encoding could be detected + * @throws FileNotFoundException if there is an error creating or + * opening the file + */ + public XmlStreamWriter(final File file, final String defaultEncoding) throws FileNotFoundException { + this(new FileOutputStream(file), defaultEncoding); + } + + /** + * Return the detected encoding. + * + * @return the detected encoding + */ + public String getEncoding() { + return encoding; + } + + /** + * Return the default encoding. + * + * @return the default encoding + */ + public String getDefaultEncoding() { + return defaultEncoding; + } + + /** + * Close the underlying writer. + * + * @throws IOException if an error occurs closing the underlying writer + */ + @Override + public void close() throws IOException { + if (writer == null) { + encoding = defaultEncoding; + writer = new OutputStreamWriter(out, encoding); + writer.write(xmlPrologWriter.toString()); + } + writer.close(); + } + + /** + * Flush the underlying writer. + * + * @throws IOException if an error occurs flushing the underlying writer + */ + @Override + public void flush() throws IOException { + if (writer != null) { + writer.flush(); + } + } + + /** + * Detect the encoding. + * + * @param cbuf the buffer to write the characters from + * @param off The start offset + * @param len The number of characters to write + * @throws IOException if an error occurs detecting the encoding + */ + private void detectEncoding(final char[] cbuf, final int off, final int len) + throws IOException { + int size = len; + final StringBuffer xmlProlog = xmlPrologWriter.getBuffer(); + if (xmlProlog.length() + len > BUFFER_SIZE) { + size = BUFFER_SIZE - xmlProlog.length(); + } + xmlPrologWriter.write(cbuf, off, size); + + // try to determine encoding + if (xmlProlog.length() >= 5) { + if (xmlProlog.substring(0, 5).equals(""); + if (xmlPrologEnd > 0) { + // ok, full XML prolog written: let's extract encoding + final Matcher m = ENCODING_PATTERN.matcher(xmlProlog.substring(0, + xmlPrologEnd)); + if (m.find()) { + encoding = m.group(1).toUpperCase(); + encoding = encoding.substring(1, encoding.length() - 1); + } else { + // no encoding found in XML prolog: using default + // encoding + encoding = defaultEncoding; + } + } else { + if (xmlProlog.length() >= BUFFER_SIZE) { + // no encoding found in first characters: using default + // encoding + encoding = defaultEncoding; + } + } + } else { + // no XML prolog: using default encoding + encoding = defaultEncoding; + } + if (encoding != null) { + // encoding has been chosen: let's do it + xmlPrologWriter = null; + writer = new OutputStreamWriter(out, encoding); + writer.write(xmlProlog.toString()); + if (len > size) { + writer.write(cbuf, off + size, len - size); + } + } + } + } + + /** + * Write the characters to the underlying writer, detecing encoding. + * + * @param cbuf the buffer to write the characters from + * @param off The start offset + * @param len The number of characters to write + * @throws IOException if an error occurs detecting the encoding + */ + @Override + public void write(final char[] cbuf, final int off, final int len) throws IOException { + if (xmlPrologWriter != null) { + detectEncoding(cbuf, off, len); + } else { + writer.write(cbuf, off, len); + } + } + + static final Pattern ENCODING_PATTERN = XmlStreamReader.ENCODING_PATTERN; +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/package.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/package.html" new file mode 100644 index 0000000000000000000000000000000000000000..44156133099931af89a39850a604cf96188722d0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/output/package.html" @@ -0,0 +1,25 @@ + + + + +

+This package provides implementations of output classes, such as +OutputStream and Writer. +

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/overview.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/overview.html" new file mode 100644 index 0000000000000000000000000000000000000000..5f2ff1e77a3c9c9d854d43485f6ef43bb6337895 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/overview.html" @@ -0,0 +1,32 @@ + + + + +

+The commons-io component contains utility classes, +filters, streams, readers and writers. +

+

+These classes aim to add to the standard JDK IO classes. +The utilities provide convenience wrappers around the JDK, simplifying +various operations into pre-tested units of code. +The filters and streams provide useful implementations that perhaps should +be in the JDK itself. +

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/package.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/package.html" new file mode 100644 index 0000000000000000000000000000000000000000..914a0a60c1a42eda8bea5a2a6d9f818d856a76a5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/package.html" @@ -0,0 +1,47 @@ + + + + +

+This package defines utility classes for working with streams, readers, +writers and files. The most commonly used classes are described here: +

+

+IOUtils is the most frequently used class. +It provides operations to read, write, copy and close streams. +

+

+FileUtils provides operations based around the JDK File class. +These include reading, writing, copying, comparing and deleting. +

+

+FilenameUtils provides utilities based on filenames. +This utility class manipulates filenames without using File objects. +It aims to simplify the transition between Windows and Unix. +Before using this class however, you should consider whether you should +be using File objects. +

+

+FileSystemUtils allows access to the filing system in ways the JDK +does not support. At present this allows you to get the free space on a drive. +

+

+EndianUtils swaps data between Big-Endian and Little-Endian formats. +

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/ClassNameMatcher.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/ClassNameMatcher.java" new file mode 100644 index 0000000000000000000000000000000000000000..00c2a6585f688a1a35c612c0709bd8b6dda36699 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/ClassNameMatcher.java" @@ -0,0 +1,33 @@ +/* + * 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.serialization; + +/** + * An object that matches a Class name to a condition. + */ +public interface ClassNameMatcher { + + /** + * Returns true if the supplied class name matches this object's condition. + * + * @param className fully qualified class name + * @return true if the class name matches this object's condition + */ + boolean matches(String className); +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/FullClassNameMatcher.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/FullClassNameMatcher.java" new file mode 100644 index 0000000000000000000000000000000000000000..55f5e4c4380e2f83c35acdf5b0b1b9f2f6aeec90 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/FullClassNameMatcher.java" @@ -0,0 +1,49 @@ +/* + * 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.serialization; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * A {@link ClassNameMatcher} that matches on full class names. + *

+ * This object is immutable and thread-safe. + *

+ */ +final class FullClassNameMatcher implements ClassNameMatcher { + + private final Set classesSet; + + /** + * Constructs an object based on the specified class names. + * + * @param classes a list of class names + */ + public FullClassNameMatcher(String... classes) { + classesSet = Collections.unmodifiableSet(new HashSet(Arrays.asList(classes))); + } + + @Override + public boolean matches(String className) { + return classesSet.contains(className); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/RegexpClassNameMatcher.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/RegexpClassNameMatcher.java" new file mode 100644 index 0000000000000000000000000000000000000000..2b8d18fe0f190eebbc2b46cff5a8a2e334d48f23 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/RegexpClassNameMatcher.java" @@ -0,0 +1,59 @@ +/* + * 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.serialization; + +import java.util.regex.Pattern; + +/** + * A {@link ClassNameMatcher} that uses regular expressions. + *

+ * This object is immutable and thread-safe. + *

+ */ +final class RegexpClassNameMatcher implements ClassNameMatcher { + + private final Pattern pattern; // Class is thread-safe + + /** + * Constructs an object based on the specified regular expression. + * + * @param regex a regular expression for evaluating acceptable class names + */ + public RegexpClassNameMatcher(String regex) { + this(Pattern.compile(regex)); + } + + /** + * Constructs an object based on the specified pattern. + * + * @param pattern a pattern for evaluating acceptable class names + * @throws IllegalArgumentException if pattern is null + */ + public RegexpClassNameMatcher(Pattern pattern) { + if (pattern == null) { + throw new IllegalArgumentException("Null pattern"); + } + this.pattern = pattern; + } + + @Override + public boolean matches(String className) { + return pattern.matcher(className).matches(); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..05e910dea6b6a171662957e30455c25e63539330 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/ValidatingObjectInputStream.java" @@ -0,0 +1,209 @@ +/* + * 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.serialization; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InvalidClassException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Pattern; + +/** + * An ObjectInputStream that's restricted to deserialize + * a limited set of classes. + * + *

+ * Various accept/reject methods allow for specifying which classes + * can be deserialized. + *

+ * + *

+ * Design inspired by IBM + * DeveloperWorks Article. + *

+ */ +public class ValidatingObjectInputStream extends ObjectInputStream { + private final List acceptMatchers = new ArrayList(); + private final List rejectMatchers = new ArrayList(); + + /** + * Constructs an object to deserialize the specified input stream. + * At least one accept method needs to be called to specify which + * classes can be deserialized, as by default no classes are + * accepted. + * + * @param input an input stream + * @throws IOException if an I/O error occurs while reading stream header + */ + public ValidatingObjectInputStream(InputStream input) throws IOException { + super(input); + } + + /** Check that the classname conforms to requirements. + * @param name The class name + * @throws InvalidClassException when a non-accepted class is encountered + */ + private void validateClassName(String name) throws InvalidClassException { + // Reject has precedence over accept + for (ClassNameMatcher m : rejectMatchers) { + if (m.matches(name)) { + invalidClassNameFound(name); + } + } + + boolean ok = false; + for (ClassNameMatcher m : acceptMatchers) { + if (m.matches(name)) { + ok = true; + break; + } + } + if (!ok) { + invalidClassNameFound(name); + } + } + + /** + * Called to throw InvalidClassException if an invalid + * class name is found during deserialization. Can be overridden, for example + * to log those class names. + * + * @param className name of the invalid class + * @throws InvalidClassException if the specified class is not allowed + */ + protected void invalidClassNameFound(String className) throws InvalidClassException { + throw new InvalidClassException("Class name not accepted: " + className); + } + + @Override + protected Class resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException { + validateClassName(osc.getName()); + return super.resolveClass(osc); + } + + /** + * Accept the specified classes for deserialization, unless they + * are otherwise rejected. + * + * @param classes Classes to accept + * @return this object + */ + public ValidatingObjectInputStream accept(Class... classes) { + for (Class c : classes) { + acceptMatchers.add(new FullClassNameMatcher(c.getName())); + } + return this; + } + + /** + * Reject the specified classes for deserialization, even if they + * are otherwise accepted. + * + * @param classes Classes to reject + * @return this object + */ + public ValidatingObjectInputStream reject(Class... classes) { + for (Class c : classes) { + rejectMatchers.add(new FullClassNameMatcher(c.getName())); + } + return this; + } + + /** + * Accept the wildcard specified classes for deserialization, + * unless they are otherwise rejected. + * + * @param patterns Wildcard filename patterns as defined by + * {@link org.apache.commons.io.FilenameUtils#wildcardMatch(String, String) FilenameUtils.wildcardMatch} + * @return this object + */ + public ValidatingObjectInputStream accept(String... patterns) { + for (String pattern : patterns) { + acceptMatchers.add(new WildcardClassNameMatcher(pattern)); + } + return this; + } + + /** + * Reject the wildcard specified classes for deserialization, + * even if they are otherwise accepted. + * + * @param patterns Wildcard filename patterns as defined by + * {@link org.apache.commons.io.FilenameUtils#wildcardMatch(String, String) FilenameUtils.wildcardMatch} + * @return this object + */ + public ValidatingObjectInputStream reject(String... patterns) { + for (String pattern : patterns) { + rejectMatchers.add(new WildcardClassNameMatcher(pattern)); + } + return this; + } + + /** + * Accept class names that match the supplied pattern for + * deserialization, unless they are otherwise rejected. + * + * @param pattern standard Java regexp + * @return this object + */ + public ValidatingObjectInputStream accept(Pattern pattern) { + acceptMatchers.add(new RegexpClassNameMatcher(pattern)); + return this; + } + + /** + * Reject class names that match the supplied pattern for + * deserialization, even if they are otherwise accepted. + * + * @param pattern standard Java regexp + * @return this object + */ + public ValidatingObjectInputStream reject(Pattern pattern) { + rejectMatchers.add(new RegexpClassNameMatcher(pattern)); + return this; + } + + /** + * Accept class names where the supplied ClassNameMatcher matches for + * deserialization, unless they are otherwise rejected. + * + * @param m the matcher to use + * @return this object + */ + public ValidatingObjectInputStream accept(ClassNameMatcher m) { + acceptMatchers.add(m); + return this; + } + + /** + * Reject class names where the supplied ClassNameMatcher matches for + * deserialization, even if they are otherwise accepted. + * + * @param m the matcher to use + * @return this object + */ + public ValidatingObjectInputStream reject(ClassNameMatcher m) { + rejectMatchers.add(m); + return this; + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/WildcardClassNameMatcher.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/WildcardClassNameMatcher.java" new file mode 100644 index 0000000000000000000000000000000000000000..98a1fc7bace81562eb49085cf206e42bd3dde6aa --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/WildcardClassNameMatcher.java" @@ -0,0 +1,47 @@ +/* + * 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.serialization; + +import org.apache.commons.io.FilenameUtils; + +/** + * A {@link ClassNameMatcher} that uses simplified regular expressions + * provided by {@link org.apache.commons.io.FilenameUtils#wildcardMatch(String, String) FilenameUtils.wildcardMatch} + *

+ * This object is immutable and thread-safe. + *

+ */ +final class WildcardClassNameMatcher implements ClassNameMatcher { + + private final String pattern; + + /** + * Constructs an object based on the specified simplified regular expression. + * + * @param pattern a {@link FilenameUtils#wildcardMatch} pattern. + */ + public WildcardClassNameMatcher(String pattern) { + this.pattern = pattern; + } + + @Override + public boolean matches(String className) { + return FilenameUtils.wildcardMatch(className, pattern); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/package.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/package.html" new file mode 100644 index 0000000000000000000000000000000000000000..271802e4daeac7706a86e072e317870fc4ea2c51 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/main/java/org/apache/commons/io/serialization/package.html" @@ -0,0 +1,24 @@ + + + + +

+This package provides a framework for controlling the deserialization of classes. +

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/media/io-logo-white.xcf" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/media/io-logo-white.xcf" new file mode 100644 index 0000000000000000000000000000000000000000..a3c899b544aef363d6ff27150b8d3a0480a63268 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/media/io-logo-white.xcf" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/media/logo.gif" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/media/logo.gif" new file mode 100644 index 0000000000000000000000000000000000000000..314441b415c5059cb2c0082efa683d798250c565 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/media/logo.gif" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/resources/download_io.cgi" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/resources/download_io.cgi" new file mode 100644 index 0000000000000000000000000000000000000000..495cde12dc8febbe45696b96fb29c372be24fa0b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/resources/download_io.cgi" @@ -0,0 +1,4 @@ +#!/bin/sh +# Just call the standard mirrors.cgi script. It will use download.html +# as the input template. +exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/resources/images/io-logo-white.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/resources/images/io-logo-white.png" new file mode 100644 index 0000000000000000000000000000000000000000..75be7af462d68915926b292656fd475760aa7739 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/resources/images/io-logo-white.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/site.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/site.xml" new file mode 100644 index 0000000000000000000000000000000000000000..84ec68c86bf1942df8eba1af7e465f1c077ae1e7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/site.xml" @@ -0,0 +1,49 @@ + + + + + Commons IO + /images/io-logo-white.png + /index.html + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/bestpractices.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/bestpractices.xml" new file mode 100644 index 0000000000000000000000000000000000000000..a4382df6d3e20125bac49c153f7f02139733d63a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/bestpractices.xml" @@ -0,0 +1,135 @@ + + + + + Best practices + Commons Documentation Team + + + +
+

+ This document presents a number of 'best practices' in the IO area. +

+
+ +
+ +

+ Often, you have to deal with files and filenames. There are many + things that can go wrong: +

+
    +
  • A class works in Unix but doesn't on Windows (or vice versa)
  • +
  • Invalid filenames due to double or missing path separators
  • +
  • UNC filenames (on Windows) don't work with my home-grown filename utility function
  • +
  • etc. etc.
  • +
+

+ These are good reasons not to work with filenames as Strings. + Using java.io.File instead handles many of the above cases nicely. + Thus, our best practice recommendation is to use java.io.File + instead of String for filenames to avoid platform dependencies. +

+

+ + Version 1.1 of commons-io now includes a dedicated filename + handling class - FilenameUtils. + This does handle many of these filename issues, however we still + recommend, wherever possible, that you use java.io.File objects. + +

+

+ Let's look at an example. +

+ + public static String getExtension(String filename) { + int index = filename.lastIndexOf('.'); + if (index == -1) { + return ""; + } else { + return filename.substring(index + 1); + } + } +

+ Easy enough? Right, but what happens if someone passes in a full path + instead of only a filename? Consider the following, perfectly legal path: + "C:\Temp\documentation.new\README". + The method as defined above would return "new\README" - definitely + not what you wanted. +

+

+ Please use java.io.File for filenames instead of Strings. + The functionality that the class provides is well tested. + In FileUtils you will find other useful utility functions + around java.io.File. +

+

+ Instead of: +

+ + String tmpdir = "/var/tmp"; + String tmpfile = tmpdir + System.getProperty("file.separator") + "test.tmp"; + InputStream in = new java.io.FileInputStream(tmpfile); +

+ ...write: +

+ + File tmpdir = new File("/var/tmp"); + File tmpfile = new File(tmpdir, "test.tmp"); + InputStream in = new java.io.FileInputStream(tmpfile); + +
+ +
+

+ IO performance depends a lot from the buffering strategy. Usually, it's + quite fast to read packets with the size of 512 or 1024 bytes because + these sizes match well with the packet sizes used on harddisks in + file systems or file system caches. But as soon as you have to read only + a few bytes and that many times performance drops significantly. +

+

+ Make sure you're properly buffering streams when reading or writing + streams, especially when working with files. Just decorate your + FileInputStream with a BufferedInputStream: +

+ + InputStream in = new java.io.FileInputStream(myfile); + try { + in = new java.io.BufferedInputStream(in); + + in.read(..... + } finally { + IOUtils.closeQuietly(in); + } +

+ Pay attention that you're not buffering an already buffered stream. Some + components like XML parsers may do their own buffering so decorating + the InputStream you pass to the XML parser does nothing but slowing down + your code. If you use our CopyUtils or IOUtils you don't need to + additionally buffer the streams you use as the code in there already + buffers the copy process. Always check the Javadocs for information. + Another case where buffering is unnecessary is when you write to a + ByteArrayOutputStream since you're writing to memory only. +

+
+ + + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/building.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/building.xml" new file mode 100644 index 0000000000000000000000000000000000000000..eed872ea9988efbd6f3f76aed1ee58133958fd47 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/building.xml" @@ -0,0 +1,79 @@ + + + + + Building + Commons Documentation Team + + + +
+

+ Commons IO uses Maven 2+ or + Ant as a build system. +

+

+ Commons IO requires a minimum of JDK 1.5 to build. +

+

+ You may also be interested in the upgrade notes:
+ Upgrade from 2.0 to 2.0.1
+ Upgrade from 1.4 to 2.0
+ Upgrade from 1.3.2 to 1.4
+ Upgrade from 1.3, or 1.3.1 to 1.3.2
+ Upgrade from 1.3 to 1.3.1
+ Upgrade from 1.2 to 1.3
+ Upgrade from 1.1 to 1.2
+ Upgrade from 1.0 to 1.1
+

+
+
+

+ The following Maven commands can be used to build io: +

+
    +
  • mvn clean - clean up
  • +
  • mvn test - compile and run the unit tests
  • +
  • mvn site - create io documentation
  • +
  • mvn package - build the jar
  • +
  • mvn package -Prc - Create the source and binary distributions
  • +
+
+ +
+

+ Note: +

    +
  • Dependencies are automatically downloaded if not specified explicitly in + a build.properties file.
  • +
+

+

+ The following Ant commands can be used to build io: +

+
    +
  • ant clean - clean up
  • +
  • ant test - compile and run the unit tests
  • +
  • ant javadoc - create javadocs
  • +
  • ant jar - build the jar
  • +
  • ant dist - Create the source and binary distributions
  • +
+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/description.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/description.xml" new file mode 100644 index 0000000000000000000000000000000000000000..df0d55c7a50a792c8cc28ac296636444c68c1bbc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/description.xml" @@ -0,0 +1,259 @@ + + + + + User guide + Commons Documentation Team + + + +
+

+ Commons-IO contains + utility classes, + endian classes, + line iterator, + file filters, + file comparators and + stream implementations. +

+ +

+ For a more detailed descriptions, take a look at the + javadocs. +

+
+ +
+ +

+ IOUtils + contains utility methods dealing with reading, writing and copying. + The methods work on InputStream, OutputStream, Reader and Writer. +

+

+ As an example, consider the task of reading bytes + from a URL, and printing them. This would typically done like this: +

+ + + InputStream in = new URL( "http://commons.apache.org" ).openStream(); + try { + InputStreamReader inR = new InputStreamReader( in ); + BufferedReader buf = new BufferedReader( inR ); + String line; + while ( ( line = buf.readLine() ) != null ) { + System.out.println( line ); + } + } finally { + in.close(); + } + +

+ With the IOUtils class, that could be done with: +

+ + + InputStream in = new URL( "http://commons.apache.org" ).openStream(); + try { + System.out.println( IOUtils.toString( in ) ); + } finally { + IOUtils.closeQuietly(in); + } + +

+ In certain application domains, such IO operations are + common, and this class can save a great deal of time. And you can + rely on well-tested code. +

+

+ For utility code such as this, flexibility and speed are of primary importance. + However you should also understand the limitations of this approach. + Using the above technique to read a 1GB file would result in an + attempt to create a 1GB String object! +

+ +
+ + +

+ The FileUtils + class contains utility methods for working with File objects. + These include reading, writing, copying and comparing files. +

+

+ For example to read an entire file line by line you could use: +

+ + File file = new File("/commons/io/project.properties"); + List lines = FileUtils.readLines(file, "UTF-8"); +
+ + +

+ The FilenameUtils + class contains utility methods for working with filenames without + using File objects. The class aims to be consistent + between Unix and Windows, to aid transitions between these + environments (such as moving from development to production). +

+

+ For example to normalize a filename removing double dot segments: +

+ + String filename = "C:/commons/io/../lang/project.xml"; + String normalized = FilenameUtils.normalize(filename); + // result is "C:/commons/lang/project.xml" +
+ + +

+ The FileSystemUtils + class contains + utility methods for working with the file system + to access functionality not supported by the JDK. + Currently, the only method is to get the free space on a drive. + Note that this uses the command line, not native code. +

+

+ For example to find the free space on a drive: +

+ + long freeSpace = FileSystemUtils.freeSpace("C:/"); +
+ +
+ +
+

+ 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. +

+ +

+ There are two classes in this package of relevance: +

+ +
    +
  • + The EndianUtils + class contains static methods for swapping the Endian-ness + of Java primitives and streams. +
  • + +
  • + The SwappedDataInputStream + class is an implementation of the DataInput interface. With + this, one can read data from files of non-native Endian-ness. +
  • +
+ +

+ For more information, see + http://www.cs.umass.edu/~verts/cs32/endian.html +

+ +
+ +
+

+ The org.apache.commons.io.LineIterator class + provides a flexible way for working with a line-based file. + An instance can be created directly, or via factory methods on + FileUtils or IOUtils. + The recommended usage pattern is: +

+ + LineIterator it = FileUtils.lineIterator(file, "UTF-8"); + try { + while (it.hasNext()) { + String line = it.nextLine(); + /// do something with line + } + } finally { + LineIterator.closeQuietly(iterator); + } +
+ +
+

+ The org.apache.commons.io.filefilter + package defines an interface + (IOFileFilter) + that combines both java.io.FileFilter and + java.io.FilenameFilter. Besides + that the package offers a series of ready-to-use + implementations of the IOFileFilter + interface including + implementation that allow you to combine other such filters. + + These filters can be used to list files or in FileDialog, for example. +

+

+ See the + filefilter + package javadoc for more details. +

+
+ +
+

+ The org.apache.commons.io.comparator + package provides a number of java.util.Comparator + implementations for java.io.File. + + These comparators can be used to sort lists and arrays of files, for example. +

+

+ See the + comparator + package javadoc for more details. +

+
+ +
+

+ The org.apache.commons.io.input and + org.apache.commons.io.output packages + contain various useful implementations of streams. + These include: +

    +
  • Null output stream - that silently absorbs all data sent to it
  • +
  • Tee output stream - that sends output data to two streams instead of one
  • +
  • Byte array output stream - that is a faster version of the JDK class
  • +
  • Counting streams - that count the number of bytes passed
  • +
  • Proxy streams - that delegate to the correct method in the proxy
  • +
  • Lockable writer - that provides synchronization of writes using a lock file
  • +
+

+

+ See the + input or + output + package javadoc for more details. +

+
+ + + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/download_io.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/download_io.xml" new file mode 100644 index 0000000000000000000000000000000000000000..bbb25653f9270b916c948e82df2554ba1f0a5409 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/download_io.xml" @@ -0,0 +1,138 @@ + + + + + + Download Apache Commons IO + Commons Documentation Team + + +
+ +

+ We recommend you use a mirror to download our release + builds, but you must verify the integrity of + the downloaded files using signatures downloaded from our main + distribution directories. Recent releases (48 hours) may not yet + be available from the mirrors. +

+ +

+ You are currently using [preferred]. If you + encounter a problem with this mirror, please select another + mirror. If all mirrors are failing, there are backup + mirrors (at the end of the mirrors list) that should be + available. +

+ [if-any logo][end] +

+ +
+

+ Other mirrors: + + +

+
+ +

+ The KEYS + link links to the code signing keys used to sign the product. + The PGP link downloads the OpenPGP compatible signature from our main site. + The MD5 link downloads the checksum from the main site. +

+
+
+
+ + + + + + + + + + + + +
commons-io-2.5-bin.tar.gzmd5pgp
commons-io-2.5-bin.zipmd5pgp
+
+ + + + + + + + + + + + +
commons-io-2.5-src.tar.gzmd5pgp
commons-io-2.5-src.zipmd5pgp
+
+
+
+

+ Older releases can be obtained from the archives. +

+ +
+ +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/index.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/index.xml" new file mode 100644 index 0000000000000000000000000000000000000000..7a1f16009a688f8e6d3887497cf2507e825b1c94 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/index.xml" @@ -0,0 +1,109 @@ + + + + + Commons IO Overview + Commons Documentation Team + + + +
+

+Commons IO is a library of utilities to assist with developing IO functionality. +

+

+There are six main areas included: +

    +
  • Utility classes + - with static methods to perform common tasks
  • +
  • Input + - useful Input Stream and Reader implementations
  • +
  • Output + - useful Output Stream and Writer implementations
  • +
  • Filters + - various implementations of file filters
  • +
  • Comparators + - various implementations of java.util.Comparator for files
  • +
  • File Monitor + - a component for monitoring file system events
  • +
+

+
+ +
+ + +

+ Commons IO 2.5 is the latest version and requires a minimum of JDK 1.6 - + Download now! +

+

+ View the + Release Notes + and + JavaDoc API documents +

+
+ + + +

+ Commons IO 2.4 requires a minimum of JDK 1.6 - +Download now! +

+

+View the Release Notes and +JavaDoc API documents +

+
+ + +

+Commons IO 2.2 requires a minimum of JDK 1.5 - +Download now! +

+

+View the Release Notes and +JavaDoc API documents +

+
+ + +

+For previous releases, see the Apache Archive. +

+
+ +
+ +
+

+The commons mailing lists act as the main support forum. +The user list is suitable for most library usage queries. +The dev list is intended for the development discussion. +Please remember that the lists are shared between all commons components, +so prefix your email by [io]. +

+

+Issues may be reported via ASF JIRA. +Please read the instructions carefully to submit a useful bug report or enhancement request. +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/issue-tracking.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/issue-tracking.xml" new file mode 100644 index 0000000000000000000000000000000000000000..9e059440ed57d6039c21e819504613e405f9dc06 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/issue-tracking.xml" @@ -0,0 +1,102 @@ + + + + + + Commons IO Issue tracking + Commons Documentation Team + + + +
+

+ Commons IO uses ASF JIRA for tracking issues. + See the Commons IO JIRA project page. +

+ +

+ To use JIRA you may need to create an account + (if you have previously created/updated Commons issues using Bugzilla an account will have been automatically + created and you can use the Forgot Password + page to get a new password). +

+ +

+ If you would like to report a bug, or raise an enhancement request with + Commons IO please do the following: +

    +
  1. Search existing open bugs. + If you find your issue listed then please add a comment with your details.
  2. +
  3. Search the mailing list archive(s). + You may find your issue or idea has already been discussed.
  4. +
  5. Decide if your issue is a bug or an enhancement.
  6. +
  7. Submit either a bug report + or enhancement request.
  8. +
+

+ +

+ Please also remember these points: +

    +
  • the more information you provide, the better we can help you
  • +
  • test cases are vital, particularly for any proposed enhancements
  • +
  • the developers of Commons IO are all unpaid volunteers
  • +
+

+ +

+ For more information on subversion and creating patches see the + Apache Contributors Guide. +

+ +

+ You may also find these links useful: +

+

+
+ +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/mail-lists.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/mail-lists.xml" new file mode 100644 index 0000000000000000000000000000000000000000..0e375acae92863128e811408cdd5278dec3edef9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/mail-lists.xml" @@ -0,0 +1,202 @@ + + + + + + Commons IO Mailing Lists + Commons Documentation Team + + + +
+

+ Commons IO shares mailing lists with all the other + Commons Components. + To make it easier for people to only read messages related to components they are interested in, + the convention in Commons is to prefix the subject line of messages with the component's name, + for example: +

    +
  • [io] Problem with the ...
  • +
+

+

+ Questions related to the usage of Commons IO should be posted to the + User List. +
+ The Developer List + is for questions and discussion related to the development of Commons IO. +
+ Please do not cross-post; developers are also subscribed to the user list. +

+

+ Note: please don't send patches or attachments to any of the mailing lists. + Patches are best handled via the Issue Tracking system. + Otherwise, please upload the file to a public server and include the URL in the mail. +

+
+ +
+

+ Please prefix the subject line of any messages for Commons IO + with [io] - thanks! +
+
+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameSubscribeUnsubscribePostArchiveOther Archives
+ Commons User List +

+ Questions on using Commons IO. +

+
SubscribeUnsubscribePostmail-archives.apache.orgmarkmail.org
+ www.mail-archive.com
+ news.gmane.org +
+ Commons Developer List +

+ Discussion of development of Commons IO. +

+
SubscribeUnsubscribePostmail-archives.apache.orgmarkmail.org
+ www.mail-archive.com
+ news.gmane.org +
+ Commons Issues List +

+ Only for e-mails automatically generated by the issue tracking system. +

+
SubscribeUnsubscriberead onlymail-archives.apache.orgmarkmail.org
+ www.mail-archive.com +
+ Commons Commits List +

+ Only for e-mails automatically generated by the source control system. +

+
SubscribeUnsubscriberead onlymail-archives.apache.orgmarkmail.org
+ www.mail-archive.com +
+ +
+
+

+ Other mailing lists which you may find useful include: +

+ + + + + + + + + + + + + + + + + + +
NameSubscribeUnsubscribePostArchiveOther Archives
+ Apache Announce List +

+ General announcements of Apache project releases. +

+
SubscribeUnsubscriberead onlymail-archives.apache.orgmarkmail.org
+ old.nabble.com
+ www.mail-archive.com
+ news.gmane.org +
+ +
+ +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/proposal.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/proposal.xml" new file mode 100644 index 0000000000000000000000000000000000000000..ac20c4d22b1b50e4d39fc164c6924da230b026bd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/proposal.xml" @@ -0,0 +1,88 @@ + + + + + + Proposal + Commons Documentation Team + + + + +
+ + + + + +

Many software projects have a need to perform I/O in various ways, and +the JDK class libraries provide a lot of functionality, but sometimes you +need just a little bit more. The io package seeks to encapsulate some of +the most popular i/o base classes into one easy to use package.

+ +
+ + +

This proposal is to create a package of Java utility classes for various +types of i/o related activity.

+ +
+ + +

IO relies only on standard JDK 1.2 (or later) APIs for production +deployment. It utilizes the JUnit unit testing framework for developing +and executing unit tests, but this is of interest only to developers of the +component. IO will be a dependency for several existing components in the +open source world.

+ +

No external configuration files are utilized.

+ +
+ + +

The original Java classes are splashed around various Apache subprojects. + We intend to seek them out and integrate them.

+ +

The proposed package name for the new component is org.apache.commons.io.

+ +
+ + +
    +
  • CVS Repository - New directory io in the jakarta-commons +CVS repository.
  • +
  • Mailing List - Discussions will take place on the general dev@commons.apache.org +mailing list. To help list subscribers identify messages of interest, +it is suggested that the message subject of messages about this component +be prefixed with [IO].
  • +
  • Bugzilla - New component "IO" under the "Commons" product category, +with appropriate version identifiers as needed.
  • +
  • Jyve FAQ - New category "commons-io" (when available).
  • + +
+ +
+ + +

The initial committers on the IO component shall be Scott Sanders and +Nicola Ken Barozzi and Henri Yandell

+ +
+
+ +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/tasks.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/tasks.xml" new file mode 100644 index 0000000000000000000000000000000000000000..76919fd3e88bc5f6b0674fd2010306f177149ce7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/tasks.xml" @@ -0,0 +1,39 @@ + + + + + Tasks + Commons Documentation Team + + +
+

+ The following are some of the proposed ideas and tasks for commons-io: +

+
    +
  • A proper user guide
  • +
  • A URLUtils class that has many of the FileUtils operations, but for a URL
  • +
  • FilePoller for telling when a file changes. Look in Tomcat, or GenJava[bayard] (One implemented in bugzilla awaiting investigation)
  • +
  • A "hot folder" handler which triggers an action when a new file has been uploaded to an FTP directory, for example.
  • +
  • JoinReader/ConcatReader. One in GenJava, one submitted to Bayard
  • +
  • FormattedWriter, when it writes out values it uses Format objects to output them.
  • +
  • FixedWidthReader. Reads in files with a known width, ie) mainframe like.
  • +
+
+ +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_1.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_1.xml" new file mode 100644 index 0000000000000000000000000000000000000000..1b0e725963e6d547bfa3203c46be0273ee11ffea --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_1.xml" @@ -0,0 +1,207 @@ + + + + + Upgrade from 1.0 to 1.1 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 1.0 to version 1.1. + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +and endian transformation classes. + + +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 + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_2.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_2.xml" new file mode 100644 index 0000000000000000000000000000000000000000..67b45d3a1bef5e843564b3c4a779df2a67ece721 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_2.xml" @@ -0,0 +1,90 @@ + + + + + Upgrade from 1.1 to 1.2 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 1.1 to version 1.2. + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +and endian transformation classes. + + +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] + + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3.xml" new file mode 100644 index 0000000000000000000000000000000000000000..a243a3e1e2f41409bf7516dfa1a09eefb5493054 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3.xml" @@ -0,0 +1,228 @@ + + + + + Upgrade from 1.2 to 1.3 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 1.2 to version 1.3. + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +and endian transformation classes. + + +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 + + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3_1.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3_1.xml" new file mode 100644 index 0000000000000000000000000000000000000000..baec5c11566d02b6905979848adef01705456dc0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3_1.xml" @@ -0,0 +1,60 @@ + + + + + Upgrade from 1.3 to 1.3.1 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 1.3 to version 1.3.1. + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +and endian transformation classes. + + +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] + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3_2.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3_2.xml" new file mode 100644 index 0000000000000000000000000000000000000000..4baebea60ab12af71b11daa1904ab3d85b8d6ac1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_3_2.xml" @@ -0,0 +1,87 @@ + + + + + Upgrade from 1.3, or 1.3.1, to 1.3.2 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 1.3, or 1.3.1, to version 1.3.2. + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +and endian transformation classes. + + +Compatibility with 1.3.1 +------------------------ +Binary compatible - Yes + +Source compatible - Yes + +Semantic compatible - Yes + Check the bug fixes section for semantic bug fixes + + +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. (For reasons of compatibility, the + deprecation warnings are hidden within the 1.3 branch. They'll be + visible, as of version 1.4.) + + +Bug fixes from 1.3.1 +-------------------- + +- Some tests, which are implicitly assuming a Unix-like file system, are + now skipped on Windows. [IO-115] + + +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] + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_4.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_4.xml" new file mode 100644 index 0000000000000000000000000000000000000000..7056de7a44093d9da6671da78e9b8810062ae1e1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto1_4.xml" @@ -0,0 +1,142 @@ + + + + + Upgrade from 1.3.2 to 1.4 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 1.3.2 to version 1.4. + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +file comparators and endian transformation classes. + + +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 for +those 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] + +- 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] + - Add a copyDirectory() method that makes use of FileFilter [IO-105] + - Add moveDirectory() and moveFile() methods [IO-77] + +- 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. + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_0.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_0.xml" new file mode 100644 index 0000000000000000000000000000000000000000..3a9dd0aad462f8f45563d762a7db6969cf395386 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_0.xml" @@ -0,0 +1,157 @@ + + + + + Upgrade from 1.4 to 2.0 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 1.4 to version 2.0. + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +file comparators and endian transformation classes. + + +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 + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_0_1.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_0_1.xml" new file mode 100644 index 0000000000000000000000000000000000000000..5f6f53eaa839c422094dcd16067186831b0c1caa --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_0_1.xml" @@ -0,0 +1,67 @@ + + + + + Upgrade from 2.0 to 2.0.1 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 2.0 to version 2.0.1 + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +file comparators and endian transformation classes. + + +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 + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_1.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_1.xml" new file mode 100644 index 0000000000000000000000000000000000000000..f1f75b56c8ea4366e4bae7755ddc94b15a20ba81 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_1.xml" @@ -0,0 +1,82 @@ + + + + + Upgrade from 2.0.1 to 2.1 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 2.0.1 to version 2.1 + +Commons IO is a package of Java utility classes for java.io's hierarchy. +Classes in this package are considered to be so standard and of such high +reuse as to justify existence in java.io. + +Commons IO contains utility classes, stream implementations, file filters, +file comparators and endian transformation classes. + +Compatibility with 2.0.1 and 1.4 +-------------------------------- + +Binary compatible - Yes + +Source compatible - Yes + +Semantic compatible - Yes + Check the bug fixes section for semantic bug fixes + +Commons IO 2.1 requires a minimum of JDK 1.5 + (Commons IO 1.4 had a minimum of JDK 1.3) + + +New features since 2.0.1 +------------------------ + +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 since 2.0.1 +---------------------- + +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 since 2.0.1 +------------------- +o FileAlterationMonitor.stop(boolean allowIntervalToFinish) Issue: IO-259. + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_2.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_2.xml" new file mode 100644 index 0000000000000000000000000000000000000000..45497e6932f504a351eebe891977cad0babcf0f2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_2.xml" @@ -0,0 +1,82 @@ + + + + + Upgrade from 2.1 to 2.2 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 2.1 to version 2.2 + +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. + +Commons IO contains utility classes, stream implementations, file filters, +file comparators, endian transformation classes, and much more. + +============================================================================== +Commons IO Package Version 2.2 +============================================================================== + +Changes in this version include: + +New features: +o IO-305: New copyLarge() method in IOUtils that takes additional offset, length arguments Thanks to Manoj Mokashi. +o IO-287: Use terabyte (TB) , petabyte (PB) and exabyte (EB) in FileUtils.byteCountToDisplaySize(long size) Thanks to Ron Kuris, Gary Gregory. +o IO-173: FileUtils.listFiles() doesn't return directories Thanks to Marcos Vinícius da Silva. +o IO-297: CharSequenceInputStream to efficiently stream content of a CharSequence Thanks to Oleg Kalnichevski. +o IO-304: The second constructor of Tailer class does not pass 'delay' to the third one Thanks to liangly. +o IO-303: TeeOutputStream does not call branch.close() when main.close() throws an exception Thanks to fabian.barney. +o IO-302: ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times Thanks to jsteuerwald, detinho. +o IO-301: Add IOUtils.closeQuietly(Selector) necessary Thanks to kaykay.unique. +o IO-292: IOUtils.closeQuietly() should take a ServerSocket as a parameter Thanks to sebb. +o IO-290: Add read/readFully methods to IOUtils Thanks to sebb. +o IO-288: Supply a ReversedLinesFileReader Thanks to Georg Henzler. +o IO-291: Add new function FileUtils.directoryContains. Thanks to ggregory. +o IO-275: FileUtils.contentEquals and IOUtils.contentEquals - Add option to ignore "line endings" + Added contentEqualsIgnoreEOL methods to both classes Thanks to CJ Aspromgos. + +Fixed Bugs: +o IO-300: FileUtils.moveDirectoryToDirectory removes source directory if destination is a subdirectory +o IO-307: ReaderInputStream#read(byte[] b, int off, int len) should check for valid parameters +o IO-306: ReaderInputStream#read(byte[] b, int off, int len) should always return 0 for length == 0 +o IO-276: "FileUtils#deleteDirectoryOnExit(File)" does not work Thanks to nkami. +o IO-273: BoundedInputStream.read() treats max differently from BoundedInputStream.read(byte[]...) Thanks to sebb. +o IO-298: Various methods of class 'org.apache.commons.io.FileUtils' incorrectly suppress 'java.io.IOException' Thanks to Christian Schulte. + +Changes: +o IO-296: ReaderInputStream optimization: more efficient reading of small chunks of data Thanks to Oleg Kalnichevski. + +Compatibility with 2.1 and 1.4: +Binary compatible: Yes +Source compatible: Yes +Semantic 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. + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_3.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_3.xml" new file mode 100644 index 0000000000000000000000000000000000000000..56a4948208ac745f716a0b0b074a94415f800d3c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_3.xml" @@ -0,0 +1,61 @@ + + + + + Upgrade from 2.2 to 2.3 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 2.2 to version 2.3 + +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 Commons IO library contains utility classes, stream implementations, file filters, +file comparators, endian transformation classes, and much more. + +============================================================================== +Apache Commons IO Version 2.3-SNAPSHOT +============================================================================== + +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. + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_4.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_4.xml" new file mode 100644 index 0000000000000000000000000000000000000000..9f46468265193a825eecc39f78f952dad18ccf78 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_4.xml" @@ -0,0 +1,81 @@ + + + + + Upgrade from 2.3 to 2.4 + Commons Documentation Team + + + +
+

+These are the release notes and advice for upgrading Commons-IO from +version 2.3 to version 2.4 + +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 Commons IO library contains utility classes, stream implementations, file filters, +file comparators, endian transformation classes, and much more. + +============================================================================== +Apache Commons IO Version 2.4-SNAPSHOT +============================================================================== + +Changes in this version include: + +New features: +o IO-269: Tailer locks file from deletion/rename on Windows. Thanks to sebb. +o IO-333: Export OSGi packages at version 1.x in addition to 2.x. Thanks to fmeschbe. +o IO-320: Add XmlStreamReader support for UTF-32. Thanks to ggregory. +o IO-331: BOMInputStream wrongly detects UTF-32LE_BOM files as UTF-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. Thanks to raviprak. +o IO-324: Add missing Charset sister APIs to method that take a String charset name. Thanks to raviprak. + +Fixed Bugs: +o IO-279: Tailer erroneously considers file as new. Thanks to Sergio Bossa, Chris Baron. +o IO-335: Tailer#readLines - incorrect CR handling. +o IO-334: FileUtils.toURLs throws NPE for null parameter; document the behavior. +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 to raviprak. + +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. + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_5.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_5.xml" new file mode 100644 index 0000000000000000000000000000000000000000..a706c04b686637b56b34fd42c21b58bcb513d381 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/site/xdoc/upgradeto2_5.xml" @@ -0,0 +1,84 @@ + + + + + Upgrade from 2.4 to 2.5 + Commons Documentation Team + + + +
+

+ These are the release notes and advice for upgrading Commons-IO from + version 2.4 to version 2.5 + + 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 Commons IO library contains utility classes, stream implementations, file filters, + file comparators, endian transformation classes, and much more. + + ============================================================================== + Apache Commons IO Version 2.4-SNAPSHOT + ============================================================================== + + Changes in this version include: + + New features: + o IO-269: Tailer locks file from deletion/rename on Windows. Thanks to sebb. + o IO-333: Export OSGi packages at version 1.x in addition to 2.x. Thanks to fmeschbe. + o IO-320: Add XmlStreamReader support for UTF-32. Thanks to ggregory. + o IO-331: BOMInputStream wrongly detects UTF-32LE_BOM files as UTF-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. Thanks to raviprak. + o IO-324: Add missing Charset sister APIs to method that take a String charset name. Thanks to + raviprak. + + Fixed Bugs: + o IO-279: Tailer erroneously considers file as new. Thanks to Sergio Bossa, Chris Baron. + o IO-335: Tailer#readLines - incorrect CR handling. + o IO-334: FileUtils.toURLs throws NPE for null parameter; document the behavior. + 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 to raviprak. + + 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.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. + +

+
+ + +
diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/ByteOrderMarkTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/ByteOrderMarkTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..92fdc22899acee2bc31e25790ae7bdabf4a764fa --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/ByteOrderMarkTestCase.java" @@ -0,0 +1,147 @@ +/* + * 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.Arrays; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + + +/** + * Test for {@link ByteOrderMark}. + * + * @version $Id: ByteOrderMarkTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class ByteOrderMarkTestCase { + + private static final ByteOrderMark TEST_BOM_1 = new ByteOrderMark("test1", 1); + private static final ByteOrderMark TEST_BOM_2 = new ByteOrderMark("test2", 1, 2); + private static final ByteOrderMark TEST_BOM_3 = new ByteOrderMark("test3", 1, 2, 3); + + /** Test {@link ByteOrderMark#getCharsetName()} */ + @Test + public void charsetName() { + assertEquals("test1 name", "test1", TEST_BOM_1.getCharsetName()); + assertEquals("test2 name", "test2", TEST_BOM_2.getCharsetName()); + assertEquals("test3 name", "test3", TEST_BOM_3.getCharsetName()); + } + + /** Tests that {@link ByteOrderMark#getCharsetName()} can be loaded as a {@link java.nio.charset.Charset} as advertised. */ + @Test + public void constantCharsetNames() { + assertNotNull(Charset.forName(ByteOrderMark.UTF_8.getCharsetName())); + assertNotNull(Charset.forName(ByteOrderMark.UTF_16BE.getCharsetName())); + assertNotNull(Charset.forName(ByteOrderMark.UTF_16LE.getCharsetName())); + assertNotNull(Charset.forName(ByteOrderMark.UTF_32BE.getCharsetName())); + assertNotNull(Charset.forName(ByteOrderMark.UTF_32LE.getCharsetName())); + } + + /** Test {@link ByteOrderMark#length()} */ + @Test + public void testLength() { assertEquals("test1 length", 1, TEST_BOM_1.length()); + assertEquals("test2 length", 2, TEST_BOM_2.length()); + assertEquals("test3 length", 3, TEST_BOM_3.length()); + } + + /** Test {@link ByteOrderMark#get(int)} */ + @Test + public void get() { + assertEquals("test1 get(0)", 1, TEST_BOM_1.get(0)); + assertEquals("test2 get(0)", 1, TEST_BOM_2.get(0)); + assertEquals("test2 get(1)", 2, TEST_BOM_2.get(1)); + assertEquals("test3 get(0)", 1, TEST_BOM_3.get(0)); + assertEquals("test3 get(1)", 2, TEST_BOM_3.get(1)); + assertEquals("test3 get(2)", 3, TEST_BOM_3.get(2)); + } + + /** Test {@link ByteOrderMark#getBytes()} */ + @Test + public void getBytes() { + assertTrue("test1 bytes", Arrays.equals(TEST_BOM_1.getBytes(), new byte[] {(byte)1})); + assertTrue("test1 bytes", Arrays.equals(TEST_BOM_2.getBytes(), new byte[] {(byte)1, (byte)2})); + assertTrue("test1 bytes", Arrays.equals(TEST_BOM_3.getBytes(), new byte[] {(byte)1, (byte)2, (byte)3})); + } + + /** Test {@link ByteOrderMark#equals(Object)} */ + @SuppressWarnings("EqualsWithItself") + @Test + public void testEquals() { + assertTrue("test1 equals", TEST_BOM_1.equals(TEST_BOM_1)); + assertTrue("test2 equals", TEST_BOM_2.equals(TEST_BOM_2)); + assertTrue("test3 equals", TEST_BOM_3.equals(TEST_BOM_3)); + + assertFalse("Object not equal", TEST_BOM_1.equals(new Object())); + assertFalse("test1-1 not equal", TEST_BOM_1.equals(new ByteOrderMark("1a", 2))); + assertFalse("test1-2 not test2", TEST_BOM_1.equals(new ByteOrderMark("1b", 1, 2))); + assertFalse("test2 not equal", TEST_BOM_2.equals(new ByteOrderMark("2", 1, 1))); + assertFalse("test3 not equal", TEST_BOM_3.equals(new ByteOrderMark("3", 1, 2, 4))); + } + + /** Test {@link ByteOrderMark#hashCode()} */ + @Test + public void testHashCode() { + final int bomClassHash = ByteOrderMark.class.hashCode(); + assertEquals("hash test1 ", bomClassHash + 1, TEST_BOM_1.hashCode()); + assertEquals("hash test2 ", bomClassHash + 3, TEST_BOM_2.hashCode()); + assertEquals("hash test3 ", bomClassHash + 6, TEST_BOM_3.hashCode()); + } + + /** Test Erros */ + @Test + public void errors() { + try { + new ByteOrderMark(null, 1,2,3); + fail("null charset name, expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected + } + try { + new ByteOrderMark("", 1,2,3); + fail("no charset name, expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected + } + try { + new ByteOrderMark("a", (int[])null); + fail("null bytes, expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected + } + try { + new ByteOrderMark("b"); + fail("empty bytes, expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected + } + } + + /** Test {@link ByteOrderMark#toString()} */ + @Test + public void testToString() { + assertEquals("test1 ", "ByteOrderMark[test1: 0x1]", TEST_BOM_1.toString()); + assertEquals("test2 ", "ByteOrderMark[test2: 0x1,0x2]", TEST_BOM_2.toString()); + assertEquals("test3 ", "ByteOrderMark[test3: 0x1,0x2,0x3]", TEST_BOM_3.toString()); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/CharsetsTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/CharsetsTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..9f50dd043b0ad5eeb83b2ed9e543714c7c2a8cf2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/CharsetsTestCase.java" @@ -0,0 +1,90 @@ +/* + * 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.SortedMap; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Tests {@link Charsets}. + * + * @version $Id: CharEncodingTest.java 1298985 2012-03-09 19:12:49Z ggregory $ + */ +public class CharsetsTestCase { + + @Test + public void testRequiredCharsets() { + final SortedMap requiredCharsets = Charsets.requiredCharsets(); + // test for what we expect to be there as of Java 6 + // Make sure the object at the given key is the right one + Assert.assertEquals(requiredCharsets.get("US-ASCII").name(), "US-ASCII"); + Assert.assertEquals(requiredCharsets.get("ISO-8859-1").name(), "ISO-8859-1"); + Assert.assertEquals(requiredCharsets.get("UTF-8").name(), "UTF-8"); + Assert.assertEquals(requiredCharsets.get("UTF-16").name(), "UTF-16"); + Assert.assertEquals(requiredCharsets.get("UTF-16BE").name(), "UTF-16BE"); + Assert.assertEquals(requiredCharsets.get("UTF-16LE").name(), "UTF-16LE"); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testIso8859_1() { + Assert.assertEquals("ISO-8859-1", Charsets.ISO_8859_1.name()); + } + + @Test + public void testToCharset() { + Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((String) null)); + Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset((Charset) null)); + Assert.assertEquals(Charset.defaultCharset(), Charsets.toCharset(Charset.defaultCharset())); + Assert.assertEquals(Charset.forName("UTF-8"), Charsets.toCharset(Charset.forName("UTF-8"))); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testUsAscii() { + Assert.assertEquals("US-ASCII", Charsets.US_ASCII.name()); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testUtf16() { + Assert.assertEquals("UTF-16", Charsets.UTF_16.name()); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testUtf16Be() { + Assert.assertEquals("UTF-16BE", Charsets.UTF_16BE.name()); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testUtf16Le() { + Assert.assertEquals("UTF-16LE", Charsets.UTF_16LE.name()); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testUtf8() { + Assert.assertEquals("UTF-8", Charsets.UTF_8.name()); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/CopyUtilsTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/CopyUtilsTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..7b6add92e4c775043f4051c4f4c510c2fc191758 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/CopyUtilsTest.java" @@ -0,0 +1,225 @@ +/* + * 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.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Arrays; + +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.apache.commons.io.testtools.YellOnCloseInputStream; +import org.apache.commons.io.testtools.YellOnFlushAndCloseOutputStream; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@SuppressWarnings("deprecation") // these are test cases for the deprecated CopyUtils + +/** + * JUnit tests for CopyUtils. + * + * @version $Id: CopyUtilsTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + * @see CopyUtils + */ +public class CopyUtilsTest extends FileBasedTestCase { + + /* + * NOTE this is not particularly beautiful code. A better way to check for + * flush and close status would be to implement "trojan horse" wrapper + * implementations of the various stream classes, which set a flag when + * relevant methods are called. (JT) + */ + + private static final int FILE_SIZE = 1024 * 4 + 1; + + + private final byte[] inData = TestUtils.generateTestData((long) FILE_SIZE); + + // ---------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------- + + @Test + public void testCtor() { + new CopyUtils(); + // Nothing to assert, the constructor is public and does not blow up. + } + + @Test + public void copy_byteArrayToOutputStream() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + CopyUtils.copy(inData, out); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void copy_byteArrayToWriter() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + final Writer writer = new java.io.OutputStreamWriter(out, "US-ASCII"); + + CopyUtils.copy(inData, writer); + writer.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testCopy_byteArrayToWriterWithEncoding() throws Exception { + final String inDataStr = "data"; + final String charsetName = "UTF-8"; + final StringWriter writer = new StringWriter(); + CopyUtils.copy(inDataStr.getBytes(charsetName), writer, charsetName); + assertEquals(inDataStr, writer.toString()); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_inputStreamToOutputStream() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + final int count = CopyUtils.copy(in, out); + + assertEquals("Not all bytes were read", 0, in.available()); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + assertEquals(inData.length, count); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void copy_inputStreamToWriter() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + final Writer writer = new java.io.OutputStreamWriter(out, "US-ASCII"); + + CopyUtils.copy(in, writer); + writer.flush(); + + assertEquals("Not all bytes were read", 0, in.available()); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void copy_inputStreamToWriterWithEncoding() throws Exception { + final String inDataStr = "data"; + final String charsetName = "UTF-8"; + final StringWriter writer = new StringWriter(); + CopyUtils.copy(new ByteArrayInputStream(inDataStr.getBytes(charsetName)), writer, charsetName); + assertEquals(inDataStr, writer.toString()); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_readerToOutputStream() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new java.io.InputStreamReader(in, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + CopyUtils.copy(reader, out); + //Note: this method *does* flush. It is equivalent to: + // OutputStreamWriter _out = new OutputStreamWriter(fout); + // IOUtils.copy( fin, _out, 4096 ); // copy( Reader, Writer, int ); + // _out.flush(); + // out = fout; + + // Note: rely on the method to flush + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void copy_readerToWriter() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new java.io.InputStreamReader(in, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + final Writer writer = new java.io.OutputStreamWriter(out, "US-ASCII"); + + final int count = CopyUtils.copy(reader, writer); + writer.flush(); + assertEquals( + "The number of characters returned by copy is wrong", + inData.length, + count); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void copy_stringToOutputStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + CopyUtils.copy(str, out); + //Note: this method *does* flush. It is equivalent to: + // OutputStreamWriter _out = new OutputStreamWriter(fout); + // IOUtils.copy( str, _out, 4096 ); // copy( Reader, Writer, int ); + // _out.flush(); + // out = fout; + // note: we don't flush here; this IOUtils method does it for us + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void copy_stringToWriter() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + final Writer writer = new java.io.OutputStreamWriter(out, "US-ASCII"); + + CopyUtils.copy(str, writer); + writer.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + +} // CopyUtilsTest diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DemuxTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DemuxTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..1eb11e5d205986a4048db05b9350ed3f07aa9b4b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DemuxTestCase.java" @@ -0,0 +1,210 @@ +/* + * 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.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Random; + +import org.apache.commons.io.input.DemuxInputStream; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.io.output.DemuxOutputStream; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.Test; + +/** + * Basic unit tests for the multiplexing streams. + */ +public class DemuxTestCase { + private static final String T1 = "Thread1"; + private static final String T2 = "Thread2"; + private static final String T3 = "Thread3"; + private static final String T4 = "Thread4"; + + private static final String DATA1 = "Data for thread1"; + private static final String DATA2 = "Data for thread2"; + private static final String DATA3 = "Data for thread3"; + private static final String DATA4 = "Data for thread4"; + + private static final Random c_random = new Random(); + private final HashMap m_outputMap = new HashMap(); + private final HashMap m_threadMap = new HashMap(); + + @SuppressWarnings("deprecation") // unavoidable until Java 7 + private String getOutput(final String threadName) { + final ByteArrayOutputStream output = + m_outputMap.get(threadName); + assertNotNull("getOutput()", output); + + return output.toString(Charsets.UTF_8); + } + + private String getInput(final String threadName) { + final ReaderThread thread = (ReaderThread) m_threadMap.get(threadName); + assertNotNull("getInput()", thread); + + return thread.getData(); + } + + private void doStart() + throws Exception { + for (String name : m_threadMap.keySet()) { + final Thread thread = m_threadMap.get(name); + thread.start(); + } + } + + private void doJoin() + throws Exception { + for (String name : m_threadMap.keySet()) { + final Thread thread = m_threadMap.get(name); + thread.join(); + } + } + + private void startWriter(final String name, + final String data, + final DemuxOutputStream demux) + throws Exception { + final ByteArrayOutputStream output = new ByteArrayOutputStream(); + m_outputMap.put(name, output); + final WriterThread thread = + new WriterThread(name, data, output, demux); + m_threadMap.put(name, thread); + } + + private void startReader(final String name, + final String data, + final DemuxInputStream demux) + throws Exception { + final ByteArrayInputStream input = new ByteArrayInputStream(data.getBytes()); + final ReaderThread thread = new ReaderThread(name, input, demux); + m_threadMap.put(name, thread); + } + + @Test + public void testOutputStream() + throws Exception { + final DemuxOutputStream output = new DemuxOutputStream(); + startWriter(T1, DATA1, output); + startWriter(T2, DATA2, output); + startWriter(T3, DATA3, output); + startWriter(T4, DATA4, output); + + doStart(); + doJoin(); + + assertEquals("Data1", DATA1, getOutput(T1)); + assertEquals("Data2", DATA2, getOutput(T2)); + assertEquals("Data3", DATA3, getOutput(T3)); + assertEquals("Data4", DATA4, getOutput(T4)); + } + + @Test + public void testInputStream() + throws Exception { + final DemuxInputStream input = new DemuxInputStream(); + startReader(T1, DATA1, input); + startReader(T2, DATA2, input); + startReader(T3, DATA3, input); + startReader(T4, DATA4, input); + + doStart(); + doJoin(); + + assertEquals("Data1", DATA1, getInput(T1)); + assertEquals("Data2", DATA2, getInput(T2)); + assertEquals("Data3", DATA3, getInput(T3)); + assertEquals("Data4", DATA4, getInput(T4)); + } + + private static class ReaderThread + extends Thread { + private final StringBuffer m_buffer = new StringBuffer(); + private final InputStream m_input; + private final DemuxInputStream m_demux; + + ReaderThread(final String name, + final InputStream input, + final DemuxInputStream demux) { + super(name); + m_input = input; + m_demux = demux; + } + + public String getData() { + return m_buffer.toString(); + } + + @Override + public void run() { + m_demux.bindStream(m_input); + + try { + int ch = m_demux.read(); + while (-1 != ch) { + //System.out.println( "Reading: " + (char)ch ); + m_buffer.append((char) ch); + + final int sleepTime = Math.abs(c_random.nextInt() % 10); + TestUtils.sleep(sleepTime); + ch = m_demux.read(); + } + } catch (final Exception e) { + e.printStackTrace(); + } + } + } + + private static class WriterThread + extends Thread { + private final byte[] m_data; + private final OutputStream m_output; + private final DemuxOutputStream m_demux; + + WriterThread(final String name, + final String data, + final OutputStream output, + final DemuxOutputStream demux) { + super(name); + m_output = output; + m_demux = demux; + m_data = data.getBytes(); + } + + @Override + public void run() { + m_demux.bindStream(m_output); + for (final byte element : m_data) { + try { + //System.out.println( "Writing: " + (char)m_data[ i ] ); + m_demux.write(element); + final int sleepTime = Math.abs(c_random.nextInt() % 10); + TestUtils.sleep(sleepTime); + } catch (final Exception e) { + e.printStackTrace(); + } + } + } + } +} + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DirectoryWalkerTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DirectoryWalkerTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..df3a187868be0fe27797dd06bc0c76d1c81697bd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DirectoryWalkerTestCase.java" @@ -0,0 +1,571 @@ +/* + * 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.junit.Assert.*; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.commons.io.filefilter.FileFilterUtils; +import org.apache.commons.io.filefilter.IOFileFilter; +import org.apache.commons.io.filefilter.NameFileFilter; +import org.apache.commons.io.filefilter.OrFileFilter; +import org.junit.Assert; +import org.junit.Test; + +/** + * This is used to test DirectoryWalker for correctness. + * + * @version $Id: DirectoryWalkerTestCase.java 1686260 2015-06-18 15:57:56Z krosenvold $ + * @see DirectoryWalker + * + */ +public class DirectoryWalkerTestCase { + + // Directories + private static final File current = new File("."); + private static final File javaDir = new File("src/main/java"); + private static final File orgDir = new File(javaDir, "org"); + private static final File apacheDir = new File(orgDir, "apache"); + private static final File commonsDir = new File(apacheDir, "commons"); + private static final File ioDir = new File(commonsDir, "io"); + private static final File outputDir = new File(ioDir, "output"); + private static final File[] dirs = new File[] {orgDir, apacheDir, commonsDir, ioDir, outputDir}; + + // Files + private static final File filenameUtils = new File(ioDir, "FilenameUtils.java"); + private static final File ioUtils = new File(ioDir, "IOUtils.java"); + private static final File proxyWriter = new File(outputDir, "ProxyWriter.java"); + private static final File nullStream = new File(outputDir, "NullOutputStream.java"); + private static final File[] ioFiles = new File[] {filenameUtils, ioUtils}; + private static final File[] outputFiles = new File[] {proxyWriter, nullStream}; + + // Filters + private static final IOFileFilter dirsFilter = createNameFilter(dirs); + private static final IOFileFilter iofilesFilter = createNameFilter(ioFiles); + private static final IOFileFilter outputFilesFilter = createNameFilter(outputFiles); + private static final IOFileFilter ioDirAndFilesFilter = new OrFileFilter(dirsFilter, iofilesFilter); + private static final IOFileFilter dirsAndFilesFilter = new OrFileFilter(ioDirAndFilesFilter, outputFilesFilter); + + // Filter to exclude SVN files + private static final IOFileFilter NOT_SVN = FileFilterUtils.makeSVNAware(null); + + //----------------------------------------------------------------------- + + /** + * Test Filtering + */ + @Test + public void testFilter() { + final List results = new TestFileFinder(dirsAndFilesFilter, -1).find(javaDir); + assertEquals("Result Size", 1 + dirs.length + ioFiles.length + outputFiles.length, results.size()); + assertTrue("Start Dir", results.contains(javaDir)); + checkContainsFiles("Dir", dirs, results); + checkContainsFiles("IO File", ioFiles, results); + checkContainsFiles("Output File", outputFiles, results); + } + + /** + * Test Filtering and limit to depth 0 + */ + @Test + public void testFilterAndLimitA() { + final List results = new TestFileFinder(NOT_SVN, 0).find(javaDir); + assertEquals("[A] Result Size", 1, results.size()); + assertTrue("[A] Start Dir", results.contains(javaDir)); + } + + /** + * Test Filtering and limit to depth 1 + */ + @Test + public void testFilterAndLimitB() { + final List results = new TestFileFinder(NOT_SVN, 1).find(javaDir); + assertEquals("[B] Result Size", 2, results.size()); + assertTrue("[B] Start Dir", results.contains(javaDir)); + assertTrue("[B] Org Dir", results.contains(orgDir)); + } + + /** + * Test Filtering and limit to depth 3 + */ + @Test + public void testFilterAndLimitC() { + final List results = new TestFileFinder(NOT_SVN, 3).find(javaDir); + assertEquals("[C] Result Size", 4, results.size()); + assertTrue("[C] Start Dir", results.contains(javaDir)); + assertTrue("[C] Org Dir", results.contains(orgDir)); + assertTrue("[C] Apache Dir", results.contains(apacheDir)); + assertTrue("[C] Commons Dir", results.contains(commonsDir)); + } + + /** + * Test Filtering and limit to depth 5 + */ + @Test + public void testFilterAndLimitD() { + final List results = new TestFileFinder(dirsAndFilesFilter, 5).find(javaDir); + assertEquals("[D] Result Size", 1 + dirs.length + ioFiles.length, results.size()); + assertTrue("[D] Start Dir", results.contains(javaDir)); + checkContainsFiles("[D] Dir", dirs, results); + checkContainsFiles("[D] File", ioFiles, results); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile1() { + final List results = new TestFileFinder(dirsFilter, iofilesFilter, -1).find(javaDir); + assertEquals("[DirAndFile1] Result Size", 1 + dirs.length + ioFiles.length, results.size()); + assertTrue("[DirAndFile1] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile1] Dir", dirs, results); + checkContainsFiles("[DirAndFile1] File", ioFiles, results); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile2() { + final List results = new TestFileFinder(null, null, -1).find(javaDir); + assertTrue("[DirAndFile2] Result Size", results.size() > 1 + dirs.length + ioFiles.length); + assertTrue("[DirAndFile2] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile2] Dir", dirs, results); + checkContainsFiles("[DirAndFile2] File", ioFiles, results); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile3() { + final List results = new TestFileFinder(dirsFilter, null, -1).find(javaDir); + final List resultDirs = directoriesOnly(results); + assertEquals("[DirAndFile3] Result Size", 1 + dirs.length, resultDirs.size()); + assertTrue("[DirAndFile3] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile3] Dir", dirs, resultDirs); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile4() { + final List results = new TestFileFinder(null, iofilesFilter, -1).find(javaDir); + final List resultFiles = filesOnly(results); + assertEquals("[DirAndFile4] Result Size", ioFiles.length, resultFiles.size()); + assertTrue("[DirAndFile4] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile4] File", ioFiles, resultFiles); + } + + /** + * Test Limiting to current directory + */ + @Test + public void testLimitToCurrent() { + final List results = new TestFileFinder(null, 0).find(current); + assertEquals("Result Size", 1, results.size()); + assertTrue("Current Dir", results.contains(new File("."))); + } + + /** + * test an invalid start directory + */ + @Test + public void testMissingStartDirectory() { + + // TODO is this what we want with invalid directory? + final File invalidDir = new File("invalid-dir"); + final List results = new TestFileFinder(null, -1).find(invalidDir); + assertEquals("Result Size", 1, results.size()); + assertTrue("Current Dir", results.contains(invalidDir)); + + try { + new TestFileFinder(null, -1).find(null); + fail("Null start directory didn't throw Exception"); + } catch (final NullPointerException ignore) { + // expected result + } + } + + /** + * test an invalid start directory + */ + @Test + public void testHandleStartDirectoryFalse() { + + final List results = new TestFalseFileFinder(null, -1).find(current); + assertEquals("Result Size", 0, results.size()); + + } + + // ------------ Convenience Test Methods ------------------------------------ + + /** + * Check the files in the array are in the results list. + */ + private void checkContainsFiles(final String prefix, final File[] files, final Collection results) { + for (int i = 0; i < files.length; i++) { + assertTrue(prefix + "["+i+"] " + files[i], results.contains(files[i])); + } + } + + private void checkContainsString(final String prefix, final File[] files, final Collection results) { + for (int i = 0; i < files.length; i++) { + assertTrue(prefix + "["+i+"] " + files[i], results.contains(files[i].toString())); + } + } + + /** + * Extract the directories. + */ + private List directoriesOnly(final Collection results) { + final List list = new ArrayList(results.size()); + for (final File file : results) { + if (file.isDirectory()) { + list.add(file); + } + } + return list; + } + + /** + * Extract the files. + */ + private List filesOnly(final Collection results) { + final List list = new ArrayList(results.size()); + for (final File file : results) { + if (file.isFile()) { + list.add(file); + } + } + return list; + } + + /** + * Create an name filter containg the names of the files + * in the array. + */ + private static IOFileFilter createNameFilter(final File[] files) { + final String[] names = new String[files.length]; + for (int i = 0; i < files.length; i++) { + names[i] = files[i].getName(); + } + return new NameFileFilter(names); + } + + /** + * Test Cancel + */ + @Test + public void testCancel() { + String cancelName = null; + + // Cancel on a file + try { + cancelName = "DirectoryWalker.java"; + new TestCancelWalker(cancelName, false).find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + assertEquals("File: " + cancelName, cancelName, cancel.getFile().getName()); + assertEquals("Depth: " + cancelName, 5, cancel.getDepth()); + } catch(final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Cancel on a directory + try { + cancelName = "commons"; + new TestCancelWalker(cancelName, false).find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + assertEquals("File: " + cancelName, cancelName, cancel.getFile().getName()); + assertEquals("Depth: " + cancelName, 3, cancel.getDepth()); + } catch(final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Suppress CancelException (use same file name as preceding test) + try { + final List results = new TestCancelWalker(cancelName, true).find(javaDir); + final File lastFile = results.get(results.size() - 1); + assertEquals("Suppress: " + cancelName, cancelName, lastFile.getName()); + } catch(final IOException ex) { + fail("Suppress threw " + ex); + } + + } + + /** + * Test Cancel + */ + @Test + public void testMultiThreadCancel() { + String cancelName = "DirectoryWalker.java"; + TestMultiThreadCancelWalker walker = new TestMultiThreadCancelWalker(cancelName, false); + // Cancel on a file + try { + walker.find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + final File last = walker.results.get(walker.results.size() - 1); + assertEquals(cancelName, last.getName()); + assertEquals("Depth: " + cancelName, 5, cancel.getDepth()); + } catch(final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Cancel on a directory + try { + cancelName = "commons"; + walker = new TestMultiThreadCancelWalker(cancelName, false); + walker.find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + assertEquals("File: " + cancelName, cancelName, cancel.getFile().getName()); + assertEquals("Depth: " + cancelName, 3, cancel.getDepth()); + } catch(final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Suppress CancelException (use same file name as preceding test) + try { + walker = new TestMultiThreadCancelWalker(cancelName, true); + final List results = walker.find(javaDir); + final File lastFile = results.get(results.size() - 1); + assertEquals("Suppress: " + cancelName, cancelName, lastFile.getName()); + } catch(final IOException ex) { + fail("Suppress threw " + ex); + } + + } + + /** + * Test Filtering + */ + @Test + public void testFilterString() { + final List results = new TestFileFinderString(dirsAndFilesFilter, -1).find(javaDir); + assertEquals("Result Size", outputFiles.length + ioFiles.length, results.size()); + checkContainsString("IO File", ioFiles, results); + checkContainsString("Output File", outputFiles, results); + } + + // ------------ Test DirectoryWalker implementation -------------------------- + + /** + * Test DirectoryWalker implementation that finds files in a directory hierarchy + * applying a file filter. + */ + private static class TestFileFinder extends DirectoryWalker { + + protected TestFileFinder(final FileFilter filter, final int depthLimit) { + super(filter, depthLimit); + } + + protected TestFileFinder(final IOFileFilter dirFilter, final IOFileFilter fileFilter, final int depthLimit) { + super(dirFilter, fileFilter, depthLimit); + } + + /** find files. */ + protected List find(final File startDirectory) { + final List results = new ArrayList(); + try { + walk(startDirectory, results); + } catch(final IOException ex) { + Assert.fail(ex.toString()); + } + return results; + } + + /** Handles a directory end by adding the File to the result set. */ + @Override + protected void handleDirectoryEnd(final File directory, final int depth, final Collection results) { + results.add(directory); + } + + /** Handles a file by adding the File to the result set. */ + @Override + protected void handleFile(final File file, final int depth, final Collection results) { + results.add(file); + } + } + + // ------------ Test DirectoryWalker implementation -------------------------- + + /** + * Test DirectoryWalker implementation that always returns false + * from handleDirectoryStart() + */ + private static class TestFalseFileFinder extends TestFileFinder { + + protected TestFalseFileFinder(final FileFilter filter, final int depthLimit) { + super(filter, depthLimit); + } + + /** Always returns false. */ + @Override + protected boolean handleDirectory(final File directory, final int depth, final Collection results) { + return false; + } + } + + // ------------ Test DirectoryWalker implementation -------------------------- + + /** + * Test DirectoryWalker implementation that finds files in a directory hierarchy + * applying a file filter. + */ + static class TestCancelWalker extends DirectoryWalker { + private final String cancelFileName; + private final boolean suppressCancel; + + TestCancelWalker(final String cancelFileName,final boolean suppressCancel) { + super(); + this.cancelFileName = cancelFileName; + this.suppressCancel = suppressCancel; + } + + /** find files. */ + protected List find(final File startDirectory) throws IOException { + final List results = new ArrayList(); + walk(startDirectory, results); + return results; + } + + /** Handles a directory end by adding the File to the result set. */ + @Override + protected void handleDirectoryEnd(final File directory, final int depth, final Collection results) throws IOException { + results.add(directory); + if (cancelFileName.equals(directory.getName())) { + throw new CancelException(directory, depth); + } + } + + /** Handles a file by adding the File to the result set. */ + @Override + protected void handleFile(final File file, final int depth, final Collection results) throws IOException { + results.add(file); + if (cancelFileName.equals(file.getName())) { + throw new CancelException(file, depth); + } + } + + /** Handles Cancel. */ + @Override + protected void handleCancelled(final File startDirectory, final Collection results, + final CancelException cancel) throws IOException { + if (!suppressCancel) { + super.handleCancelled(startDirectory, results, cancel); + } + } + } + + /** + * Test DirectoryWalker implementation that finds files in a directory hierarchy + * applying a file filter. + */ + static class TestMultiThreadCancelWalker extends DirectoryWalker { + private final String cancelFileName; + private final boolean suppressCancel; + private boolean cancelled; + public List results; + + TestMultiThreadCancelWalker(final String cancelFileName, final boolean suppressCancel) { + super(); + this.cancelFileName = cancelFileName; + this.suppressCancel = suppressCancel; + } + + /** find files. */ + protected List find(final File startDirectory) throws IOException { + results = new ArrayList(); + walk(startDirectory, results); + return results; + } + + /** Handles a directory end by adding the File to the result set. */ + @Override + protected void handleDirectoryEnd(final File directory, final int depth, final Collection results) throws IOException { + results.add(directory); + assertFalse(cancelled); + if (cancelFileName.equals(directory.getName())) { + cancelled = true; + } + } + + /** Handles a file by adding the File to the result set. */ + @Override + protected void handleFile(final File file, final int depth, final Collection results) throws IOException { + results.add(file); + assertFalse(cancelled); + if (cancelFileName.equals(file.getName())) { + cancelled = true; + } + } + + /** Handles Cancelled. */ + @Override + protected boolean handleIsCancelled(final File file, final int depth, final Collection results) throws IOException { + return cancelled; + } + + /** Handles Cancel. */ + @Override + protected void handleCancelled(final File startDirectory, final Collection results, + final CancelException cancel) throws IOException { + if (!suppressCancel) { + super.handleCancelled(startDirectory, results, cancel); + } + } + } + + /** + * Test DirectoryWalker implementation that finds files in a directory hierarchy + * applying a file filter. + */ + private static class TestFileFinderString extends DirectoryWalker { + + protected TestFileFinderString(final FileFilter filter, final int depthLimit) { + super(filter, depthLimit); + } + + /** find files. */ + protected List find(final File startDirectory) { + final List results = new ArrayList(); + try { + walk(startDirectory, results); + } catch(final IOException ex) { + Assert.fail(ex.toString()); + } + return results; + } + + /** Handles a file by adding the File to the result set. */ + @Override + protected void handleFile(final File file, final int depth, final Collection results) { + results.add(file.toString()); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java" new file mode 100644 index 0000000000000000000000000000000000000000..b633f5a2dbe09a00b8bf8a55134bca726fb3972c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/DirectoryWalkerTestCaseJava4.java" @@ -0,0 +1,554 @@ +/* + * 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 org.apache.commons.io.filefilter.FileFilterUtils; +import org.apache.commons.io.filefilter.IOFileFilter; +import org.apache.commons.io.filefilter.NameFileFilter; +import org.apache.commons.io.filefilter.OrFileFilter; +import org.junit.Test; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This is used to test DirectoryWalker for correctness when using Java4 (i.e. no generics). + * + * @version $Id: DirectoryWalkerTestCaseJava4.java 1718944 2015-12-09 19:50:30Z krosenvold $ + * @see DirectoryWalker + */ +@SuppressWarnings({"unchecked", "rawtypes"}) // Java4 +public class DirectoryWalkerTestCaseJava4 { + + // Directories + private static final File current = new File("."); + private static final File javaDir = new File("src/main/java"); + private static final File orgDir = new File(javaDir, "org"); + private static final File apacheDir = new File(orgDir, "apache"); + private static final File commonsDir = new File(apacheDir, "commons"); + private static final File ioDir = new File(commonsDir, "io"); + private static final File outputDir = new File(ioDir, "output"); + private static final File[] dirs = new File[]{orgDir, apacheDir, commonsDir, ioDir, outputDir}; + + // Files + private static final File filenameUtils = new File(ioDir, "FilenameUtils.java"); + private static final File ioUtils = new File(ioDir, "IOUtils.java"); + private static final File proxyWriter = new File(outputDir, "ProxyWriter.java"); + private static final File nullStream = new File(outputDir, "NullOutputStream.java"); + private static final File[] ioFiles = new File[]{filenameUtils, ioUtils}; + private static final File[] outputFiles = new File[]{proxyWriter, nullStream}; + + // Filters + private static final IOFileFilter dirsFilter = createNameFilter(dirs); + private static final IOFileFilter iofilesFilter = createNameFilter(ioFiles); + private static final IOFileFilter outputFilesFilter = createNameFilter(outputFiles); + private static final IOFileFilter ioDirAndFilesFilter = new OrFileFilter(dirsFilter, iofilesFilter); + private static final IOFileFilter dirsAndFilesFilter = new OrFileFilter(ioDirAndFilesFilter, outputFilesFilter); + + // Filter to exclude SVN files + private static final IOFileFilter NOT_SVN = FileFilterUtils.makeSVNAware(null); + + //----------------------------------------------------------------------- + + /** + * Test Filtering + */ + @Test + public void testFilter() { + final List results = new TestFileFinder(dirsAndFilesFilter, -1).find(javaDir); + assertEquals("Result Size", 1 + dirs.length + ioFiles.length + outputFiles.length, results.size()); + assertTrue("Start Dir", results.contains(javaDir)); + checkContainsFiles("Dir", dirs, results); + checkContainsFiles("IO File", ioFiles, results); + checkContainsFiles("Output File", outputFiles, results); + } + + /** + * Test Filtering and limit to depth 0 + */ + @Test + public void testFilterAndLimitA() { + final List results = new TestFileFinder(NOT_SVN, 0).find(javaDir); + assertEquals("[A] Result Size", 1, results.size()); + assertTrue("[A] Start Dir", results.contains(javaDir)); + } + + /** + * Test Filtering and limit to depth 1 + */ + @Test + public void testFilterAndLimitB() { + final List results = new TestFileFinder(NOT_SVN, 1).find(javaDir); + assertEquals("[B] Result Size", 2, results.size()); + assertTrue("[B] Start Dir", results.contains(javaDir)); + assertTrue("[B] Org Dir", results.contains(orgDir)); + } + + /** + * Test Filtering and limit to depth 3 + */ + @Test + public void testFilterAndLimitC() { + final List results = new TestFileFinder(NOT_SVN, 3).find(javaDir); + assertEquals("[C] Result Size", 4, results.size()); + assertTrue("[C] Start Dir", results.contains(javaDir)); + assertTrue("[C] Org Dir", results.contains(orgDir)); + assertTrue("[C] Apache Dir", results.contains(apacheDir)); + assertTrue("[C] Commons Dir", results.contains(commonsDir)); + } + + /** + * Test Filtering and limit to depth 5 + */ + @Test + public void testFilterAndLimitD() { + final List results = new TestFileFinder(dirsAndFilesFilter, 5).find(javaDir); + assertEquals("[D] Result Size", 1 + dirs.length + ioFiles.length, results.size()); + assertTrue("[D] Start Dir", results.contains(javaDir)); + checkContainsFiles("[D] Dir", dirs, results); + checkContainsFiles("[D] File", ioFiles, results); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile1() { + final List results = new TestFileFinder(dirsFilter, iofilesFilter, -1).find(javaDir); + assertEquals("[DirAndFile1] Result Size", 1 + dirs.length + ioFiles.length, results.size()); + assertTrue("[DirAndFile1] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile1] Dir", dirs, results); + checkContainsFiles("[DirAndFile1] File", ioFiles, results); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile2() { + final List results = new TestFileFinder(null, null, -1).find(javaDir); + assertTrue("[DirAndFile2] Result Size", results.size() > 1 + dirs.length + ioFiles.length); + assertTrue("[DirAndFile2] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile2] Dir", dirs, results); + checkContainsFiles("[DirAndFile2] File", ioFiles, results); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile3() { + final List results = new TestFileFinder(dirsFilter, null, -1).find(javaDir); + final List resultDirs = directoriesOnly(results); + assertEquals("[DirAndFile3] Result Size", 1 + dirs.length, resultDirs.size()); + assertTrue("[DirAndFile3] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile3] Dir", dirs, resultDirs); + } + + /** + * Test separate dir and file filters + */ + @Test + public void testFilterDirAndFile4() { + final List results = new TestFileFinder(null, iofilesFilter, -1).find(javaDir); + final List resultFiles = filesOnly(results); + assertEquals("[DirAndFile4] Result Size", ioFiles.length, resultFiles.size()); + assertTrue("[DirAndFile4] Start Dir", results.contains(javaDir)); + checkContainsFiles("[DirAndFile4] File", ioFiles, resultFiles); + } + + /** + * Test Limiting to current directory + */ + @Test + public void testLimitToCurrent() { + final List results = new TestFileFinder(null, 0).find(current); + assertEquals("Result Size", 1, results.size()); + assertTrue("Current Dir", results.contains(new File("."))); + } + + /** + * test an invalid start directory + */ + @Test + public void testMissingStartDirectory() { + + // TODO is this what we want with invalid directory? + final File invalidDir = new File("invalid-dir"); + final List results = new TestFileFinder(null, -1).find(invalidDir); + assertEquals("Result Size", 1, results.size()); + assertTrue("Current Dir", results.contains(invalidDir)); + + try { + new TestFileFinder(null, -1).find(null); + fail("Null start directory didn't throw Exception"); + } catch (final NullPointerException ignore) { + // expected result + } + } + + /** + * test an invalid start directory + */ + @Test + public void testHandleStartDirectoryFalse() { + + final List results = new TestFalseFileFinder(null, -1).find(current); + assertEquals("Result Size", 0, results.size()); + + } + + // ------------ Convenience Test Methods ------------------------------------ + + /** + * Check the files in the array are in the results list. + */ + private void checkContainsFiles(final String prefix, final File[] files, final Collection results) { + for (int i = 0; i < files.length; i++) { + assertTrue(prefix + "[" + i + "] " + files[i], results.contains(files[i])); + } + } + + /** + * Extract the directories. + */ + private List directoriesOnly(final Collection results) { + final List list = new ArrayList(results.size()); + for (File file : results) { + if (file.isDirectory()) { + list.add(file); + } + } + return list; + } + + /** + * Extract the files. + */ + private List filesOnly(final Collection results) { + final List list = new ArrayList(results.size()); + for (File file : results) { + if (file.isFile()) { + list.add(file); + } + } + return list; + } + + /** + * Create an name filter containg the names of the files + * in the array. + */ + private static IOFileFilter createNameFilter(final File[] files) { + final String[] names = new String[files.length]; + for (int i = 0; i < files.length; i++) { + names[i] = files[i].getName(); + } + return new NameFileFilter(names); + } + + /** + * Test Cancel + */ + @Test + public void testCancel() { + String cancelName = null; + + // Cancel on a file + try { + cancelName = "DirectoryWalker.java"; + new TestCancelWalker(cancelName, false).find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + assertEquals("File: " + cancelName, cancelName, cancel.getFile().getName()); + assertEquals("Depth: " + cancelName, 5, cancel.getDepth()); + } catch (final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Cancel on a directory + try { + cancelName = "commons"; + new TestCancelWalker(cancelName, false).find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + assertEquals("File: " + cancelName, cancelName, cancel.getFile().getName()); + assertEquals("Depth: " + cancelName, 3, cancel.getDepth()); + } catch (final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Suppress CancelException (use same file name as preceding test) + try { + final List results = new TestCancelWalker(cancelName, true).find(javaDir); + final File lastFile = (File) results.get(results.size() - 1); + assertEquals("Suppress: " + cancelName, cancelName, lastFile.getName()); + } catch (final IOException ex) { + fail("Suppress threw " + ex); + } + + } + + /** + * Test Cancel + */ + @Test + public void testMultiThreadCancel() { + String cancelName = "DirectoryWalker.java"; + TestMultiThreadCancelWalker walker = new TestMultiThreadCancelWalker(cancelName, false); + // Cancel on a file + try { + walker.find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + final File last = (File) walker.results.get(walker.results.size() - 1); + assertEquals(cancelName, last.getName()); + assertEquals("Depth: " + cancelName, 5, cancel.getDepth()); + } catch (final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Cancel on a directory + try { + cancelName = "commons"; + walker = new TestMultiThreadCancelWalker(cancelName, false); + walker.find(javaDir); + fail("CancelException not thrown for '" + cancelName + "'"); + } catch (final DirectoryWalker.CancelException cancel) { + assertEquals("File: " + cancelName, cancelName, cancel.getFile().getName()); + assertEquals("Depth: " + cancelName, 3, cancel.getDepth()); + } catch (final IOException ex) { + fail("IOException: " + cancelName + " " + ex); + } + + // Suppress CancelException (use same file name as preceding test) + try { + walker = new TestMultiThreadCancelWalker(cancelName, true); + final List results = walker.find(javaDir); + final File lastFile = (File) results.get(results.size() - 1); + assertEquals("Suppress: " + cancelName, cancelName, lastFile.getName()); + } catch (final IOException ex) { + fail("Suppress threw " + ex); + } + + } + + // ------------ Test DirectoryWalker implementation -------------------------- + + /** + * Test DirectoryWalker implementation that finds files in a directory hierarchy + * applying a file filter. + */ + private static class TestFileFinder extends DirectoryWalker { + + protected TestFileFinder(final FileFilter filter, final int depthLimit) { + super(filter, depthLimit); + } + + protected TestFileFinder(final IOFileFilter dirFilter, final IOFileFilter fileFilter, final int depthLimit) { + super(dirFilter, fileFilter, depthLimit); + } + + /** + * find files. + */ + protected List find(final File startDirectory) { + final List results = new ArrayList(); + try { + walk(startDirectory, results); + } catch (final IOException ex) { + fail(ex.toString()); + } + return results; + } + + /** + * Handles a directory end by adding the File to the result set. + */ + @Override + protected void handleDirectoryEnd(final File directory, final int depth, final Collection results) { + results.add(directory); + } + + /** + * Handles a file by adding the File to the result set. + */ + @Override + protected void handleFile(final File file, final int depth, final Collection results) { + results.add(file); + } + } + + // ------------ Test DirectoryWalker implementation -------------------------- + + /** + * Test DirectoryWalker implementation that always returns false + * from handleDirectoryStart() + */ + private static class TestFalseFileFinder extends TestFileFinder { + + protected TestFalseFileFinder(final FileFilter filter, final int depthLimit) { + super(filter, depthLimit); + } + + /** + * Always returns false. + */ + @Override + protected boolean handleDirectory(final File directory, final int depth, final Collection results) { + return false; + } + } + + // ------------ Test DirectoryWalker implementation -------------------------- + + /** + * Test DirectoryWalker implementation that finds files in a directory hierarchy + * applying a file filter. + */ + static class TestCancelWalker extends DirectoryWalker { + private final String cancelFileName; + private final boolean suppressCancel; + + TestCancelWalker(final String cancelFileName, final boolean suppressCancel) { + super(); + this.cancelFileName = cancelFileName; + this.suppressCancel = suppressCancel; + } + + /** + * find files. + */ + protected List find(final File startDirectory) throws IOException { + final List results = new ArrayList(); + walk(startDirectory, results); + return results; + } + + /** + * Handles a directory end by adding the File to the result set. + */ + @Override + protected void handleDirectoryEnd(final File directory, final int depth, final Collection results) throws IOException { + results.add(directory); + if (cancelFileName.equals(directory.getName())) { + throw new CancelException(directory, depth); + } + } + + /** + * Handles a file by adding the File to the result set. + */ + @Override + protected void handleFile(final File file, final int depth, final Collection results) throws IOException { + results.add(file); + if (cancelFileName.equals(file.getName())) { + throw new CancelException(file, depth); + } + } + + /** + * Handles Cancel. + */ + @Override + protected void handleCancelled(final File startDirectory, final Collection results, + final CancelException cancel) throws IOException { + if (!suppressCancel) { + super.handleCancelled(startDirectory, results, cancel); + } + } + } + + /** + * Test DirectoryWalker implementation that finds files in a directory hierarchy + * applying a file filter. + */ + static class TestMultiThreadCancelWalker extends DirectoryWalker { + private final String cancelFileName; + private final boolean suppressCancel; + private boolean cancelled; + public List results; + + TestMultiThreadCancelWalker(final String cancelFileName, final boolean suppressCancel) { + super(); + this.cancelFileName = cancelFileName; + this.suppressCancel = suppressCancel; + } + + /** + * find files. + */ + protected List find(final File startDirectory) throws IOException { + results = new ArrayList(); + walk(startDirectory, results); + return results; + } + + /** + * Handles a directory end by adding the File to the result set. + */ + @Override + protected void handleDirectoryEnd(final File directory, final int depth, final Collection results) throws IOException { + results.add(directory); + assertFalse(cancelled); + if (cancelFileName.equals(directory.getName())) { + cancelled = true; + } + } + + /** + * Handles a file by adding the File to the result set. + */ + @Override + protected void handleFile(final File file, final int depth, final Collection results) throws IOException { + results.add(file); + assertFalse(cancelled); + if (cancelFileName.equals(file.getName())) { + cancelled = true; + } + } + + /** + * Handles Cancelled. + */ + @Override + protected boolean handleIsCancelled(final File file, final int depth, final Collection results) throws IOException { + return cancelled; + } + + /** + * Handles Cancel. + */ + @Override + protected void handleCancelled(final File startDirectory, final Collection results, + final CancelException cancel) throws IOException { + if (!suppressCancel) { + super.handleCancelled(startDirectory, results, cancel); + } + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/EndianUtilsTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/EndianUtilsTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..0c884a57927fc7e36c12bb2e976eb684c7d3f3b5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/EndianUtilsTest.java" @@ -0,0 +1,316 @@ +/* + * 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 org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.EOFException; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * @version $Id: EndianUtilsTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class EndianUtilsTest { + + @Test + public void testCtor() { + new EndianUtils(); + // Constructor does not blow up. + } + + @Test + public void testEOFException() throws IOException { + final ByteArrayInputStream input = new ByteArrayInputStream(new byte[] {}); + try { + EndianUtils.readSwappedDouble(input); + fail("Expected EOFException"); + } catch (final EOFException e) { + // expected + } + } + + @Test + public void testSwapShort() { + assertEquals( (short) 0, EndianUtils.swapShort( (short) 0 ) ); + assertEquals( (short) 0x0201, EndianUtils.swapShort( (short) 0x0102 ) ); + assertEquals( (short) 0xffff, EndianUtils.swapShort( (short) 0xffff ) ); + assertEquals( (short) 0x0102, EndianUtils.swapShort( (short) 0x0201 ) ); + } + + @Test + public void testSwapInteger() { + assertEquals( 0, EndianUtils.swapInteger( 0 ) ); + assertEquals( 0x04030201, EndianUtils.swapInteger( 0x01020304 ) ); + assertEquals( 0x01000000, EndianUtils.swapInteger( 0x00000001 ) ); + assertEquals( 0x00000001, EndianUtils.swapInteger( 0x01000000 ) ); + assertEquals( 0x11111111, EndianUtils.swapInteger( 0x11111111 ) ); + assertEquals( 0xabcdef10, EndianUtils.swapInteger( 0x10efcdab ) ); + assertEquals( 0xab, EndianUtils.swapInteger( 0xab000000 ) ); + } + + @Test + public void testSwapLong() { + assertEquals( 0, EndianUtils.swapLong( 0 ) ); + assertEquals( 0x0807060504030201L, EndianUtils.swapLong( 0x0102030405060708L ) ); + assertEquals( 0xffffffffffffffffL, EndianUtils.swapLong( 0xffffffffffffffffL ) ); + assertEquals( 0xab, EndianUtils.swapLong( 0xab00000000000000L ) ); + } + + @Test + public void testSwapFloat() { + assertEquals( 0.0f, EndianUtils.swapFloat( 0.0f ), 0.0 ); + final float f1 = Float.intBitsToFloat( 0x01020304 ); + final float f2 = Float.intBitsToFloat( 0x04030201 ); + assertEquals( f2, EndianUtils.swapFloat( f1 ), 0.0 ); + } + + @Test + public void testSwapDouble() { + assertEquals( 0.0, EndianUtils.swapDouble( 0.0 ), 0.0 ); + final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); + final double d2 = Double.longBitsToDouble( 0x0807060504030201L ); + assertEquals( d2, EndianUtils.swapDouble( d1 ), 0.0 ); + } + + /** + * Tests all swapXxxx methods for symmetry when going from one endian + * to another and back again. + */ + @Test + public void testSymmetry() { + assertEquals( (short) 0x0102, EndianUtils.swapShort( EndianUtils.swapShort( (short) 0x0102 ) ) ); + assertEquals( 0x01020304, EndianUtils.swapInteger( EndianUtils.swapInteger( 0x01020304 ) ) ); + assertEquals( 0x0102030405060708L, EndianUtils.swapLong( EndianUtils.swapLong( 0x0102030405060708L ) ) ); + final float f1 = Float.intBitsToFloat( 0x01020304 ); + assertEquals( f1, EndianUtils.swapFloat( EndianUtils.swapFloat( f1 ) ), 0.0 ); + final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); + assertEquals( d1, EndianUtils.swapDouble( EndianUtils.swapDouble( d1 ) ), 0.0 ); + } + + @Test + public void testReadSwappedShort() throws IOException { + final byte[] bytes = new byte[] { 0x02, 0x01 }; + assertEquals( 0x0102, EndianUtils.readSwappedShort( bytes, 0 ) ); + + final ByteArrayInputStream input = new ByteArrayInputStream(bytes); + assertEquals( 0x0102, EndianUtils.readSwappedShort( input ) ); + } + + @Test + public void testWriteSwappedShort() throws IOException { + byte[] bytes = new byte[2]; + EndianUtils.writeSwappedShort( bytes, 0, (short) 0x0102 ); + assertEquals( 0x02, bytes[0] ); + assertEquals( 0x01, bytes[1] ); + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(2); + EndianUtils.writeSwappedShort( baos, (short) 0x0102 ); + bytes = baos.toByteArray(); + assertEquals( 0x02, bytes[0] ); + assertEquals( 0x01, bytes[1] ); + } + + @Test + public void testReadSwappedUnsignedShort() throws IOException { + final byte[] bytes = new byte[] { 0x02, 0x01 }; + assertEquals( 0x00000102, EndianUtils.readSwappedUnsignedShort( bytes, 0 ) ); + + final ByteArrayInputStream input = new ByteArrayInputStream(bytes); + assertEquals( 0x00000102, EndianUtils.readSwappedUnsignedShort( input ) ); + } + + @Test + public void testReadSwappedInteger() throws IOException { + final byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 }; + assertEquals( 0x01020304, EndianUtils.readSwappedInteger( bytes, 0 ) ); + + final ByteArrayInputStream input = new ByteArrayInputStream(bytes); + assertEquals( 0x01020304, EndianUtils.readSwappedInteger( input ) ); + } + + @Test + public void testWriteSwappedInteger() throws IOException { + byte[] bytes = new byte[4]; + EndianUtils.writeSwappedInteger( bytes, 0, 0x01020304 ); + assertEquals( 0x04, bytes[0] ); + assertEquals( 0x03, bytes[1] ); + assertEquals( 0x02, bytes[2] ); + assertEquals( 0x01, bytes[3] ); + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(4); + EndianUtils.writeSwappedInteger( baos, 0x01020304 ); + bytes = baos.toByteArray(); + assertEquals( 0x04, bytes[0] ); + assertEquals( 0x03, bytes[1] ); + assertEquals( 0x02, bytes[2] ); + assertEquals( 0x01, bytes[3] ); + } + + @Test + public void testReadSwappedUnsignedInteger() throws IOException { + final byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 }; + assertEquals( 0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger( bytes, 0 ) ); + + final ByteArrayInputStream input = new ByteArrayInputStream(bytes); + assertEquals( 0x0000000001020304L, EndianUtils.readSwappedUnsignedInteger( input ) ); + } + + @Test + public void testReadSwappedLong() throws IOException { + final byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; + assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( bytes, 0 ) ); + + final ByteArrayInputStream input = new ByteArrayInputStream(bytes); + assertEquals( 0x0102030405060708L, EndianUtils.readSwappedLong( input ) ); + } + + @Test + public void testWriteSwappedLong() throws IOException { + byte[] bytes = new byte[8]; + EndianUtils.writeSwappedLong( bytes, 0, 0x0102030405060708L ); + assertEquals( 0x08, bytes[0] ); + assertEquals( 0x07, bytes[1] ); + assertEquals( 0x06, bytes[2] ); + assertEquals( 0x05, bytes[3] ); + assertEquals( 0x04, bytes[4] ); + assertEquals( 0x03, bytes[5] ); + assertEquals( 0x02, bytes[6] ); + assertEquals( 0x01, bytes[7] ); + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(8); + EndianUtils.writeSwappedLong( baos, 0x0102030405060708L ); + bytes = baos.toByteArray(); + assertEquals( 0x08, bytes[0] ); + assertEquals( 0x07, bytes[1] ); + assertEquals( 0x06, bytes[2] ); + assertEquals( 0x05, bytes[3] ); + assertEquals( 0x04, bytes[4] ); + assertEquals( 0x03, bytes[5] ); + assertEquals( 0x02, bytes[6] ); + assertEquals( 0x01, bytes[7] ); + } + + @Test + public void testReadSwappedFloat() throws IOException { + final byte[] bytes = new byte[] { 0x04, 0x03, 0x02, 0x01 }; + final float f1 = Float.intBitsToFloat( 0x01020304 ); + final float f2 = EndianUtils.readSwappedFloat( bytes, 0 ); + assertEquals( f1, f2, 0.0 ); + + final ByteArrayInputStream input = new ByteArrayInputStream(bytes); + assertEquals( f1, EndianUtils.readSwappedFloat( input ), 0.0 ); + } + + @Test + public void testWriteSwappedFloat() throws IOException { + byte[] bytes = new byte[4]; + final float f1 = Float.intBitsToFloat( 0x01020304 ); + EndianUtils.writeSwappedFloat( bytes, 0, f1 ); + assertEquals( 0x04, bytes[0] ); + assertEquals( 0x03, bytes[1] ); + assertEquals( 0x02, bytes[2] ); + assertEquals( 0x01, bytes[3] ); + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(4); + EndianUtils.writeSwappedFloat( baos, f1 ); + bytes = baos.toByteArray(); + assertEquals( 0x04, bytes[0] ); + assertEquals( 0x03, bytes[1] ); + assertEquals( 0x02, bytes[2] ); + assertEquals( 0x01, bytes[3] ); + } + + @Test + public void testReadSwappedDouble() throws IOException { + final byte[] bytes = new byte[] { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01 }; + final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); + final double d2 = EndianUtils.readSwappedDouble( bytes, 0 ); + assertEquals( d1, d2, 0.0 ); + + final ByteArrayInputStream input = new ByteArrayInputStream(bytes); + assertEquals( d1, EndianUtils.readSwappedDouble( input ), 0.0 ); + } + + @Test + public void testWriteSwappedDouble() throws IOException { + byte[] bytes = new byte[8]; + final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); + EndianUtils.writeSwappedDouble( bytes, 0, d1 ); + assertEquals( 0x08, bytes[0] ); + assertEquals( 0x07, bytes[1] ); + assertEquals( 0x06, bytes[2] ); + assertEquals( 0x05, bytes[3] ); + assertEquals( 0x04, bytes[4] ); + assertEquals( 0x03, bytes[5] ); + assertEquals( 0x02, bytes[6] ); + assertEquals( 0x01, bytes[7] ); + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(8); + EndianUtils.writeSwappedDouble( baos, d1 ); + bytes = baos.toByteArray(); + assertEquals( 0x08, bytes[0] ); + assertEquals( 0x07, bytes[1] ); + assertEquals( 0x06, bytes[2] ); + assertEquals( 0x05, bytes[3] ); + assertEquals( 0x04, bytes[4] ); + assertEquals( 0x03, bytes[5] ); + assertEquals( 0x02, bytes[6] ); + assertEquals( 0x01, bytes[7] ); + } + + // tests #IO-101 + @Test + public void testSymmetryOfLong() { + + final double[] tests = new double[] {34.345, -345.5645, 545.12, 10.043, 7.123456789123}; + for (final double test : tests) { + + // testing the real problem + byte[] buffer = new byte[8]; + final long ln1 = Double.doubleToLongBits( test ); + EndianUtils.writeSwappedLong(buffer, 0, ln1); + final long ln2 = EndianUtils.readSwappedLong(buffer, 0); + assertEquals( ln1, ln2 ); + + // testing the bug report + buffer = new byte[8]; + EndianUtils.writeSwappedDouble(buffer, 0, test); + final double val = EndianUtils.readSwappedDouble(buffer, 0); + assertEquals( test, val, 0 ); + } + } + + // tests #IO-117 + @Test + public void testUnsignedOverrun() throws Exception { + final byte[] target = new byte[] { 0, 0, 0, (byte)0x80 }; + final long expected = 0x80000000L; + + long actual = EndianUtils.readSwappedUnsignedInteger(target, 0); + assertEquals("readSwappedUnsignedInteger(byte[], int) was incorrect", expected, actual); + + final ByteArrayInputStream in = new ByteArrayInputStream(target); + actual = EndianUtils.readSwappedUnsignedInteger(in); + assertEquals("readSwappedUnsignedInteger(InputStream) was incorrect", expected, actual); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileCleanerTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileCleanerTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..b809eaead4ea0049f9df851a03d7ba1bd60dbd6d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileCleanerTestCase.java" @@ -0,0 +1,32 @@ +/* + * 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; + +@SuppressWarnings("deprecation") // testing deprecated class +/** + * This is used to test FileCleaner for correctness. + * + * @version $Id: FileCleanerTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + + * @see FileCleaner + */ +public class FileCleanerTestCase extends FileCleaningTrackerTestCase { + @Override + protected FileCleaningTracker newInstance() { + return FileCleaner.getInstance(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..4fa71c80188108c320ca39b74b1a3e219a216ef1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileCleaningTrackerTestCase.java" @@ -0,0 +1,346 @@ +/* + * 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 org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.*; +import java.lang.ref.ReferenceQueue; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This is used to test {@link FileCleaningTracker} for correctness. + * + * @version $Id: FileCleaningTrackerTestCase.java 1718945 2015-12-09 19:51:14Z krosenvold $ + * @see FileCleaningTracker + */ +public class FileCleaningTrackerTestCase extends FileBasedTestCase { + protected FileCleaningTracker newInstance() { + return new FileCleaningTracker(); + } + + private File testFile; + private FileCleaningTracker theInstance; + + public FileCleaningTrackerTestCase() { + testFile = new File(getTestDirectory(), "file-test.txt"); + } + + @Before + public void setUp() throws Exception { + theInstance = newInstance(); + getTestDirectory(); + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(getTestDirectory()); + + // reset file cleaner class, so as not to break other tests + + /** + * The following block of code can possibly be removed when the + * deprecated {@link FileCleaner} is gone. The question is, whether + * we want to support reuse of {@link FileCleaningTracker} instances, + * which we should, IMO, not. + */ + { + theInstance.q = new ReferenceQueue(); + theInstance.trackers.clear(); + theInstance.deleteFailures.clear(); + theInstance.exitWhenFinished = false; + theInstance.reaper = null; + } + + theInstance = null; + } + + //----------------------------------------------------------------------- + @Test + public void testFileCleanerFile() throws Exception { + final String path = testFile.getPath(); + + assertFalse(testFile.exists()); + RandomAccessFile r = new RandomAccessFile(testFile, "rw"); + assertTrue(testFile.exists()); + + assertEquals(0, theInstance.getTrackCount()); + theInstance.track(path, r); + assertEquals(1, theInstance.getTrackCount()); + + r.close(); + testFile = null; + r = null; + + waitUntilTrackCount(); + pauseForDeleteToComplete(new File(path)); + + assertEquals(0, theInstance.getTrackCount()); + assertEquals(showFailures(), false, new File(path).exists()); + } + + @Test + public void testFileCleanerDirectory() throws Exception { + TestUtils.createFile(testFile, 100); + assertTrue(testFile.exists()); + assertTrue(getTestDirectory().exists()); + + Object obj = new Object(); + assertEquals(0, theInstance.getTrackCount()); + theInstance.track(getTestDirectory(), obj); + assertEquals(1, theInstance.getTrackCount()); + + obj = null; + + waitUntilTrackCount(); + + assertEquals(0, theInstance.getTrackCount()); + assertTrue(testFile.exists()); // not deleted, as dir not empty + assertTrue(testFile.getParentFile().exists()); // not deleted, as dir not empty + } + + @Test + public void testFileCleanerDirectory_NullStrategy() throws Exception { + TestUtils.createFile(testFile, 100); + assertTrue(testFile.exists()); + assertTrue(getTestDirectory().exists()); + + Object obj = new Object(); + assertEquals(0, theInstance.getTrackCount()); + theInstance.track(getTestDirectory(), obj, null); + assertEquals(1, theInstance.getTrackCount()); + + obj = null; + + waitUntilTrackCount(); + + assertEquals(0, theInstance.getTrackCount()); + assertTrue(testFile.exists()); // not deleted, as dir not empty + assertTrue(testFile.getParentFile().exists()); // not deleted, as dir not empty + } + + @Test + public void testFileCleanerDirectory_ForceStrategy() throws Exception { + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 100); + } finally { + IOUtils.closeQuietly(output); + } + assertTrue(testFile.exists()); + assertTrue(getTestDirectory().exists()); + + Object obj = new Object(); + assertEquals(0, theInstance.getTrackCount()); + theInstance.track(getTestDirectory(), obj, FileDeleteStrategy.FORCE); + assertEquals(1, theInstance.getTrackCount()); + + obj = null; + + waitUntilTrackCount(); + pauseForDeleteToComplete(testFile.getParentFile()); + + assertEquals(0, theInstance.getTrackCount()); + assertEquals(showFailures(), false, new File(testFile.getPath()).exists()); + assertEquals(showFailures(), false, testFile.getParentFile().exists()); + } + + @Test + public void testFileCleanerNull() throws Exception { + try { + theInstance.track((File) null, new Object()); + fail(); + } catch (final NullPointerException ex) { + // expected + } + try { + theInstance.track((File) null, new Object(), FileDeleteStrategy.NORMAL); + fail(); + } catch (final NullPointerException ex) { + // expected + } + try { + theInstance.track((String) null, new Object()); + fail(); + } catch (final NullPointerException ex) { + // expected + } + try { + theInstance.track((String) null, new Object(), FileDeleteStrategy.NORMAL); + fail(); + } catch (final NullPointerException ex) { + // expected + } + } + + @Test + public void testFileCleanerExitWhenFinishedFirst() throws Exception { + assertFalse(theInstance.exitWhenFinished); + theInstance.exitWhenFinished(); + assertTrue(theInstance.exitWhenFinished); + assertEquals(null, theInstance.reaper); + + waitUntilTrackCount(); + + assertEquals(0, theInstance.getTrackCount()); + assertTrue(theInstance.exitWhenFinished); + assertEquals(null, theInstance.reaper); + } + + @Test + public void testFileCleanerExitWhenFinished_NoTrackAfter() throws Exception { + assertFalse(theInstance.exitWhenFinished); + theInstance.exitWhenFinished(); + assertTrue(theInstance.exitWhenFinished); + assertEquals(null, theInstance.reaper); + + final String path = testFile.getPath(); + final Object marker = new Object(); + try { + theInstance.track(path, marker); + fail(); + } catch (final IllegalStateException ex) { + // expected + } + assertTrue(theInstance.exitWhenFinished); + assertEquals(null, theInstance.reaper); + } + + @Test + public void testFileCleanerExitWhenFinished1() throws Exception { + final String path = testFile.getPath(); + + assertEquals("1-testFile exists", false, testFile.exists()); + RandomAccessFile r = new RandomAccessFile(testFile, "rw"); + assertEquals("2-testFile exists", true, testFile.exists()); + + assertEquals("3-Track Count", 0, theInstance.getTrackCount()); + theInstance.track(path, r); + assertEquals("4-Track Count", 1, theInstance.getTrackCount()); + assertEquals("5-exitWhenFinished", false, theInstance.exitWhenFinished); + assertEquals("6-reaper.isAlive", true, theInstance.reaper.isAlive()); + + assertEquals("7-exitWhenFinished", false, theInstance.exitWhenFinished); + theInstance.exitWhenFinished(); + assertEquals("8-exitWhenFinished", true, theInstance.exitWhenFinished); + assertEquals("9-reaper.isAlive", true, theInstance.reaper.isAlive()); + + r.close(); + testFile = null; + r = null; + + waitUntilTrackCount(); + pauseForDeleteToComplete(new File(path)); + + assertEquals("10-Track Count", 0, theInstance.getTrackCount()); + assertEquals("11-testFile exists " + showFailures(), false, new File(path).exists()); + assertEquals("12-exitWhenFinished", true, theInstance.exitWhenFinished); + assertEquals("13-reaper.isAlive", false, theInstance.reaper.isAlive()); + } + + @Test + public void testFileCleanerExitWhenFinished2() throws Exception { + final String path = testFile.getPath(); + + assertFalse(testFile.exists()); + RandomAccessFile r = new RandomAccessFile(testFile, "rw"); + assertTrue(testFile.exists()); + + assertEquals(0, theInstance.getTrackCount()); + theInstance.track(path, r); + assertEquals(1, theInstance.getTrackCount()); + assertFalse(theInstance.exitWhenFinished); + assertTrue(theInstance.reaper.isAlive()); + + r.close(); + testFile = null; + r = null; + + waitUntilTrackCount(); + pauseForDeleteToComplete(new File(path)); + + assertEquals(0, theInstance.getTrackCount()); + assertEquals(showFailures(), false, new File(path).exists()); + assertFalse(theInstance.exitWhenFinished); + assertTrue(theInstance.reaper.isAlive()); + + assertFalse(theInstance.exitWhenFinished); + theInstance.exitWhenFinished(); + for (int i = 0; i < 20 && theInstance.reaper.isAlive(); i++) { + TestUtils.sleep(500L); // allow reaper thread to die + } + assertTrue(theInstance.exitWhenFinished); + assertFalse(theInstance.reaper.isAlive()); + } + + //----------------------------------------------------------------------- + private void pauseForDeleteToComplete(File file) { + int count = 0; + while(file.exists() && count++ < 40) { + try { + TestUtils.sleep(500L); + } catch (final InterruptedException ignore) { + } + file = new File(file.getPath()); + } + } + private String showFailures() throws Exception { + if (theInstance.deleteFailures.size() == 1) { + return "[Delete Failed: " + theInstance.deleteFailures.get(0) + "]"; + } else { + return "[Delete Failures: " + theInstance.deleteFailures.size() + "]"; + } + } + + private void waitUntilTrackCount() throws Exception { + System.gc(); + TestUtils.sleep(500); + int count = 0; + while(theInstance.getTrackCount() != 0 && count++ < 5) { + List list = new ArrayList(); + try { + long i = 0; + while (theInstance.getTrackCount() != 0) { + list.add("A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String A Big String " + (i++)); + } + } catch (final Throwable ignored) { + } + list = null; + System.gc(); + TestUtils.sleep(1000); + } + if (theInstance.getTrackCount() != 0) { + throw new IllegalStateException("Your JVM is not releasing References, try running the testcase with less memory (-Xmx)"); + } + + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileDeleteStrategyTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileDeleteStrategyTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..f92d6c57cb40f2216f2c9092f2ac82f95b354db7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileDeleteStrategyTestCase.java" @@ -0,0 +1,165 @@ +/* + * 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 org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.Test; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Test for FileDeleteStrategy. + * + * @version $Id: FileDeleteStrategyTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + * @see FileDeleteStrategy + */ +public class FileDeleteStrategyTestCase extends FileBasedTestCase { + + //----------------------------------------------------------------------- + @Test + public void testDeleteNormal() throws Exception { + final File baseDir = getTestDirectory(); + final File subDir = new File(baseDir, "test"); + assertTrue(subDir.mkdir()); + final File subFile = new File(subDir, "a.txt"); + if (!subFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + subFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(subFile)); + try { + TestUtils.generateTestData(output, (long) 16); + } finally { + IOUtils.closeQuietly(output); + } + + assertTrue(subDir.exists()); + assertTrue(subFile.exists()); + // delete dir + try { + FileDeleteStrategy.NORMAL.delete(subDir); + fail(); + } catch (final IOException ex) { + // expected + } + assertTrue(subDir.exists()); + assertTrue(subFile.exists()); + // delete file + FileDeleteStrategy.NORMAL.delete(subFile); + assertTrue(subDir.exists()); + assertFalse(subFile.exists()); + // delete dir + FileDeleteStrategy.NORMAL.delete(subDir); + assertFalse(subDir.exists()); + // delete dir + FileDeleteStrategy.NORMAL.delete(subDir); // no error + assertFalse(subDir.exists()); + } + + @Test + public void testDeleteQuietlyNormal() throws Exception { + final File baseDir = getTestDirectory(); + final File subDir = new File(baseDir, "test"); + assertTrue(subDir.mkdir()); + final File subFile = new File(subDir, "a.txt"); + if (!subFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + subFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(subFile)); + try { + TestUtils.generateTestData(output, (long) 16); + } finally { + IOUtils.closeQuietly(output); + } + + assertTrue(subDir.exists()); + assertTrue(subFile.exists()); + // delete dir + assertFalse(FileDeleteStrategy.NORMAL.deleteQuietly(subDir)); + assertTrue(subDir.exists()); + assertTrue(subFile.exists()); + // delete file + assertTrue(FileDeleteStrategy.NORMAL.deleteQuietly(subFile)); + assertTrue(subDir.exists()); + assertFalse(subFile.exists()); + // delete dir + assertTrue(FileDeleteStrategy.NORMAL.deleteQuietly(subDir)); + assertFalse(subDir.exists()); + // delete dir + assertTrue(FileDeleteStrategy.NORMAL.deleteQuietly(subDir)); // no error + assertFalse(subDir.exists()); + } + + @Test + public void testDeleteForce() throws Exception { + final File baseDir = getTestDirectory(); + final File subDir = new File(baseDir, "test"); + assertTrue(subDir.mkdir()); + final File subFile = new File(subDir, "a.txt"); + if (!subFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + subFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(subFile)); + try { + TestUtils.generateTestData(output, (long) 16); + } finally { + IOUtils.closeQuietly(output); + } + + assertTrue(subDir.exists()); + assertTrue(subFile.exists()); + // delete dir + FileDeleteStrategy.FORCE.delete(subDir); + assertFalse(subDir.exists()); + assertFalse(subFile.exists()); + // delete dir + FileDeleteStrategy.FORCE.delete(subDir); // no error + assertFalse(subDir.exists()); + } + + @Test + public void testDeleteNull() throws Exception { + try { + FileDeleteStrategy.NORMAL.delete(null); + fail(); + } catch (final NullPointerException ex) { + // expected + } + assertTrue(FileDeleteStrategy.NORMAL.deleteQuietly(null)); + } + + @Test + public void testToString() { + assertEquals("FileDeleteStrategy[Normal]", FileDeleteStrategy.NORMAL.toString()); + assertEquals("FileDeleteStrategy[Force]", FileDeleteStrategy.FORCE.toString()); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..ebacff5099717e744b812535243ad9fcc9022bd2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileSystemUtilsTestCase.java" @@ -0,0 +1,584 @@ +/* + * 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 org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.Assert; +import org.junit.Test; + +import java.io.*; +import java.util.Locale; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * This is used to test FileSystemUtils. + * + * @version $Id: FileSystemUtilsTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class FileSystemUtilsTestCase extends FileBasedTestCase { + + //----------------------------------------------------------------------- + @Test + public void testGetFreeSpace_String() throws Exception { + // test coverage, as we can't check value + if (File.separatorChar == '/') { + // have to figure out unix block size + final String[] cmd; + String osName = System.getProperty("os.name"); + osName = osName.toLowerCase(Locale.ENGLISH); + + if (osName.contains("hp-ux") || osName.contains("aix")) { + cmd = new String[]{"df", "-P", "/"}; + } else if (osName.contains("sunos") || osName.contains("sun os") + || osName.contains("solaris")) { + cmd = new String[]{"/usr/xpg4/bin/df", "-P", "/"}; + } else { + cmd = new String[]{"df", "/"}; + } + final Process proc = Runtime.getRuntime().exec(cmd); + boolean kilobyteBlock = true; + BufferedReader r = null; + try { + r = new BufferedReader(new InputStreamReader(proc.getInputStream())); + final String line = r.readLine(); + Assert.assertNotNull("Unexpected null line", line); + if (line.contains("512")) { + kilobyteBlock = false; + } + } finally { + IOUtils.closeQuietly(r); + } + + // now perform the test + @SuppressWarnings("deprecation") + final + long free = FileSystemUtils.freeSpace("/"); + final long kb = FileSystemUtils.freeSpaceKb("/"); + if (kilobyteBlock) { + assertEquals(free, kb, 256d); + } else { + assertEquals(free / 2d, kb, 256d); + } + } else { + @SuppressWarnings("deprecation") + final + long bytes = FileSystemUtils.freeSpace(""); + final long kb = FileSystemUtils.freeSpaceKb(""); + assertEquals((double) bytes / 1024, kb, 256d); + } + } + + //----------------------------------------------------------------------- + @Test + public void testGetFreeSpaceOS_String_NullPath() throws Exception { + final FileSystemUtils fsu = new FileSystemUtils(); + try { + fsu.freeSpaceOS(null, 1, false, -1); + fail(); + } catch (final IllegalArgumentException ignore) { + } + try { + fsu.freeSpaceOS(null, 1, true, -1); + fail(); + } catch (final IllegalArgumentException ignore) { + } + } + + @Test + public void testGetFreeSpaceOS_String_InitError() throws Exception { + final FileSystemUtils fsu = new FileSystemUtils(); + try { + fsu.freeSpaceOS("", -1, false, -1); + fail(); + } catch (final IllegalStateException ignore) { + } + try { + fsu.freeSpaceOS("", -1, true, -1); + fail(); + } catch (final IllegalStateException ignore) { + } + } + + @Test + public void testGetFreeSpaceOS_String_Other() throws Exception { + final FileSystemUtils fsu = new FileSystemUtils(); + try { + fsu.freeSpaceOS("", 0, false, -1); + fail(); + } catch (final IllegalStateException ignore) { + } + try { + fsu.freeSpaceOS("", 0, true, -1); + fail(); + } catch (final IllegalStateException ignore) { + } + } + + @Test + public void testGetFreeSpaceOS_String_Windows() throws Exception { + final FileSystemUtils fsu = new FileSystemUtils() { + @Override + protected long freeSpaceWindows(final String path, final long timeout) throws IOException { + return 12345L; + } + }; + assertEquals(12345L, fsu.freeSpaceOS("", 1, false, -1)); + assertEquals(12345L / 1024, fsu.freeSpaceOS("", 1, true, -1)); + } + + @Test + public void testGetFreeSpaceOS_String_Unix() throws Exception { + final FileSystemUtils fsu = new FileSystemUtils() { + @Override + protected long freeSpaceUnix(final String path, final boolean kb, final boolean posix, final long timeout) throws IOException { + return kb ? 12345L : 54321; + } + }; + assertEquals(54321L, fsu.freeSpaceOS("", 2, false, -1)); + assertEquals(12345L, fsu.freeSpaceOS("", 2, true, -1)); + } + + //----------------------------------------------------------------------- + @Test + public void testGetFreeSpaceWindows_String_ParseCommaFormatBytes() throws Exception { + // this is the format of response when calling dir /c + // we have now switched to dir /-c, so we should never get this + final String lines = + " Volume in drive C is HDD\n" + + " Volume Serial Number is XXXX-YYYY\n" + + "\n" + + " Directory of C:\\Documents and Settings\\Xxxx\n" + + "\n" + + "19/08/2005 22:43 .\n" + + "19/08/2005 22:43 ..\n" + + "11/08/2005 01:07 81 build.properties\n" + + "17/08/2005 21:44 Desktop\n" + + " 7 File(s) 180,260 bytes\n" + + " 10 Dir(s) 41,411,551,232 bytes free"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(41411551232L, fsu.freeSpaceWindows("", -1)); + } + + //----------------------------------------------------------------------- + @Test + public void testGetFreeSpaceWindows_String_EmptyPath() throws Exception { + final String lines = + " Volume in drive C is HDD\n" + + " Volume Serial Number is XXXX-YYYY\n" + + "\n" + + " Directory of C:\\Documents and Settings\\Xxxx\n" + + "\n" + + "19/08/2005 22:43 .\n" + + "19/08/2005 22:43 ..\n" + + "11/08/2005 01:07 81 build.properties\n" + + "17/08/2005 21:44 Desktop\n" + + " 7 File(s) 180260 bytes\n" + + " 10 Dir(s) 41411551232 bytes free"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c "); + assertEquals(41411551232L, fsu.freeSpaceWindows("", -1)); + } + + @Test + public void testGetFreeSpaceWindows_String_NormalResponse() throws Exception { + final String lines = + " Volume in drive C is HDD\n" + + " Volume Serial Number is XXXX-YYYY\n" + + "\n" + + " Directory of C:\\Documents and Settings\\Xxxx\n" + + "\n" + + "19/08/2005 22:43 .\n" + + "19/08/2005 22:43 ..\n" + + "11/08/2005 01:07 81 build.properties\n" + + "17/08/2005 21:44 Desktop\n" + + " 7 File(s) 180260 bytes\n" + + " 10 Dir(s) 41411551232 bytes free"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\""); + assertEquals(41411551232L, fsu.freeSpaceWindows("C:", -1)); + } + + @Test + public void testGetFreeSpaceWindows_String_StripDrive() throws Exception { + final String lines = + " Volume in drive C is HDD\n" + + " Volume Serial Number is XXXX-YYYY\n" + + "\n" + + " Directory of C:\\Documents and Settings\\Xxxx\n" + + "\n" + + "19/08/2005 22:43 .\n" + + "19/08/2005 22:43 ..\n" + + "11/08/2005 01:07 81 build.properties\n" + + "17/08/2005 21:44 Desktop\n" + + " 7 File(s) 180260 bytes\n" + + " 10 Dir(s) 41411551232 bytes free"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); + assertEquals(41411551232L, fsu.freeSpaceWindows("C:\\somedir", -1)); + } + + @Test + public void testGetFreeSpaceWindows_String_quoted() throws Exception { + final String lines = + " Volume in drive C is HDD\n" + + " Volume Serial Number is XXXX-YYYY\n" + + "\n" + + " Directory of C:\\Documents and Settings\\Xxxx\n" + + "\n" + + "19/08/2005 22:43 .\n" + + "19/08/2005 22:43 ..\n" + + "11/08/2005 01:07 81 build.properties\n" + + "17/08/2005 21:44 Desktop\n" + + " 7 File(s) 180260 bytes\n" + + " 10 Dir(s) 41411551232 bytes free"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines, "dir /a /-c \"C:\\somedir\""); + assertEquals(41411551232L, fsu.freeSpaceWindows("\"C:\\somedir\"", -1)); + } + + @Test + public void testGetFreeSpaceWindows_String_EmptyResponse() throws Exception { + final String lines = ""; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + try { + fsu.freeSpaceWindows("C:", -1); + fail(); + } catch (final IOException ignore) { + } + } + + @Test(expected = IOException.class) + public void testGetFreeSpaceWindows_String_EmptyMultiLineResponse() throws Exception { + final String lines = "\n\n"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + fsu.freeSpaceWindows("C:", -1); + } + + @Test(expected = IOException.class) + public void testGetFreeSpaceWindows_String_InvalidTextResponse() throws Exception { + final String lines = "BlueScreenOfDeath"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + fsu.freeSpaceWindows("C:", -1); + } + + @Test(expected = IOException.class) + public void testGetFreeSpaceWindows_String_NoSuchDirectoryResponse() throws Exception { + final String lines = + " Volume in drive C is HDD\n" + + " Volume Serial Number is XXXX-YYYY\n" + + "\n" + + " Directory of C:\\Documents and Settings\\empty" + + "\n"; + final FileSystemUtils fsu = new MockFileSystemUtils(1, lines); + fsu.freeSpaceWindows("C:", -1); + } + + //----------------------------------------------------------------------- + @Test + public void testGetFreeSpaceUnix_String_EmptyPath() throws Exception { + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "xxx:/home/users/s 14428928 12956424 1472504 90% /home/users/s"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + try { + fsu.freeSpaceUnix("", false, false, -1); + fail(); + } catch (final IllegalArgumentException ignore) { + } + try { + fsu.freeSpaceUnix("", true, false, -1); + fail(); + } catch (final IllegalArgumentException ignore) { + } + try { + fsu.freeSpaceUnix("", true, true, -1); + fail(); + } catch (final IllegalArgumentException ignore) { + } + try { + fsu.freeSpaceUnix("", false, true, -1); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + } + + @Test + public void testGetFreeSpaceUnix_String_NormalResponseLinux() throws Exception { + // from Sourceforge 'GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)' + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "/dev/xxx 497944 308528 189416 62% /"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(189416L, fsu.freeSpaceUnix("/", false, false, -1)); + } + + @Test + public void testGetFreeSpaceUnix_String_NormalResponseFreeBSD() throws Exception { + // from Apache 'FreeBSD 6.1-RELEASE (SMP-turbo)' + final String lines = + "Filesystem 1K-blocks Used Avail Capacity Mounted on\n" + + "/dev/xxxxxx 128990 102902 15770 87% /"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(15770L, fsu.freeSpaceUnix("/", false, false, -1)); + } + + //----------------------------------------------------------------------- + @Test + public void testGetFreeSpaceUnix_String_NormalResponseKbLinux() throws Exception { + // from Sourceforge 'GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)' + // df, df -k and df -kP are all identical + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "/dev/xxx 497944 308528 189416 62% /"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(189416L, fsu.freeSpaceUnix("/", true, false, -1)); + } + + @Test + public void testGetFreeSpaceUnix_String_NormalResponseKbFreeBSD() throws Exception { + // from Apache 'FreeBSD 6.1-RELEASE (SMP-turbo)' + // df and df -k are identical, but df -kP uses 512 blocks (not relevant as not used) + final String lines = + "Filesystem 1K-blocks Used Avail Capacity Mounted on\n" + + "/dev/xxxxxx 128990 102902 15770 87% /"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(15770L, fsu.freeSpaceUnix("/", true, false, -1)); + } + + @Test + public void testGetFreeSpaceUnix_String_NormalResponseKbSolaris() throws Exception { + // from IO-91 - ' SunOS et 5.10 Generic_118822-25 sun4u sparc SUNW,Ultra-4' + // non-kb response does not contain free space - see IO-91 + final String lines = + "Filesystem kbytes used avail capacity Mounted on\n" + + "/dev/dsk/x0x0x0x0 1350955 815754 481163 63%"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(481163L, fsu.freeSpaceUnix("/dev/dsk/x0x0x0x0", true, false, -1)); + } + + @Test + public void testGetFreeSpaceUnix_String_LongResponse() throws Exception { + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "xxx-yyyyyyy-zzz:/home/users/s\n" + + " 14428928 12956424 1472504 90% /home/users/s"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(1472504L, fsu.freeSpaceUnix("/home/users/s", false, false, -1)); + } + + @Test + public void testGetFreeSpaceUnix_String_LongResponseKb() throws Exception { + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "xxx-yyyyyyy-zzz:/home/users/s\n" + + " 14428928 12956424 1472504 90% /home/users/s"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + assertEquals(1472504L, fsu.freeSpaceUnix("/home/users/s", true, false, -1)); + } + @Test + + public void testGetFreeSpaceUnix_String_EmptyResponse() throws Exception { + final String lines = ""; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + try { + fsu.freeSpaceUnix("/home/users/s", false, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", false, true, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, true, -1); + fail(); + } catch (final IOException ignore) { + } + } + + @Test + public void testGetFreeSpaceUnix_String_InvalidResponse1() throws Exception { + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + " 14428928 12956424 100"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + try { + fsu.freeSpaceUnix("/home/users/s", false, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", false, true, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, true, -1); + fail(); + } catch (final IOException ignore) { + } + } + + @Test + public void testGetFreeSpaceUnix_String_InvalidResponse2() throws Exception { + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "xxx:/home/users/s 14428928 12956424 nnnnnnn 90% /home/users/s"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + try { + fsu.freeSpaceUnix("/home/users/s", false, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", false, true, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, true, -1); + fail(); + } catch (final IOException ignore) { + } + } + + @Test + public void testGetFreeSpaceUnix_String_InvalidResponse3() throws Exception { + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "xxx:/home/users/s 14428928 12956424 -1 90% /home/users/s"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + try { + fsu.freeSpaceUnix("/home/users/s", false, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", false, true, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, true, -1); + fail(); + } catch (final IOException ignore) { + } + } + + @Test + public void testGetFreeSpaceUnix_String_InvalidResponse4() throws Exception { + final String lines = + "Filesystem 1K-blocks Used Available Use% Mounted on\n" + + "xxx-yyyyyyy-zzz:/home/users/s"; + final FileSystemUtils fsu = new MockFileSystemUtils(0, lines); + try { + fsu.freeSpaceUnix("/home/users/s", false, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, false, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", false, true, -1); + fail(); + } catch (final IOException ignore) { + } + try { + fsu.freeSpaceUnix("/home/users/s", true, true, -1); + fail(); + } catch (final IOException ignore) { + } + } + + //----------------------------------------------------------------------- + static class MockFileSystemUtils extends FileSystemUtils { + private final int exitCode; + private final byte[] bytes; + private final String cmd; + + public MockFileSystemUtils(final int exitCode, final String lines) { + this(exitCode, lines, null); + } + + public MockFileSystemUtils(final int exitCode, final String lines, final String cmd) { + this.exitCode = exitCode; + this.bytes = lines.getBytes(); + this.cmd = cmd; + } + + @Override + Process openProcess(final String[] params) { + if (cmd != null) { + assertEquals(cmd, params[params.length - 1]); + } + return new Process() { + @Override + public InputStream getErrorStream() { + return null; + } + + @Override + public InputStream getInputStream() { + return new ByteArrayInputStream(bytes); + } + + @Override + public OutputStream getOutputStream() { + return null; + } + + @Override + public int waitFor() throws InterruptedException { + return exitCode; + } + + @Override + public int exitValue() { + return exitCode; + } + + @Override + public void destroy() { + } + }; + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..ce54fbef3890290c599faddeb970287c0236adce --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsCleanDirectoryTestCase.java" @@ -0,0 +1,161 @@ +/* + * 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.List; + +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Test cases for FileUtils.cleanDirectory() method. + * + * @version $Id: FileUtilsCleanDirectoryTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class FileUtilsCleanDirectoryTestCase extends FileBasedTestCase { + final File top = getLocalTestDirectory(); + + private File getLocalTestDirectory() { + return new File(getTestDirectory(), "list-files"); + } + + /** + * @see junit.framework.TestCase#setUp() + */ + @Before + public void setUp() throws Exception { + top.mkdirs(); + } + + /** + * @see junit.framework.TestCase#tearDown() + */ + @After + public void tearDown() throws Exception { + chmod(top, 775, true); + FileUtils.deleteDirectory(top); + } + + //----------------------------------------------------------------------- + @Test + public void testCleanEmpty() throws Exception { + assertEquals(0, top.list().length); + + FileUtils.cleanDirectory(top); + + assertEquals(0, top.list().length); + } + + @Test + public void testDeletesRegular() throws Exception { + FileUtils.touch(new File(top, "regular")); + FileUtils.touch(new File(top, ".hidden")); + + assertEquals(2, top.list().length); + + FileUtils.cleanDirectory(top); + + assertEquals(0, top.list().length); + } + + @Test + public void testDeletesNested() throws Exception { + final File nested = new File(top, "nested"); + + assertTrue(nested.mkdirs()); + + FileUtils.touch(new File(nested, "file")); + + assertEquals(1, top.list().length); + + FileUtils.cleanDirectory(top); + + assertEquals(0, top.list().length); + } + + @Test + public void testThrowsOnNullList() throws Exception { + if (System.getProperty("os.name").startsWith("Win") || !chmod(top, 0, false)) { + // test wont work if we can't restrict permissions on the + // directory, so skip it. + return; + } + + try { + FileUtils.cleanDirectory(top); + fail("expected IOException"); + } catch (final IOException e) { + assertEquals("Failed to list contents of " + + top.getAbsolutePath(), e.getMessage()); + } + } + + @Test + public void testThrowsOnCannotDeleteFile() throws Exception { + final File file = new File(top, "restricted"); + FileUtils.touch(file); + + if (System.getProperty("os.name").startsWith("Win") || !chmod(top, 500, false)) { + // test wont work if we can't restrict permissions on the + // directory, so skip it. + return; + } + + try { + FileUtils.cleanDirectory(top); + fail("expected IOException"); + } catch (final IOException e) { + assertEquals("Unable to delete file: " + + file.getAbsolutePath(), e.getMessage()); + } + } + + private boolean chmod(final File file, final int mode, final boolean recurse) + throws InterruptedException { + // TODO: Refactor this to FileSystemUtils + final List args = new ArrayList(); + args.add("chmod"); + + if (recurse) { + args.add("-R"); + } + + args.add(Integer.toString(mode)); + args.add(file.getAbsolutePath()); + + Process proc; + + try { + proc = Runtime.getRuntime().exec( + args.toArray(new String[args.size()])); + } catch (final IOException e) { + return false; + } + final int result = proc.waitFor(); + return result == 0; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..7d3a92725c6549c0c931afcfc8e287b8eb678857 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsCleanSymlinksTestCase.java" @@ -0,0 +1,273 @@ +/* + * 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.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Test cases for FileUtils.cleanDirectory() method that involve symlinks. + * & FileUtils.isSymlink(File file) + */ +public class FileUtilsCleanSymlinksTestCase extends FileBasedTestCase { + + final File top = getTestDirectory(); + + @Before + public void setUp() throws Exception { + top.mkdirs(); + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(top); + } + + @Test + public void testCleanDirWithSymlinkFile() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File realOuter = new File(top, "realouter"); + assertTrue(realOuter.mkdirs()); + + final File realInner = new File(realOuter, "realinner"); + assertTrue(realInner.mkdirs()); + + final File realFile = new File(realInner, "file1"); + FileUtils.touch(realFile); + assertEquals(1, realInner.list().length); + + final File randomFile = new File(top, "randomfile"); + FileUtils.touch(randomFile); + + final File symlinkFile = new File(realInner, "fakeinner"); + setupSymlink(randomFile, symlinkFile); + + assertEquals(2, realInner.list().length); + + // assert contents of the real directory were removed including the symlink + FileUtils.cleanDirectory(realOuter); + assertEquals(0, realOuter.list().length); + + // ensure that the contents of the symlink were NOT removed. + assertTrue(randomFile.exists()); + assertFalse(symlinkFile.exists()); + } + + + @Test + public void testCleanDirWithASymlinkDir() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File realOuter = new File(top, "realouter"); + assertTrue(realOuter.mkdirs()); + + final File realInner = new File(realOuter, "realinner"); + assertTrue(realInner.mkdirs()); + + FileUtils.touch(new File(realInner, "file1")); + assertEquals(1, realInner.list().length); + + final File randomDirectory = new File(top, "randomDir"); + assertTrue(randomDirectory.mkdirs()); + + FileUtils.touch(new File(randomDirectory, "randomfile")); + assertEquals(1, randomDirectory.list().length); + + final File symlinkDirectory = new File(realOuter, "fakeinner"); + setupSymlink(randomDirectory, symlinkDirectory); + + assertEquals(1, symlinkDirectory.list().length); + + // assert contents of the real directory were removed including the symlink + FileUtils.cleanDirectory(realOuter); + assertEquals(0, realOuter.list().length); + + // ensure that the contents of the symlink were NOT removed. + assertEquals("Contents of sym link should not have been removed", 1, randomDirectory.list().length); + } + + @Test + public void testCleanDirWithParentSymlinks() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File realParent = new File(top, "realparent"); + assertTrue(realParent.mkdirs()); + + final File realInner = new File(realParent, "realinner"); + assertTrue(realInner.mkdirs()); + + FileUtils.touch(new File(realInner, "file1")); + assertEquals(1, realInner.list().length); + + final File randomDirectory = new File(top, "randomDir"); + assertTrue(randomDirectory.mkdirs()); + + FileUtils.touch(new File(randomDirectory, "randomfile")); + assertEquals(1, randomDirectory.list().length); + + final File symlinkDirectory = new File(realParent, "fakeinner"); + setupSymlink(randomDirectory, symlinkDirectory); + + assertEquals(1, symlinkDirectory.list().length); + + final File symlinkParentDirectory = new File(top, "fakeouter"); + setupSymlink(realParent, symlinkParentDirectory); + + // assert contents of the real directory were removed including the symlink + FileUtils.cleanDirectory(symlinkParentDirectory);// should clean the contents of this but not recurse into other links + assertEquals(0, symlinkParentDirectory.list().length); + assertEquals(0, realParent.list().length); + + // ensure that the contents of the symlink were NOT removed. + assertEquals("Contents of sym link should not have been removed", 1, randomDirectory.list().length); + } + + @Test + public void testStillClearsIfGivenDirectoryIsASymlink() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File randomDirectory = new File(top, "randomDir"); + assertTrue(randomDirectory.mkdirs()); + + FileUtils.touch(new File(randomDirectory, "randomfile")); + assertEquals(1, randomDirectory.list().length); + + final File symlinkDirectory = new File(top, "fakeDir"); + setupSymlink(randomDirectory, symlinkDirectory); + + FileUtils.cleanDirectory(symlinkDirectory); + assertEquals(0, symlinkDirectory.list().length); + assertEquals(0, randomDirectory.list().length); + } + + + @Test + public void testIdentifiesSymlinkDir() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File randomDirectory = new File(top, "randomDir"); + assertTrue(randomDirectory.mkdirs()); + + final File symlinkDirectory = new File(top, "fakeDir"); + setupSymlink(randomDirectory, symlinkDirectory); + + assertTrue(FileUtils.isSymlink(symlinkDirectory)); + assertFalse(FileUtils.isSymlink(randomDirectory)); + } + + @Test + public void testIdentifiesSymlinkFile() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File randomFile = new File(top, "randomfile"); + FileUtils.touch(randomFile); + + final File symlinkFile = new File(top, "fakeinner"); + setupSymlink(randomFile, symlinkFile); + + assertTrue(FileUtils.isSymlink(symlinkFile)); + assertFalse(FileUtils.isSymlink(randomFile)); + } + + @Test + public void testIdentifiesBrokenSymlinkFile() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File noexistFile = new File(top, "noexist"); + final File symlinkFile = new File(top, "fakeinner"); + final File badSymlinkInPathFile = new File(symlinkFile, "fakeinner"); + final File noexistParentFile = new File("noexist", "file"); + + setupSymlink(noexistFile, symlinkFile); + + assertTrue(FileUtils.isSymlink(symlinkFile)); + assertFalse(FileUtils.isSymlink(noexistFile)); + assertFalse(FileUtils.isSymlink(noexistParentFile)); + assertFalse(FileUtils.isSymlink(badSymlinkInPathFile)); + } + + @Test + public void testCorrectlyIdentifySymlinkWithParentSymLink() throws Exception { + if (System.getProperty("os.name").startsWith("Win")) { + // cant create symlinks in windows. + return; + } + + final File realParent = new File(top, "realparent"); + assertTrue(realParent.mkdirs()); + + final File symlinkParentDirectory = new File(top, "fakeparent"); + setupSymlink(realParent, symlinkParentDirectory); + + final File realChild = new File(symlinkParentDirectory, "realChild"); + assertTrue(realChild.mkdirs()); + + final File symlinkChild = new File(symlinkParentDirectory, "fakeChild"); + setupSymlink(realChild, symlinkChild); + + assertTrue(FileUtils.isSymlink(symlinkChild)); + assertFalse(FileUtils.isSymlink(realChild)); + } + + private void setupSymlink(final File res, final File link) throws Exception { + // create symlink + final List args = new ArrayList(); + args.add("ln"); + args.add("-s"); + + args.add(res.getAbsolutePath()); + args.add(link.getAbsolutePath()); + + Process proc; + + proc = Runtime.getRuntime().exec(args.toArray(new String[args.size()])); + proc.waitFor(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..002c77b94fdda53943f6c928d389e074b3178738 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsDirectoryContainsTestCase.java" @@ -0,0 +1,181 @@ +/* + * 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 org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This class ensure the correctness of {@link FileUtils#directoryContains(File,File)}. + * + * @see FileUtils#directoryContains(File, File) + * @since 2.2 + * @version $Id: FileUtilsDirectoryContainsTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class FileUtilsDirectoryContainsTestCase extends FileBasedTestCase { + + private File directory1; + private File directory2; + private File directory3; + private File file1; + private File file1ByRelativeDirectory2; + private File file2; + private File file2ByRelativeDirectory1; + private File file3; + final File top = getTestDirectory(); + + @SuppressWarnings("ResultOfMethodCallIgnored") + @Before + public void setUp() throws Exception { + top.mkdirs(); + + directory1 = new File(top, "directory1"); + directory2 = new File(top, "directory2"); + directory3 = new File(directory2, "directory3"); + + directory1.mkdir(); + directory2.mkdir(); + directory3.mkdir(); + + file1 = new File(directory1, "file1"); + file2 = new File(directory2, "file2"); + file3 = new File(top, "file3"); + + // Tests case with relative path + file1ByRelativeDirectory2 = new File(getTestDirectory(), "directory2/../directory1/file1"); + file2ByRelativeDirectory1 = new File(getTestDirectory(), "directory1/../directory2/file2"); + + FileUtils.touch(file1); + FileUtils.touch(file2); + FileUtils.touch(file3); + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(top); + } + + @Test + public void testCanonicalPath() throws IOException { + assertTrue(FileUtils.directoryContains(directory1, file1ByRelativeDirectory2)); + assertTrue(FileUtils.directoryContains(directory2, file2ByRelativeDirectory1)); + + assertFalse(FileUtils.directoryContains(directory1, file2ByRelativeDirectory1)); + assertFalse(FileUtils.directoryContains(directory2, file1ByRelativeDirectory2)); + } + + @Test + public void testDirectoryContainsDirectory() throws IOException { + assertTrue(FileUtils.directoryContains(top, directory1)); + assertTrue(FileUtils.directoryContains(top, directory2)); + assertTrue(FileUtils.directoryContains(top, directory3)); + assertTrue(FileUtils.directoryContains(directory2, directory3)); + } + + @Test + public void testDirectoryContainsFile() throws IOException { + assertTrue(FileUtils.directoryContains(directory1, file1)); + assertTrue(FileUtils.directoryContains(directory2, file2)); + } + + @Test + public void testDirectoryDoesNotContainFile() throws IOException { + assertFalse(FileUtils.directoryContains(directory1, file2)); + assertFalse(FileUtils.directoryContains(directory2, file1)); + + assertFalse(FileUtils.directoryContains(directory1, file3)); + assertFalse(FileUtils.directoryContains(directory2, file3)); + } + + @Test + public void testDirectoryDoesNotContainsDirectory() throws IOException { + assertFalse(FileUtils.directoryContains(directory1, top)); + assertFalse(FileUtils.directoryContains(directory2, top)); + assertFalse(FileUtils.directoryContains(directory3, top)); + assertFalse(FileUtils.directoryContains(directory3, directory2)); + } + + @Test + public void testDirectoryDoesNotExist() throws IOException { + final File dir = new File("DOESNOTEXIST"); + assertFalse(dir.exists()); + try { + assertFalse(FileUtils.directoryContains(dir, file1)); + fail("Expected " + IllegalArgumentException.class.getName()); + } catch (final IllegalArgumentException e) { + // expected + } + } + + @Test + public void testSameFile() throws IOException { + try { + assertTrue(FileUtils.directoryContains(file1, file1)); + fail("Expected " + IllegalArgumentException.class.getName()); + } catch (final IllegalArgumentException e) { + // expected + } + } + + @Test + public void testIO466() throws IOException { + File fooFile = new File(directory1.getParent(), "directory1.txt"); + assertFalse(FileUtils.directoryContains(directory1, fooFile)); + } + + @Test + public void testFileDoesNotExist() throws IOException { + assertFalse(FileUtils.directoryContains(top, null)); + final File file = new File("DOESNOTEXIST"); + assertFalse(file.exists()); + assertFalse(FileUtils.directoryContains(top, file)); + } + + /** + * Test to demonstrate a file which does not exist returns false + * @throws IOException If an I/O error occurs + */ + @Test + public void testFileDoesNotExistBug() throws IOException { + final File file = new File(top, "DOESNOTEXIST"); + assertTrue("Check directory exists", top.exists()); + assertFalse("Check file does not exist", file.exists()); + assertFalse("Direcory does not contain unrealized file", FileUtils.directoryContains(top, file)); + } + + @Test + public void testUnrealizedContainment() throws IOException { + final File dir = new File("DOESNOTEXIST"); + final File file = new File(dir, "DOESNOTEXIST2"); + assertFalse(dir.exists()); + assertFalse(file.exists()); + try { + assertTrue(FileUtils.directoryContains(dir, file)); + } catch (final IllegalArgumentException e) { + // expected + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..7b76f44a88599ad6bc378ffffbd3908f9c06f27c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsFileNewerTestCase.java" @@ -0,0 +1,190 @@ +/* + * 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.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Date; + +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * This is used to test FileUtils for correctness. + */ +public class FileUtilsFileNewerTestCase extends FileBasedTestCase { + + // Test data + private static final int FILE1_SIZE = 1; + private static final int FILE2_SIZE = 1024 * 4 + 1; + + private final File m_testFile1; + private final File m_testFile2; + + public FileUtilsFileNewerTestCase() { + m_testFile1 = new File(getTestDirectory(), "file1-test.txt"); + m_testFile2 = new File(getTestDirectory(), "file2-test.txt"); + } + + /** @see junit.framework.TestCase#setUp() */ + @Before + public void setUp() throws Exception { + getTestDirectory().mkdirs(); + if (!m_testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + m_testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(m_testFile1)); + try { + TestUtils.generateTestData(output1, (long) FILE1_SIZE); + } finally { + IOUtils.closeQuietly(output1); + } + if (!m_testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + m_testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(m_testFile2)); + try { + TestUtils.generateTestData(output, (long) FILE2_SIZE); + } finally { + IOUtils.closeQuietly(output); + } + } + + /** @see junit.framework.TestCase#tearDown() */ + @After + public void tearDown() throws Exception { + m_testFile1.delete(); + m_testFile2.delete(); + } + + /** + * Tests the isFileNewer(File, *) methods which a "normal" file. + * + * @see FileUtils#isFileNewer(File, long) + * @see FileUtils#isFileNewer(File, Date) + * @see FileUtils#isFileNewer(File, File) + */ + @Test + public void testIsFileNewer() { + if (!m_testFile1.exists()) { + throw new IllegalStateException("The m_testFile1 should exist"); + } + + final long fileLastModified = m_testFile1.lastModified(); + final long TWO_SECOND = 2000; + + testIsFileNewer("two second earlier is not newer" , m_testFile1, fileLastModified + TWO_SECOND, false); + testIsFileNewer("same time is not newer" , m_testFile1, fileLastModified, false); + testIsFileNewer("two second later is newer" , m_testFile1, fileLastModified - TWO_SECOND, true); + } + + /** + * Tests the isFileNewer(File, *) methods which a not existing file. + * + * @see FileUtils#isFileNewer(File, long) + * @see FileUtils#isFileNewer(File, Date) + * @see FileUtils#isFileNewer(File, File) + */ + @Test + public void testIsFileNewerImaginaryFile() { + final File imaginaryFile = new File(getTestDirectory(), "imaginaryFile"); + if (imaginaryFile.exists()) { + throw new IllegalStateException("The imaginary File exists"); + } + + testIsFileNewer("imaginary file can be newer" , imaginaryFile, m_testFile2.lastModified(), false); + } + + /** + * Tests the isFileNewer(File, *) methods which the specified conditions. + * + * Creates : + *
    + *
  • a Date which represents the time reference
  • + *
  • a temporary file with the same last modification date than the time reference
  • + *
+ * Then compares (with the needed isFileNewer method) the last modification date of + * the specified file with the specified time reference, the created Date and the temporary + * file. + *
+ * The test is successfull if the three comparaisons return the specified wanted result. + * + * @param description describes the tested situation + * @param file the file of which the last modification date is compared + * @param time the time reference measured in milliseconds since the epoch + * @param wantedResult the expected result + * + * @see FileUtils#isFileNewer(File, long) + * @see FileUtils#isFileNewer(File, Date) + * @see FileUtils#isFileNewer(File, File) + */ + protected void testIsFileNewer(final String description, final File file, final long time, final boolean wantedResult) { + assertEquals(description + " - time", wantedResult, FileUtils.isFileNewer(file, time)); + assertEquals(description + " - date", wantedResult, FileUtils.isFileNewer(file, new Date(time))); + + final File temporaryFile = m_testFile2; + + temporaryFile.setLastModified(time); + assertEquals("The temporary file hasn't the right last modification date", time, temporaryFile.lastModified()); + assertEquals(description + " - file", wantedResult, FileUtils.isFileNewer(file, temporaryFile)); + } + + /** + * Tests the isFileNewer(File, long) method without specifying a File. + *
+ * The test is successfull if the method throws an IllegalArgumentException. + */ + @Test(expected = IllegalArgumentException.class) + public void testIsFileNewerNoFile() { + FileUtils.isFileNewer(null,0); + fail("File not specified"); + } + + /** + * Tests the isFileNewer(File, Date) method without specifying a Date. + *
+ * The test is successfull if the method throws an IllegalArgumentException. + */ + @Test(expected = IllegalArgumentException.class) + public void testIsFileNewerNoDate() { + FileUtils.isFileNewer(m_testFile1, (Date) null); + fail("Date not specified"); + } + + /** + * Tests the isFileNewer(File, File) method without specifying a reference File. + *
+ * The test is successfull if the method throws an IllegalArgumentException. + */ + @Test(expected = IllegalArgumentException.class) + public void testIsFileNewerNoFileReference() { + FileUtils.isFileNewer(m_testFile1, (File) null); + fail("Reference file not specified"); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..5bb451118a38b01a02fb3f1bec7c81e062606f77 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsListFilesTestCase.java" @@ -0,0 +1,211 @@ +/* + * 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 org.apache.commons.io.filefilter.FileFilterUtils; +import org.apache.commons.io.filefilter.IOFileFilter; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Test cases for FileUtils.listFiles() methods. + */ +public class FileUtilsListFilesTestCase extends FileBasedTestCase { + + private File getLocalTestDirectory() { + return new File(getTestDirectory(), "list-files"); + } + + /** + * @see junit.framework.TestCase#setUp() + */ + @SuppressWarnings("ResultOfMethodCallIgnored") + @Before + public void setUp() throws Exception { + File dir = getLocalTestDirectory(); + if (dir.exists()) { + FileUtils.deleteDirectory(dir); + } + dir.mkdirs(); + File file = new File(dir, "dummy-build.xml"); + FileUtils.touch(file); + file = new File(dir, "README"); + FileUtils.touch(file); + + dir = new File(dir, "subdir1"); + dir.mkdirs(); + file = new File(dir, "dummy-build.xml"); + FileUtils.touch(file); + file = new File(dir, "dummy-readme.txt"); + FileUtils.touch(file); + + dir = new File(dir, "subsubdir1"); + dir.mkdirs(); + file = new File(dir, "dummy-file.txt"); + FileUtils.touch(file); + file = new File(dir, "dummy-index.html"); + FileUtils.touch(file); + + dir = dir.getParentFile(); + dir = new File(dir, "CVS"); + dir.mkdirs(); + file = new File(dir, "Entries"); + FileUtils.touch(file); + file = new File(dir, "Repository"); + FileUtils.touch(file); + } + + /** + * @see junit.framework.TestCase#tearDown() + */ + @After + public void tearDown() throws Exception { + final File dir = getLocalTestDirectory(); + FileUtils.deleteDirectory(dir); + } + + private Collection filesToFilenames(final Collection files) { + final Collection filenames = new ArrayList(files.size()); + for (final File file : files) { + filenames.add(file.getName()); + } + return filenames; + } + + private Collection filesToFilenames(final Iterator files) { + final Collection filenames = new ArrayList(); + while (files.hasNext()) { + filenames.add(files.next().getName()); + } + return filenames; + } + + @Test + public void testIterateFilesByExtension() throws Exception { + final String[] extensions = { "xml", "txt" }; + + Iterator files = FileUtils.iterateFiles(getLocalTestDirectory(), extensions, false); + Collection filenames = filesToFilenames(files); + assertEquals(1, filenames.size()); + assertTrue(filenames.contains("dummy-build.xml")); + assertFalse(filenames.contains("README")); + assertFalse(filenames.contains("dummy-file.txt")); + + files = FileUtils.iterateFiles(getLocalTestDirectory(), extensions, true); + filenames = filesToFilenames(files); + assertEquals(4, filenames.size()); + assertTrue(filenames.contains("dummy-file.txt")); + assertFalse(filenames.contains("dummy-index.html")); + + files = FileUtils.iterateFiles(getLocalTestDirectory(), null, false); + filenames = filesToFilenames(files); + assertEquals(2, filenames.size()); + assertTrue(filenames.contains("dummy-build.xml")); + assertTrue(filenames.contains("README")); + assertFalse(filenames.contains("dummy-file.txt")); + } + + @Test + public void testListFilesByExtension() throws Exception { + final String[] extensions = {"xml", "txt"}; + + Collection files = FileUtils.listFiles(getLocalTestDirectory(), extensions, false); + assertEquals(1, files.size()); + Collection filenames = filesToFilenames(files); + assertTrue(filenames.contains("dummy-build.xml")); + assertFalse(filenames.contains("README")); + assertFalse(filenames.contains("dummy-file.txt")); + + files = FileUtils.listFiles(getLocalTestDirectory(), extensions, true); + filenames = filesToFilenames(files); + assertEquals(4, filenames.size()); + assertTrue(filenames.contains("dummy-file.txt")); + assertFalse(filenames.contains("dummy-index.html")); + + files = FileUtils.listFiles(getLocalTestDirectory(), null, false); + assertEquals(2, files.size()); + filenames = filesToFilenames(files); + assertTrue(filenames.contains("dummy-build.xml")); + assertTrue(filenames.contains("README")); + assertFalse(filenames.contains("dummy-file.txt")); + } + + @Test + public void testListFiles() throws Exception { + Collection files; + Collection filenames; + IOFileFilter fileFilter; + IOFileFilter dirFilter; + + //First, find non-recursively + fileFilter = FileFilterUtils.trueFileFilter(); + files = FileUtils.listFiles(getLocalTestDirectory(), fileFilter, null); + filenames = filesToFilenames(files); + assertTrue("'dummy-build.xml' is missing", filenames.contains("dummy-build.xml")); + assertFalse("'dummy-index.html' shouldn't be found", filenames.contains("dummy-index.html")); + assertFalse("'Entries' shouldn't be found", filenames.contains("Entries")); + + //Second, find recursively + fileFilter = FileFilterUtils.trueFileFilter(); + dirFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("CVS")); + files = FileUtils.listFiles(getLocalTestDirectory(), fileFilter, dirFilter); + filenames = filesToFilenames(files); + assertTrue("'dummy-build.xml' is missing", filenames.contains("dummy-build.xml")); + assertTrue("'dummy-index.html' is missing", filenames.contains("dummy-index.html")); + assertFalse("'Entries' shouldn't be found", filenames.contains("Entries")); + + //Do the same as above but now with the filter coming from FileFilterUtils + fileFilter = FileFilterUtils.trueFileFilter(); + dirFilter = FileFilterUtils.makeCVSAware(null); + files = FileUtils.listFiles(getLocalTestDirectory(), fileFilter, dirFilter); + filenames = filesToFilenames(files); + assertTrue("'dummy-build.xml' is missing", filenames.contains("dummy-build.xml")); + assertTrue("'dummy-index.html' is missing", filenames.contains("dummy-index.html")); + assertFalse("'Entries' shouldn't be found", filenames.contains("Entries")); + + //Again with the CVS filter but now with a non-null parameter + fileFilter = FileFilterUtils.trueFileFilter(); + dirFilter = FileFilterUtils.prefixFileFilter("sub"); + dirFilter = FileFilterUtils.makeCVSAware(dirFilter); + files = FileUtils.listFiles(getLocalTestDirectory(), fileFilter, dirFilter); + filenames = filesToFilenames(files); + assertTrue("'dummy-build.xml' is missing", filenames.contains("dummy-build.xml")); + assertTrue("'dummy-index.html' is missing", filenames.contains("dummy-index.html")); + assertFalse("'Entries' shouldn't be found", filenames.contains("Entries")); + + try { + FileUtils.listFiles(getLocalTestDirectory(), null, null); + fail("Expected error about null parameter"); + } catch (final NullPointerException e) { + // expected + } + } + + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..942e8301ccfa6c7103bbdfb7f9be1842072941ae --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsTestCase.java" @@ -0,0 +1,3085 @@ +/* + * 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 org.apache.commons.io.filefilter.NameFileFilter; +import org.apache.commons.io.filefilter.WildcardFileFilter; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.*; + +import java.io.*; +import java.math.BigInteger; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.*; +import java.util.zip.CRC32; +import java.util.zip.Checksum; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This is used to test FileUtils for correctness. + * + * @version $Id: FileUtilsTestCase.java 1718945 2015-12-09 19:51:14Z krosenvold $ + * @see FileUtils + */ +@SuppressWarnings({"deprecation", "ResultOfMethodCallIgnored"}) // unit tests include tests of many deprecated methods +public class FileUtilsTestCase extends FileBasedTestCase { + + // Test data + + /** + * Size of test directory. + */ + private static final int TEST_DIRECTORY_SIZE = 0; + + /** + * Size of test directory. + */ + private static final BigInteger TEST_DIRECTORY_SIZE_BI = BigInteger.ZERO; + + /** + * Size (greater of zero) of test file. + */ + private static final BigInteger TEST_DIRECTORY_SIZE_GT_ZERO_BI = BigInteger.valueOf(100); + + /** + * List files recursively + */ + private static final ListDirectoryWalker LIST_WALKER = new ListDirectoryWalker(); + + /** + * Delay in milliseconds to make sure test for "last modified date" are accurate + */ + //private static final int LAST_MODIFIED_DELAY = 600; + + private final File testFile1; + private final File testFile2; + + private final int testFile1Size; + private final int testFile2Size; + + public FileUtilsTestCase() { + testFile1 = new File(getTestDirectory(), "file1-test.txt"); + testFile2 = new File(getTestDirectory(), "file1a-test.txt"); + + testFile1Size = (int) testFile1.length(); + testFile2Size = (int) testFile2.length(); + } + + @Before + public void setUp() throws Exception { + getTestDirectory().mkdirs(); + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output3 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output3, (long) testFile1Size); + } finally { + IOUtils.closeQuietly(output3); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output2 = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output2, (long) testFile2Size); + } finally { + IOUtils.closeQuietly(output2); + } + FileUtils.deleteDirectory(getTestDirectory()); + getTestDirectory().mkdirs(); + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output1, (long) testFile1Size); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output, (long) testFile2Size); + } finally { + IOUtils.closeQuietly(output); + } + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(getTestDirectory()); + } + + private String getName() { + return this.getClass().getSimpleName(); + } + + //----------------------------------------------------------------------- + @Test + public void testGetFile() { + final File expected_A = new File("src"); + final File expected_B = new File(expected_A, "main"); + final File expected_C = new File(expected_B, "java"); + assertEquals("A", expected_A, FileUtils.getFile("src")); + assertEquals("B", expected_B, FileUtils.getFile("src", "main")); + assertEquals("C", expected_C, FileUtils.getFile("src", "main", "java")); + try { + FileUtils.getFile((String[]) null); + fail("Expected NullPointerException"); + } catch (final NullPointerException e) { + // expected + } + } + + @Test + public void testGetFile_Parent() { + final File parent = new File("parent"); + final File expected_A = new File(parent, "src"); + final File expected_B = new File(expected_A, "main"); + final File expected_C = new File(expected_B, "java"); + assertEquals("A", expected_A, FileUtils.getFile(parent, "src")); + assertEquals("B", expected_B, FileUtils.getFile(parent, "src", "main")); + assertEquals("C", expected_C, FileUtils.getFile(parent, "src", "main", "java")); + try { + FileUtils.getFile(parent, (String[]) null); + fail("Expected NullPointerException"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.getFile((File) null, "src"); + fail("Expected NullPointerException"); + } catch (final NullPointerException e) { + // expected + } + } + + @Test + public void testGetTempDirectoryPath() { + assertEquals(System.getProperty("java.io.tmpdir"), + FileUtils.getTempDirectoryPath()); + } + + @Test + public void testGetTempDirectory() { + final File tempDirectory = new File(System.getProperty("java.io.tmpdir")); + assertEquals(tempDirectory, FileUtils.getTempDirectory()); + } + + @Test + public void testGetUserDirectoryPath() { + assertEquals(System.getProperty("user.home"), + FileUtils.getUserDirectoryPath()); + } + + @Test + public void testGetUserDirectory() { + final File userDirectory = new File(System.getProperty("user.home")); + assertEquals(userDirectory, FileUtils.getUserDirectory()); + } + + //----------------------------------------------------------------------- + @Test + public void test_openInputStream_exists() throws Exception { + final File file = new File(getTestDirectory(), "test.txt"); + TestUtils.createLineBasedFile(file, new String[]{"Hello"}); + FileInputStream in = null; + try { + in = FileUtils.openInputStream(file); + assertEquals('H', in.read()); + } finally { + IOUtils.closeQuietly(in); + } + } + + @Test + public void test_openInputStream_existsButIsDirectory() throws Exception { + final File directory = new File(getTestDirectory(), "subdir"); + directory.mkdirs(); + FileInputStream in = null; + try { + in = FileUtils.openInputStream(directory); + fail(); + } catch (final IOException ioe) { + // expected + } finally { + IOUtils.closeQuietly(in); + } + } + + @Test + public void test_openInputStream_notExists() throws Exception { + final File directory = new File(getTestDirectory(), "test.txt"); + FileInputStream in = null; + try { + in = FileUtils.openInputStream(directory); + fail(); + } catch (final IOException ioe) { + // expected + } finally { + IOUtils.closeQuietly(in); + } + } + + //----------------------------------------------------------------------- + void openOutputStream_noParent(final boolean createFile) throws Exception { + final File file = new File("test.txt"); + assertNull(file.getParentFile()); + try { + if (createFile) { + TestUtils.createLineBasedFile(file, new String[]{"Hello"}); + } + FileOutputStream out = null; + try { + out = FileUtils.openOutputStream(file); + out.write(0); + } finally { + IOUtils.closeQuietly(out); + } + assertTrue(file.exists()); + } finally { + if (!file.delete()) { + file.deleteOnExit(); + } + } + } + + @Test + public void test_openOutputStream_noParentCreateFile() throws Exception { + openOutputStream_noParent(true); + } + + @Test + public void test_openOutputStream_noParentNoFile() throws Exception { + openOutputStream_noParent(false); + } + + + @Test + public void test_openOutputStream_exists() throws Exception { + final File file = new File(getTestDirectory(), "test.txt"); + TestUtils.createLineBasedFile(file, new String[]{"Hello"}); + FileOutputStream out = null; + try { + out = FileUtils.openOutputStream(file); + out.write(0); + } finally { + IOUtils.closeQuietly(out); + } + assertTrue(file.exists()); + } + + @Test + public void test_openOutputStream_existsButIsDirectory() throws Exception { + final File directory = new File(getTestDirectory(), "subdir"); + directory.mkdirs(); + FileOutputStream out = null; + try { + out = FileUtils.openOutputStream(directory); + fail(); + } catch (final IOException ioe) { + // expected + } finally { + IOUtils.closeQuietly(out); + } + } + + @Test + public void test_openOutputStream_notExists() throws Exception { + final File file = new File(getTestDirectory(), "a/test.txt"); + FileOutputStream out = null; + try { + out = FileUtils.openOutputStream(file); + out.write(0); + } finally { + IOUtils.closeQuietly(out); + } + assertTrue(file.exists()); + } + + @Test + public void test_openOutputStream_notExistsCannotCreate() throws Exception { + // according to Wikipedia, most filing systems have a 256 limit on filename + final String longStr = + "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" + + "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" + + "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" + + "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" + + "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz" + + "abcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyzabcdevwxyz"; // 300 chars + final File file = new File(getTestDirectory(), "a/" + longStr + "/test.txt"); + FileOutputStream out = null; + try { + out = FileUtils.openOutputStream(file); + fail(); + } catch (final IOException ioe) { + // expected + } finally { + IOUtils.closeQuietly(out); + } + } + + //----------------------------------------------------------------------- + // byteCountToDisplaySize + @Test + public void testByteCountToDisplaySizeBigInteger() { + final BigInteger b1023 = BigInteger.valueOf(1023); + final BigInteger b1025 = BigInteger.valueOf(1025); + final BigInteger KB1 = BigInteger.valueOf(1024); + final BigInteger MB1 = KB1.multiply(KB1); + final BigInteger GB1 = MB1.multiply(KB1); + final BigInteger GB2 = GB1.add(GB1); + final BigInteger TB1 = GB1.multiply(KB1); + final BigInteger PB1 = TB1.multiply(KB1); + final BigInteger EB1 = PB1.multiply(KB1); + assertEquals(FileUtils.byteCountToDisplaySize(BigInteger.ZERO), "0 bytes"); + assertEquals(FileUtils.byteCountToDisplaySize(BigInteger.ONE), "1 bytes"); + assertEquals(FileUtils.byteCountToDisplaySize(b1023), "1023 bytes"); + assertEquals(FileUtils.byteCountToDisplaySize(KB1), "1 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(b1025), "1 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(MB1.subtract(BigInteger.ONE)), "1023 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(MB1), "1 MB"); + assertEquals(FileUtils.byteCountToDisplaySize(MB1.add(BigInteger.ONE)), "1 MB"); + assertEquals(FileUtils.byteCountToDisplaySize(GB1.subtract(BigInteger.ONE)), "1023 MB"); + assertEquals(FileUtils.byteCountToDisplaySize(GB1), "1 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(GB1.add(BigInteger.ONE)), "1 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(GB2), "2 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(GB2.subtract(BigInteger.ONE)), "1 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(TB1), "1 TB"); + assertEquals(FileUtils.byteCountToDisplaySize(PB1), "1 PB"); + assertEquals(FileUtils.byteCountToDisplaySize(EB1), "1 EB"); + assertEquals(FileUtils.byteCountToDisplaySize(Long.MAX_VALUE), "7 EB"); + // Other MAX_VALUEs + assertEquals(FileUtils.byteCountToDisplaySize(BigInteger.valueOf(Character.MAX_VALUE)), "63 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(BigInteger.valueOf(Short.MAX_VALUE)), "31 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(BigInteger.valueOf(Integer.MAX_VALUE)), "1 GB"); + } + + @SuppressWarnings("NumericOverflow") + @Test + public void testByteCountToDisplaySizeLong() { + assertEquals(FileUtils.byteCountToDisplaySize(0), "0 bytes"); + assertEquals(FileUtils.byteCountToDisplaySize(1), "1 bytes"); + assertEquals(FileUtils.byteCountToDisplaySize(1023), "1023 bytes"); + assertEquals(FileUtils.byteCountToDisplaySize(1024), "1 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(1025), "1 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024 * 1023), "1023 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024 * 1024), "1 MB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024 * 1025), "1 MB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024 * 1024 * 1023), "1023 MB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024 * 1024 * 1024), "1 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024 * 1024 * 1025), "1 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024L * 1024 * 1024 * 2), "2 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024 * 1024 * 1024 * 2 - 1), "1 GB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024L * 1024 * 1024 * 1024), "1 TB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024L * 1024 * 1024 * 1024 * 1024), "1 PB"); + assertEquals(FileUtils.byteCountToDisplaySize(1024L * 1024 * 1024 * 1024 * 1024 * 1024), "1 EB"); + assertEquals(FileUtils.byteCountToDisplaySize(Long.MAX_VALUE), "7 EB"); + // Other MAX_VALUEs + assertEquals(FileUtils.byteCountToDisplaySize(Character.MAX_VALUE), "63 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(Short.MAX_VALUE), "31 KB"); + assertEquals(FileUtils.byteCountToDisplaySize(Integer.MAX_VALUE), "1 GB"); + } + + //----------------------------------------------------------------------- + @Test + public void testToFile1() throws Exception { + final URL url = new URL("file", null, "a/b/c/file.txt"); + final File file = FileUtils.toFile(url); + assertTrue(file.toString().contains("file.txt")); + } + + @Test + public void testToFile2() throws Exception { + final URL url = new URL("file", null, "a/b/c/file%20n%61me%2520.tx%74"); + final File file = FileUtils.toFile(url); + assertTrue(file.toString().contains("file name%20.txt")); + } + + @Test + public void testToFile3() throws Exception { + assertEquals(null, FileUtils.toFile(null)); + assertEquals(null, FileUtils.toFile(new URL("http://jakarta.apache.org"))); + } + + @Test + public void testToFile4() throws Exception { + final URL url = new URL("file", null, "a/b/c/file%%20%me.txt%"); + final File file = FileUtils.toFile(url); + assertTrue(file.toString().contains("file% %me.txt%")); + } + + /* IO-252 */ + @Test + public void testToFile5() throws Exception { + final URL url = new URL("file", null, "both%20are%20100%20%25%20true"); + final File file = FileUtils.toFile(url); + assertEquals("both are 100 % true", file.toString()); + } + + @Test + public void testToFileUtf8() throws Exception { + final URL url = new URL("file", null, "/home/%C3%A4%C3%B6%C3%BC%C3%9F"); + final File file = FileUtils.toFile(url); + assertTrue(file.toString().contains("\u00E4\u00F6\u00FC\u00DF")); + } + + @Test + public void testDecodeUrl() { + assertEquals("", FileUtils.decodeUrl("")); + assertEquals("foo", FileUtils.decodeUrl("foo")); + assertEquals("+", FileUtils.decodeUrl("+")); + assertEquals("% ", FileUtils.decodeUrl("%25%20")); + assertEquals("%20", FileUtils.decodeUrl("%2520")); + assertEquals("jar:file:/C:/dir/sub dir/1.0/foo-1.0.jar!/org/Bar.class", FileUtils + .decodeUrl("jar:file:/C:/dir/sub%20dir/1.0/foo-1.0.jar!/org/Bar.class")); + } + + @Test + public void testDecodeUrlLenient() { + assertEquals(" ", FileUtils.decodeUrl(" ")); + assertEquals("\u00E4\u00F6\u00FC\u00DF", FileUtils.decodeUrl("\u00E4\u00F6\u00FC\u00DF")); + assertEquals("%", FileUtils.decodeUrl("%")); + assertEquals("% ", FileUtils.decodeUrl("%%20")); + assertEquals("%2", FileUtils.decodeUrl("%2")); + assertEquals("%2G", FileUtils.decodeUrl("%2G")); + } + + @Test + public void testDecodeUrlNullSafe() { + assertNull(FileUtils.decodeUrl(null)); + } + + @Test + public void testDecodeUrlEncodingUtf8() { + assertEquals("\u00E4\u00F6\u00FC\u00DF", FileUtils.decodeUrl("%C3%A4%C3%B6%C3%BC%C3%9F")); + } + + // toFiles + + @Test + public void testToFiles1() throws Exception { + final URL[] urls = new URL[]{ + new URL("file", null, "file1.txt"), + new URL("file", null, "file2.txt"), + }; + final File[] files = FileUtils.toFiles(urls); + + assertEquals(urls.length, files.length); + assertEquals("File: " + files[0], true, files[0].toString().contains("file1.txt")); + assertEquals("File: " + files[1], true, files[1].toString().contains("file2.txt")); + } + + @Test + public void testToFiles2() throws Exception { + final URL[] urls = new URL[]{ + new URL("file", null, "file1.txt"), + null, + }; + final File[] files = FileUtils.toFiles(urls); + + assertEquals(urls.length, files.length); + assertEquals("File: " + files[0], true, files[0].toString().contains("file1.txt")); + assertEquals("File: " + files[1], null, files[1]); + } + + @Test + public void testToFiles3() throws Exception { + final URL[] urls = null; + final File[] files = FileUtils.toFiles(urls); + + assertEquals(0, files.length); + } + + @Test + public void testToFiles3a() throws Exception { + final URL[] urls = new URL[0]; // empty array + final File[] files = FileUtils.toFiles(urls); + + assertEquals(0, files.length); + } + + @Test + public void testToFiles4() throws Exception { + final URL[] urls = new URL[]{ + new URL("file", null, "file1.txt"), + new URL("http", "jakarta.apache.org", "file1.txt"), + }; + try { + FileUtils.toFiles(urls); + fail(); + } catch (final IllegalArgumentException ignore) { + } + } + + // toURLs + + @Test + public void testToURLs1() throws Exception { + final File[] files = new File[]{ + new File(getTestDirectory(), "file1.txt"), + new File(getTestDirectory(), "file2.txt"), + new File(getTestDirectory(), "test file.txt"), + }; + final URL[] urls = FileUtils.toURLs(files); + + assertEquals(files.length, urls.length); + assertTrue(urls[0].toExternalForm().startsWith("file:")); + assertTrue(urls[0].toExternalForm().contains("file1.txt")); + assertTrue(urls[1].toExternalForm().startsWith("file:")); + assertTrue(urls[1].toExternalForm().contains("file2.txt")); + + // Test escaped char + assertTrue(urls[2].toExternalForm().startsWith("file:")); + assertTrue(urls[2].toExternalForm().contains("test%20file.txt")); + } + +// @Test public void testToURLs2() throws Exception { +// File[] files = new File[] { +// new File(getTestDirectory(), "file1.txt"), +// null, +// }; +// URL[] urls = FileUtils.toURLs(files); +// +// assertEquals(files.length, urls.length); +// assertTrue(urls[0].toExternalForm().startsWith("file:")); +// assertTrue(urls[0].toExternalForm().indexOf("file1.txt") > 0); +// assertEquals(null, urls[1]); +// } +// +// @Test public void testToURLs3() throws Exception { +// File[] files = null; +// URL[] urls = FileUtils.toURLs(files); +// +// assertEquals(0, urls.length); +// } + + @Test + public void testToURLs3a() throws Exception { + final File[] files = new File[0]; // empty array + final URL[] urls = FileUtils.toURLs(files); + + assertEquals(0, urls.length); + } + + // contentEquals + + @Test + public void testContentEquals() throws Exception { + // Non-existent files + final File file = new File(getTestDirectory(), getName()); + final File file2 = new File(getTestDirectory(), getName() + "2"); + // both don't exist + assertTrue(FileUtils.contentEquals(file, file)); + assertTrue(FileUtils.contentEquals(file, file2)); + assertTrue(FileUtils.contentEquals(file2, file2)); + assertTrue(FileUtils.contentEquals(file2, file)); + + // Directories + try { + FileUtils.contentEquals(getTestDirectory(), getTestDirectory()); + fail("Comparing directories should fail with an IOException"); + } catch (final IOException ioe) { + //expected + } + + // Different files + final File objFile1 = + new File(getTestDirectory(), getName() + ".object"); + objFile1.deleteOnExit(); + FileUtils.copyURLToFile( + getClass().getResource("/java/lang/Object.class"), + objFile1); + + final File objFile1b = + new File(getTestDirectory(), getName() + ".object2"); + objFile1.deleteOnExit(); + FileUtils.copyURLToFile( + getClass().getResource("/java/lang/Object.class"), + objFile1b); + + final File objFile2 = + new File(getTestDirectory(), getName() + ".collection"); + objFile2.deleteOnExit(); + FileUtils.copyURLToFile( + getClass().getResource("/java/util/Collection.class"), + objFile2); + + assertFalse(FileUtils.contentEquals(objFile1, objFile2)); + assertFalse(FileUtils.contentEquals(objFile1b, objFile2)); + assertTrue(FileUtils.contentEquals(objFile1, objFile1b)); + + assertTrue(FileUtils.contentEquals(objFile1, objFile1)); + assertTrue(FileUtils.contentEquals(objFile1b, objFile1b)); + assertTrue(FileUtils.contentEquals(objFile2, objFile2)); + + // Equal files + file.createNewFile(); + file2.createNewFile(); + assertTrue(FileUtils.contentEquals(file, file)); + assertTrue(FileUtils.contentEquals(file, file2)); + } + + @Test + public void testContentEqualsIgnoreEOL() throws Exception { + // Non-existent files + final File file1 = new File(getTestDirectory(), getName()); + final File file2 = new File(getTestDirectory(), getName() + "2"); + // both don't exist + assertTrue(FileUtils.contentEqualsIgnoreEOL(file1, file1, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(file1, file2, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(file2, file2, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(file2, file1, null)); + + // Directories + try { + FileUtils.contentEqualsIgnoreEOL(getTestDirectory(), getTestDirectory(), null); + fail("Comparing directories should fail with an IOException"); + } catch (final IOException ioe) { + //expected + } + + // Different files + final File tfile1 = new File(getTestDirectory(), getName() + ".txt1"); + tfile1.deleteOnExit(); + FileUtils.write(tfile1, "123\r"); + + final File tfile2 = new File(getTestDirectory(), getName() + ".txt2"); + tfile1.deleteOnExit(); + FileUtils.write(tfile2, "123\n"); + + final File tfile3 = new File(getTestDirectory(), getName() + ".collection"); + tfile3.deleteOnExit(); + FileUtils.write(tfile3, "123\r\n2"); + + assertTrue(FileUtils.contentEqualsIgnoreEOL(tfile1, tfile1, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(tfile2, tfile2, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(tfile3, tfile3, null)); + + assertTrue(FileUtils.contentEqualsIgnoreEOL(tfile1, tfile2, null)); + assertFalse(FileUtils.contentEqualsIgnoreEOL(tfile1, tfile3, null)); + assertFalse(FileUtils.contentEqualsIgnoreEOL(tfile2, tfile3, null)); + + final URL urlCR = getClass().getResource("FileUtilsTestDataCR.dat"); + assertNotNull(urlCR); + final File cr = new File(urlCR.getPath()); + assertTrue(cr.exists()); + + final URL urlCRLF = getClass().getResource("FileUtilsTestDataCRLF.dat"); + assertNotNull(urlCRLF); + final File crlf = new File(urlCRLF.getPath()); + assertTrue(crlf.exists()); + + final URL urlLF = getClass().getResource("FileUtilsTestDataLF.dat"); + assertNotNull(urlLF); + final File lf = new File(urlLF.getPath()); + assertTrue(lf.exists()); + + assertTrue(FileUtils.contentEqualsIgnoreEOL(cr, cr, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(crlf, crlf, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(lf, lf, null)); + + assertTrue(FileUtils.contentEqualsIgnoreEOL(cr, crlf, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(cr, lf, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(crlf, lf, null)); + + // Check the files behave OK when EOL is not ignored + assertTrue(FileUtils.contentEquals(cr, cr)); + assertTrue(FileUtils.contentEquals(crlf, crlf)); + assertTrue(FileUtils.contentEquals(lf, lf)); + + assertFalse(FileUtils.contentEquals(cr, crlf)); + assertFalse(FileUtils.contentEquals(cr, lf)); + assertFalse(FileUtils.contentEquals(crlf, lf)); + + // Equal files + file1.createNewFile(); + file2.createNewFile(); + assertTrue(FileUtils.contentEqualsIgnoreEOL(file1, file1, null)); + assertTrue(FileUtils.contentEqualsIgnoreEOL(file1, file2, null)); + } + + // copyURLToFile + + @Test + public void testCopyURLToFile() throws Exception { + // Creates file + final File file = new File(getTestDirectory(), getName()); + file.deleteOnExit(); + + // Loads resource + final String resourceName = "/java/lang/Object.class"; + FileUtils.copyURLToFile(getClass().getResource(resourceName), file); + + // Tests that resuorce was copied correctly + final FileInputStream fis = new FileInputStream(file); + try { + assertTrue( + "Content is not equal.", + IOUtils.contentEquals( + getClass().getResourceAsStream(resourceName), + fis)); + } finally { + fis.close(); + } + //TODO Maybe test copy to itself like for copyFile() + } + + @Test + public void testCopyURLToFileWithTimeout() throws Exception { + // Creates file + final File file = new File(getTestDirectory(), "testCopyURLToFileWithTimeout"); + file.deleteOnExit(); + + // Loads resource + final String resourceName = "/java/lang/Object.class"; + FileUtils.copyURLToFile(getClass().getResource(resourceName), file, 500, 500); + + // Tests that resuorce was copied correctly + final FileInputStream fis = new FileInputStream(file); + try { + assertTrue( + "Content is not equal.", + IOUtils.contentEquals( + getClass().getResourceAsStream(resourceName), + fis)); + } finally { + fis.close(); + } + //TODO Maybe test copy to itself like for copyFile() + } + + // forceMkdir + + @Test + public void testForceMkdir() throws Exception { + // Tests with existing directory + FileUtils.forceMkdir(getTestDirectory()); + + // Creates test file + final File testFile = new File(getTestDirectory(), getName()); + testFile.deleteOnExit(); + testFile.createNewFile(); + assertTrue("Test file does not exist.", testFile.exists()); + + // Tests with existing file + try { + FileUtils.forceMkdir(testFile); + fail("Exception expected."); + } catch (final IOException ignore) { + } + + testFile.delete(); + + // Tests with non-existent directory + FileUtils.forceMkdir(testFile); + assertTrue("Directory was not created.", testFile.exists()); + } + + @Test + public void testForceMkdirParent() throws Exception { + // Tests with existing directory + assertTrue(getTestDirectory().exists()); + final File testParentDir = new File(getTestDirectory(), "testForceMkdirParent"); + try { + testParentDir.delete(); + assertFalse(testParentDir.exists()); + final File testFile = new File(testParentDir, "test.txt"); + assertFalse(testParentDir.exists()); + assertFalse(testFile.exists()); + // Create + FileUtils.forceMkdirParent(testFile); + assertTrue(testParentDir.exists()); + assertFalse(testFile.exists()); + // Again + FileUtils.forceMkdirParent(testFile); + assertTrue(testParentDir.exists()); + assertFalse(testFile.exists()); + } finally { + testParentDir.delete(); + } + } + + // sizeOfDirectory + + @Test + public void testSizeOfDirectory() throws Exception { + final File file = new File(getTestDirectory(), getName()); + + // Non-existent file + try { + FileUtils.sizeOfDirectory(file); + fail("Exception expected."); + } catch (final IllegalArgumentException ignore) { + } + + // Creates file + file.createNewFile(); + file.deleteOnExit(); + + // Existing file + try { + FileUtils.sizeOfDirectory(file); + fail("Exception expected."); + } catch (final IllegalArgumentException ignore) { + } + + // Existing directory + file.delete(); + file.mkdir(); + + // Create a cyclic symlink + this.createCircularSymLink(file); + + assertEquals( + "Unexpected directory size", + TEST_DIRECTORY_SIZE, + FileUtils.sizeOfDirectory(file)); + } + + private void createCircularSymLink(final File file) throws IOException { + if (!FilenameUtils.isSystemWindows()) { + Runtime.getRuntime() + .exec("ln -s " + file + "/.. " + file + "/cycle"); + } else { + try { + Runtime.getRuntime() + .exec("mklink /D " + file + "/cycle" + file + "/.. "); + } catch (final IOException ioe) { // So that tests run in FAT filesystems + //don't fail + } + } + } + + @Test + public void testSizeOfDirectoryAsBigInteger() throws Exception { + final File file = new File(getTestDirectory(), getName()); + + // Non-existent file + try { + FileUtils.sizeOfDirectoryAsBigInteger(file); + fail("Exception expected."); + } catch (final IllegalArgumentException ignore) { + } + + // Creates file + file.createNewFile(); + file.deleteOnExit(); + + // Existing file + try { + FileUtils.sizeOfDirectoryAsBigInteger(file); + fail("Exception expected."); + } catch (final IllegalArgumentException ignore) { + } + + // Existing directory + file.delete(); + file.mkdir(); + + this.createCircularSymLink(file); + + assertEquals("Unexpected directory size", TEST_DIRECTORY_SIZE_BI, FileUtils.sizeOfDirectoryAsBigInteger(file)); + + // Existing directory which size is greater than zero + file.delete(); + file.mkdir(); + + final File nonEmptyFile = new File(file, "nonEmptyFile" + System.nanoTime()); + if (!nonEmptyFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + nonEmptyFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(nonEmptyFile)); + try { + TestUtils.generateTestData(output, TEST_DIRECTORY_SIZE_GT_ZERO_BI.longValue()); + } finally { + IOUtils.closeQuietly(output); + } + nonEmptyFile.deleteOnExit(); + + assertEquals("Unexpected directory size", TEST_DIRECTORY_SIZE_GT_ZERO_BI, + FileUtils.sizeOfDirectoryAsBigInteger(file)); + + nonEmptyFile.delete(); + file.delete(); + } + + // Compare sizes of a directory tree using long and BigInteger methods + @Test + public void testCompareSizeOf() { + final File start = new File("src/test/java"); + final long sizeLong1 = FileUtils.sizeOf(start); + final BigInteger sizeBig = FileUtils.sizeOfAsBigInteger(start); + final long sizeLong2 = FileUtils.sizeOf(start); + assertEquals("Size should not change", sizeLong1, sizeLong2); + assertEquals("longSize should equal BigSize", sizeLong1, sizeBig.longValue()); + } + + @Test + public void testSizeOf() throws Exception { + final File file = new File(getTestDirectory(), getName()); + + // Null argument + try { + FileUtils.sizeOf(null); + fail("Exception expected."); + } catch (final NullPointerException ignore) { + } + + // Non-existent file + try { + FileUtils.sizeOf(file); + fail("Exception expected."); + } catch (final IllegalArgumentException ignore) { + } + + // Creates file + file.createNewFile(); + file.deleteOnExit(); + + // New file + assertEquals(0, FileUtils.sizeOf(file)); + file.delete(); + + // Existing file + assertEquals("Unexpected files size", + testFile1Size, + FileUtils.sizeOf(testFile1)); + + // Existing directory + assertEquals("Unexpected directory size", + TEST_DIRECTORY_SIZE, + FileUtils.sizeOf(getTestDirectory())); + } + + @Test + public void testSizeOfAsBigInteger() throws Exception { + final File file = new File(getTestDirectory(), getName()); + + // Null argument + try { + FileUtils.sizeOfAsBigInteger(null); + fail("Exception expected."); + } catch (final NullPointerException ignore) { + } + + // Non-existent file + try { + FileUtils.sizeOfAsBigInteger(file); + fail("Exception expected."); + } catch (final IllegalArgumentException ignore) { + } + + // Creates file + file.createNewFile(); + file.deleteOnExit(); + + // New file + assertEquals(BigInteger.ZERO, FileUtils.sizeOfAsBigInteger(file)); + file.delete(); + + // Existing file + assertEquals("Unexpected files size", + BigInteger.valueOf(testFile1Size), + FileUtils.sizeOfAsBigInteger(testFile1)); + + // Existing directory + assertEquals("Unexpected directory size", + TEST_DIRECTORY_SIZE_BI, + FileUtils.sizeOfAsBigInteger(getTestDirectory())); + } + + // isFileNewer / isFileOlder + @Test + public void testIsFileNewerOlder() throws Exception { + final File reference = new File(getTestDirectory(), "FileUtils-reference.txt"); + final File oldFile = new File(getTestDirectory(), "FileUtils-old.txt"); + final File newFile = new File(getTestDirectory(), "FileUtils-new.txt"); + final File invalidFile = new File(getTestDirectory(), "FileUtils-invalid-file.txt"); + + // Create Files + if (!oldFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + oldFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(oldFile)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + + do { + try { + TestUtils.sleep(1000); + } catch (final InterruptedException ie) { + // ignore + } + if (!reference.getParentFile().exists()) { + throw new IOException("Cannot create file " + reference + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(reference)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + } while (oldFile.lastModified() == reference.lastModified()); + + final Date date = new Date(); + final long now = date.getTime(); + + do { + try { + TestUtils.sleep(1000); + } catch (final InterruptedException ie) { + // ignore + } + if (!newFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + newFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(newFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + } while (reference.lastModified() == newFile.lastModified()); + + // Test isFileNewer() + assertFalse("Old File - Newer - File", FileUtils.isFileNewer(oldFile, reference)); + assertFalse("Old File - Newer - Date", FileUtils.isFileNewer(oldFile, date)); + assertFalse("Old File - Newer - Mili", FileUtils.isFileNewer(oldFile, now)); + assertTrue("New File - Newer - File", FileUtils.isFileNewer(newFile, reference)); + assertTrue("New File - Newer - Date", FileUtils.isFileNewer(newFile, date)); + assertTrue("New File - Newer - Mili", FileUtils.isFileNewer(newFile, now)); + assertFalse("Invalid - Newer - File", FileUtils.isFileNewer(invalidFile, reference)); + final String invalidFileName = invalidFile.getName(); + try { + FileUtils.isFileNewer(newFile, invalidFile); + fail("Should have cause IllegalArgumentException"); + } catch (final IllegalArgumentException iae) { + final String message = iae.getMessage(); + assertTrue("Message should contain: " + invalidFileName + " but was: " + message, message.contains(invalidFileName)); + } + + // Test isFileOlder() + assertTrue("Old File - Older - File", FileUtils.isFileOlder(oldFile, reference)); + assertTrue("Old File - Older - Date", FileUtils.isFileOlder(oldFile, date)); + assertTrue("Old File - Older - Mili", FileUtils.isFileOlder(oldFile, now)); + assertFalse("New File - Older - File", FileUtils.isFileOlder(newFile, reference)); + assertFalse("New File - Older - Date", FileUtils.isFileOlder(newFile, date)); + assertFalse("New File - Older - Mili", FileUtils.isFileOlder(newFile, now)); + assertFalse("Invalid - Older - File", FileUtils.isFileOlder(invalidFile, reference)); + try { + FileUtils.isFileOlder(newFile, invalidFile); + fail("Should have cause IllegalArgumentException"); + } catch (final IllegalArgumentException iae) { + final String message = iae.getMessage(); + assertTrue("Message should contain: " + invalidFileName + " but was: " + message, message.contains(invalidFileName)); + } + + + // ----- Test isFileNewer() exceptions ----- + // Null File + try { + FileUtils.isFileNewer(null, now); + fail("Newer Null, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException expected) { + // expected result + } + + // Null reference File + try { + FileUtils.isFileNewer(oldFile, (File) null); + fail("Newer Null reference, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException ignore) { + // expected result + } + + // Invalid reference File + try { + FileUtils.isFileNewer(oldFile, invalidFile); + fail("Newer invalid reference, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException ignore) { + // expected result + } + + // Null reference Date + try { + FileUtils.isFileNewer(oldFile, (Date) null); + fail("Newer Null date, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException ignore) { + // expected result + } + + + // ----- Test isFileOlder() exceptions ----- + // Null File + try { + FileUtils.isFileOlder(null, now); + fail("Older Null, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException ignore) { + // expected result + } + + // Null reference File + try { + FileUtils.isFileOlder(oldFile, (File) null); + fail("Older Null reference, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException ignore) { + // expected result + } + + // Invalid reference File + try { + FileUtils.isFileOlder(oldFile, invalidFile); + fail("Older invalid reference, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException ignore) { + // expected result + } + + // Null reference Date + try { + FileUtils.isFileOlder(oldFile, (Date) null); + fail("Older Null date, expected IllegalArgumentExcepion"); + } catch (final IllegalArgumentException ignore) { + // expected result + } + + } + + // copyFile + + @Test + public void testCopyFile1() throws Exception { + final File destination = new File(getTestDirectory(), "copy1.txt"); + + //Thread.sleep(LAST_MODIFIED_DELAY); + //This is to slow things down so we can catch if + //the lastModified date is not ok + + FileUtils.copyFile(testFile1, destination); + assertTrue("Check Exist", destination.exists()); + assertEquals("Check Full copy", testFile1Size, destination.length()); + /* disabled: Thread.sleep doesn't work reliantly for this case + assertTrue("Check last modified date preserved", + testFile1.lastModified() == destination.lastModified());*/ + } + + @Test + public void testCopyFileToOutputStream() throws Exception { + final ByteArrayOutputStream destination = new ByteArrayOutputStream(); + FileUtils.copyFile(testFile1, destination); + assertEquals("Check Full copy size", testFile1Size, destination.size()); + final byte[] expected = FileUtils.readFileToByteArray(testFile1); + Assert.assertArrayEquals("Check Full copy", expected, destination.toByteArray()); + } + + @Test + @Ignore + public void testCopyFileLarge() throws Exception { + + final File largeFile = new File(getTestDirectory(), "large.txt"); + final File destination = new File(getTestDirectory(), "copylarge.txt"); + + System.out.println("START: " + new java.util.Date()); + if (!largeFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + largeFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(largeFile)); + try { + TestUtils.generateTestData(output, FileUtils.ONE_GB); + } finally { + IOUtils.closeQuietly(output); + } + System.out.println("CREATED: " + new java.util.Date()); + FileUtils.copyFile(largeFile, destination); + System.out.println("COPIED: " + new java.util.Date()); + + assertTrue("Check Exist", destination.exists()); + assertEquals("Check Full copy", largeFile.length(), destination.length()); + } + + @Test + public void testCopyFile2() throws Exception { + final File destination = new File(getTestDirectory(), "copy2.txt"); + + //Thread.sleep(LAST_MODIFIED_DELAY); + //This is to slow things down so we can catch if + //the lastModified date is not ok + + FileUtils.copyFile(testFile1, destination); + assertTrue("Check Exist", destination.exists()); + assertEquals("Check Full copy", testFile2Size, destination.length()); + /* disabled: Thread.sleep doesn't work reliably for this case + assertTrue("Check last modified date preserved", + testFile1.lastModified() == destination.lastModified());*/ + } + + @Test + public void testCopyToSelf() throws Exception { + final File destination = new File(getTestDirectory(), "copy3.txt"); + //Prepare a test file + FileUtils.copyFile(testFile1, destination); + + try { + FileUtils.copyFile(destination, destination); + fail("file copy to self should not be possible"); + } catch (final IOException ioe) { + //we want the exception, copy to self should be illegal + } + } + + @Test + public void testCopyFile2WithoutFileDatePreservation() throws Exception { + final File destination = new File(getTestDirectory(), "copy2.txt"); + + //Thread.sleep(LAST_MODIFIED_DELAY); + //This is to slow things down so we can catch if + //the lastModified date is not ok + + FileUtils.copyFile(testFile1, destination, false); + assertTrue("Check Exist", destination.exists()); + assertEquals("Check Full copy", testFile2Size, destination.length()); + /* disabled: Thread.sleep doesn't work reliantly for this case + assertTrue("Check last modified date modified", + testFile1.lastModified() != destination.lastModified());*/ + } + + @Test + public void testCopyDirectoryToDirectory_NonExistingDest() throws Exception { + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output1, (long) 1234); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output, (long) 4321); + } finally { + IOUtils.closeQuietly(output); + } + final File srcDir = getTestDirectory(); + final File subDir = new File(srcDir, "sub"); + subDir.mkdir(); + final File subFile = new File(subDir, "A.txt"); + FileUtils.writeStringToFile(subFile, "HELLO WORLD", "UTF8"); + final File destDir = new File(System.getProperty("java.io.tmpdir"), "tmp-FileUtilsTestCase"); + FileUtils.deleteDirectory(destDir); + final File actualDestDir = new File(destDir, srcDir.getName()); + + FileUtils.copyDirectoryToDirectory(srcDir, destDir); + + assertTrue("Check exists", destDir.exists()); + assertTrue("Check exists", actualDestDir.exists()); + final long srcSize = FileUtils.sizeOfDirectory(srcDir); + assertTrue("Size > 0", srcSize > 0); + assertEquals("Check size", srcSize, FileUtils.sizeOfDirectory(actualDestDir)); + assertTrue(new File(actualDestDir, "sub/A.txt").exists()); + FileUtils.deleteDirectory(destDir); + } + + @Test + public void testCopyDirectoryToNonExistingDest() throws Exception { + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output1, (long) 1234); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output, (long) 4321); + } finally { + IOUtils.closeQuietly(output); + } + final File srcDir = getTestDirectory(); + final File subDir = new File(srcDir, "sub"); + subDir.mkdir(); + final File subFile = new File(subDir, "A.txt"); + FileUtils.writeStringToFile(subFile, "HELLO WORLD", "UTF8"); + final File destDir = new File(System.getProperty("java.io.tmpdir"), "tmp-FileUtilsTestCase"); + FileUtils.deleteDirectory(destDir); + + FileUtils.copyDirectory(srcDir, destDir); + + assertTrue("Check exists", destDir.exists()); + final long sizeOfSrcDirectory = FileUtils.sizeOfDirectory(srcDir); + assertTrue("Size > 0", sizeOfSrcDirectory > 0); + assertEquals("Check size", sizeOfSrcDirectory, FileUtils.sizeOfDirectory(destDir)); + assertTrue(new File(destDir, "sub/A.txt").exists()); + FileUtils.deleteDirectory(destDir); + } + + @Test + public void testCopyDirectoryToExistingDest() throws Exception { + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output1, (long) 1234); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output, (long) 4321); + } finally { + IOUtils.closeQuietly(output); + } + final File srcDir = getTestDirectory(); + final File subDir = new File(srcDir, "sub"); + subDir.mkdir(); + final File subFile = new File(subDir, "A.txt"); + FileUtils.writeStringToFile(subFile, "HELLO WORLD", "UTF8"); + final File destDir = new File(System.getProperty("java.io.tmpdir"), "tmp-FileUtilsTestCase"); + FileUtils.deleteDirectory(destDir); + destDir.mkdirs(); + + FileUtils.copyDirectory(srcDir, destDir); + + final long srcSize = FileUtils.sizeOfDirectory(srcDir); + assertTrue("Size > 0", srcSize > 0); + assertEquals(srcSize, FileUtils.sizeOfDirectory(destDir)); + assertTrue(new File(destDir, "sub/A.txt").exists()); + } + + @Test + public void testCopyDirectoryFiltered() throws Exception { + final File grandParentDir = new File(getTestDirectory(), "grandparent"); + final File parentDir = new File(grandParentDir, "parent"); + final File childDir = new File(parentDir, "child"); + createFilesForTestCopyDirectory(grandParentDir, parentDir, childDir); + + final NameFileFilter filter = new NameFileFilter(new String[]{"parent", "child", "file3.txt"}); + final File destDir = new File(getTestDirectory(), "copydest"); + + FileUtils.copyDirectory(grandParentDir, destDir, filter); + final List files = LIST_WALKER.list(destDir); + assertEquals(3, files.size()); + assertEquals("parent", files.get(0).getName()); + assertEquals("child", files.get(1).getName()); + assertEquals("file3.txt", files.get(2).getName()); + } + + @Test + public void testCopyDirectoryPreserveDates() throws Exception { + final File source = new File(getTestDirectory(), "source"); + final File sourceDirectory = new File(source, "directory"); + final File sourceFile = new File(sourceDirectory, "hello.txt"); + + // Prepare source data + source.mkdirs(); + sourceDirectory.mkdir(); + FileUtils.writeStringToFile(sourceFile, "HELLO WORLD", "UTF8"); + // Set dates in reverse order to avoid overwriting previous values + // Also, use full seconds (arguments are in ms) close to today + // but still highly unlikely to occur in the real world + sourceFile.setLastModified(1000000002000L); + sourceDirectory.setLastModified(1000000001000L); + source.setLastModified(1000000000000L); + + final File target = new File(getTestDirectory(), "target"); + final File targetDirectory = new File(target, "directory"); + final File targetFile = new File(targetDirectory, "hello.txt"); + + // Test with preserveFileDate disabled + FileUtils.copyDirectory(source, target, false); + assertTrue(1000000000000L != target.lastModified()); + assertTrue(1000000001000L != targetDirectory.lastModified()); + assertTrue(1000000002000L != targetFile.lastModified()); + FileUtils.deleteDirectory(target); + + // Test with preserveFileDate enabled + FileUtils.copyDirectory(source, target, true); + assertEquals(1000000000000L, target.lastModified()); + assertEquals(1000000001000L, targetDirectory.lastModified()); + assertEquals(1000000002000L, targetFile.lastModified()); + FileUtils.deleteDirectory(target); + + // also if the target directory already exists (IO-190) + target.mkdirs(); + FileUtils.copyDirectory(source, target, true); + assertEquals(1000000000000L, target.lastModified()); + assertEquals(1000000001000L, targetDirectory.lastModified()); + assertEquals(1000000002000L, targetFile.lastModified()); + FileUtils.deleteDirectory(target); + + // also if the target subdirectory already exists (IO-190) + targetDirectory.mkdirs(); + FileUtils.copyDirectory(source, target, true); + assertEquals(1000000000000L, target.lastModified()); + assertEquals(1000000001000L, targetDirectory.lastModified()); + assertEquals(1000000002000L, targetFile.lastModified()); + FileUtils.deleteDirectory(target); + } + + /* Test for IO-141 */ + @Test + public void testCopyDirectoryToChild() throws Exception { + final File grandParentDir = new File(getTestDirectory(), "grandparent"); + final File parentDir = new File(grandParentDir, "parent"); + final File childDir = new File(parentDir, "child"); + createFilesForTestCopyDirectory(grandParentDir, parentDir, childDir); + + final long expectedCount = LIST_WALKER.list(grandParentDir).size() + + LIST_WALKER.list(parentDir).size(); + final long expectedSize = FileUtils.sizeOfDirectory(grandParentDir) + + FileUtils.sizeOfDirectory(parentDir); + FileUtils.copyDirectory(parentDir, childDir); + assertEquals(expectedCount, LIST_WALKER.list(grandParentDir).size()); + assertEquals(expectedSize, FileUtils.sizeOfDirectory(grandParentDir)); + assertTrue("Count > 0", expectedCount > 0); + assertTrue("Size > 0", expectedSize > 0); + } + + /* Test for IO-141 */ + @Test + public void testCopyDirectoryToGrandChild() throws Exception { + final File grandParentDir = new File(getTestDirectory(), "grandparent"); + final File parentDir = new File(grandParentDir, "parent"); + final File childDir = new File(parentDir, "child"); + createFilesForTestCopyDirectory(grandParentDir, parentDir, childDir); + + final long expectedCount = LIST_WALKER.list(grandParentDir).size() * 2; + final long expectedSize = FileUtils.sizeOfDirectory(grandParentDir) * 2; + FileUtils.copyDirectory(grandParentDir, childDir); + assertEquals(expectedCount, LIST_WALKER.list(grandParentDir).size()); + assertEquals(expectedSize, FileUtils.sizeOfDirectory(grandParentDir)); + assertTrue("Size > 0", expectedSize > 0); + } + + /* Test for IO-217 FileUtils.copyDirectoryToDirectory makes infinite loops */ + @Test + public void testCopyDirectoryToItself() throws Exception { + final File dir = new File(getTestDirectory(), "itself"); + dir.mkdirs(); + FileUtils.copyDirectoryToDirectory(dir, dir); + assertEquals(1, LIST_WALKER.list(dir).size()); + } + + private void createFilesForTestCopyDirectory(final File grandParentDir, final File parentDir, final File childDir) throws Exception { + final File childDir2 = new File(parentDir, "child2"); + final File grandChildDir = new File(childDir, "grandChild"); + final File grandChild2Dir = new File(childDir2, "grandChild2"); + final File file1 = new File(grandParentDir, "file1.txt"); + final File file2 = new File(parentDir, "file2.txt"); + final File file3 = new File(childDir, "file3.txt"); + final File file4 = new File(childDir2, "file4.txt"); + final File file5 = new File(grandChildDir, "file5.txt"); + final File file6 = new File(grandChild2Dir, "file6.txt"); + FileUtils.deleteDirectory(grandParentDir); + grandChildDir.mkdirs(); + grandChild2Dir.mkdirs(); + FileUtils.writeStringToFile(file1, "File 1 in grandparent", "UTF8"); + FileUtils.writeStringToFile(file2, "File 2 in parent", "UTF8"); + FileUtils.writeStringToFile(file3, "File 3 in child", "UTF8"); + FileUtils.writeStringToFile(file4, "File 4 in child2", "UTF8"); + FileUtils.writeStringToFile(file5, "File 5 in grandChild", "UTF8"); + FileUtils.writeStringToFile(file6, "File 6 in grandChild2", "UTF8"); + } + + @Test + public void testCopyDirectoryErrors() throws Exception { + try { + FileUtils.copyDirectory(null, null); + fail(); + } catch (final NullPointerException ignore) { + } + try { + FileUtils.copyDirectory(new File("a"), null); + fail(); + } catch (final NullPointerException ignore) { + } + try { + FileUtils.copyDirectory(null, new File("a")); + fail(); + } catch (final NullPointerException ignore) { + } + try { + FileUtils.copyDirectory(new File("doesnt-exist"), new File("a")); + fail(); + } catch (final IOException ignore) { + } + try { + FileUtils.copyDirectory(testFile1, new File("a")); + fail(); + } catch (final IOException ignore) { + } + try { + FileUtils.copyDirectory(getTestDirectory(), testFile1); + fail(); + } catch (final IOException ignore) { + } + try { + FileUtils.copyDirectory(getTestDirectory(), getTestDirectory()); + fail(); + } catch (final IOException ignore) { + } + } + + // forceDelete + + @Test + public void testForceDeleteAFile1() throws Exception { + final File destination = new File(getTestDirectory(), "copy1.txt"); + destination.createNewFile(); + assertTrue("Copy1.txt doesn't exist to delete", destination.exists()); + FileUtils.forceDelete(destination); + assertTrue("Check No Exist", !destination.exists()); + } + + @Test + public void testForceDeleteAFile2() throws Exception { + final File destination = new File(getTestDirectory(), "copy2.txt"); + destination.createNewFile(); + assertTrue("Copy2.txt doesn't exist to delete", destination.exists()); + FileUtils.forceDelete(destination); + assertTrue("Check No Exist", !destination.exists()); + } + + @Test + public void testForceDeleteAFile3() throws Exception { + final File destination = new File(getTestDirectory(), "no_such_file"); + assertTrue("Check No Exist", !destination.exists()); + try { + FileUtils.forceDelete(destination); + fail("Should generate FileNotFoundException"); + } catch (final FileNotFoundException ignored) { + } + } + + // copyFileToDirectory + + @Test + public void testCopyFile1ToDir() throws Exception { + final File directory = new File(getTestDirectory(), "subdir"); + if (!directory.exists()) { + directory.mkdirs(); + } + final File destination = new File(directory, testFile1.getName()); + + //Thread.sleep(LAST_MODIFIED_DELAY); + //This is to slow things down so we can catch if + //the lastModified date is not ok + + FileUtils.copyFileToDirectory(testFile1, directory); + assertTrue("Check Exist", destination.exists()); + assertEquals("Check Full copy", testFile1Size, destination.length()); + /* disabled: Thread.sleep doesn't work reliantly for this case + assertTrue("Check last modified date preserved", + testFile1.lastModified() == destination.lastModified());*/ + + try { + FileUtils.copyFileToDirectory(destination, directory); + fail("Should not be able to copy a file into the same directory as itself"); + } catch (final IOException ioe) { + //we want that, cannot copy to the same directory as the original file + } + } + + @Test + public void testCopyFile2ToDir() throws Exception { + final File directory = new File(getTestDirectory(), "subdir"); + if (!directory.exists()) { + directory.mkdirs(); + } + final File destination = new File(directory, testFile1.getName()); + + //Thread.sleep(LAST_MODIFIED_DELAY); + //This is to slow things down so we can catch if + //the lastModified date is not ok + + FileUtils.copyFileToDirectory(testFile1, directory); + assertTrue("Check Exist", destination.exists()); + assertEquals("Check Full copy", testFile2Size, destination.length()); + /* disabled: Thread.sleep doesn't work reliantly for this case + assertTrue("Check last modified date preserved", + testFile1.lastModified() == destination.lastModified());*/ + } + + // forceDelete + + @Test + public void testForceDeleteDir() throws Exception { + final File testDirectory = getTestDirectory(); + FileUtils.forceDelete(testDirectory.getParentFile()); + assertTrue( + "Check No Exist", + !testDirectory.getParentFile().exists()); + } + + /* + * Test the FileUtils implementation. + */ + @Test + public void testFileUtils() throws Exception { + // Loads file from classpath + final File file1 = new File(getTestDirectory(), "test.txt"); + final String filename = file1.getAbsolutePath(); + + //Create test file on-the-fly (used to be in CVS) + final OutputStream out = new java.io.FileOutputStream(file1); + try { + out.write("This is a test".getBytes("UTF-8")); + } finally { + out.close(); + } + + final File file2 = new File(getTestDirectory(), "test2.txt"); + + FileUtils.writeStringToFile(file2, filename, "UTF-8"); + assertTrue(file2.exists()); + assertTrue(file2.length() > 0); + + final String file2contents = FileUtils.readFileToString(file2, "UTF-8"); + assertTrue( + "Second file's contents correct", + filename.equals(file2contents)); + + assertTrue(file2.delete()); + + final String contents = FileUtils.readFileToString(new File(filename), "UTF-8"); + assertEquals("FileUtils.fileRead()", "This is a test", contents); + + } + + @Test + public void testTouch() throws IOException { + final File file = new File(getTestDirectory(), "touch.txt"); + if (file.exists()) { + file.delete(); + } + assertTrue("Bad test: test file still exists", !file.exists()); + FileUtils.touch(file); + assertTrue("FileUtils.touch() created file", file.exists()); + final FileOutputStream out = new FileOutputStream(file); + assertEquals("Created empty file.", 0, file.length()); + out.write(0); + out.close(); + assertEquals("Wrote one byte to file", 1, file.length()); + final long y2k = new GregorianCalendar(2000, 0, 1).getTime().getTime(); + final boolean res = file.setLastModified(y2k); // 0L fails on Win98 + assertEquals("Bad test: set lastModified failed", true, res); + assertEquals("Bad test: set lastModified set incorrect value", y2k, file.lastModified()); + final long now = System.currentTimeMillis(); + FileUtils.touch(file); + assertEquals("FileUtils.touch() didn't empty the file.", 1, file.length()); + assertEquals("FileUtils.touch() changed lastModified", false, y2k == file.lastModified()); + assertEquals("FileUtils.touch() changed lastModified to more than now-3s", true, file.lastModified() >= now - 3000); + assertEquals("FileUtils.touch() changed lastModified to less than now+3s", true, file.lastModified() <= now + 3000); + } + + @Test + public void testListFiles() throws Exception { + final File srcDir = getTestDirectory(); + final File subDir = new File(srcDir, "list_test"); + subDir.mkdir(); + + final File subDir2 = new File(subDir, "subdir"); + subDir2.mkdir(); + + final String[] fileNames = {"a.txt", "b.txt", "c.txt", "d.txt", "e.txt", "f.txt"}; + final int[] fileSizes = {123, 234, 345, 456, 678, 789}; + + for (int i = 0; i < fileNames.length; ++i) { + final File theFile = new File(subDir, fileNames[i]); + if (!theFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + theFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(theFile)); + try { + TestUtils.generateTestData(output, (long) fileSizes[i]); + } finally { + IOUtils.closeQuietly(output); + } + } + + final Collection files = FileUtils.listFiles(subDir, + new WildcardFileFilter("*.*"), + new WildcardFileFilter("*")); + + final int count = files.size(); + final Object[] fileObjs = files.toArray(); + + assertEquals(fileNames.length, files.size()); + + final Map foundFileNames = new HashMap(); + + for (int i = 0; i < count; ++i) { + boolean found = false; + for (int j = 0; !found && j < fileNames.length; ++j) { + if (fileNames[j].equals(((File) fileObjs[i]).getName())) { + foundFileNames.put(fileNames[j], fileNames[j]); + found = true; + } + } + } + + assertEquals(foundFileNames.size(), fileNames.length); + + subDir.delete(); + } + + @Test + public void testListFilesWithDirs() throws IOException { + final File srcDir = getTestDirectory(); + + final File subDir1 = new File(srcDir, "subdir"); + subDir1.mkdir(); + + final File subDir2 = new File(subDir1, "subdir2"); + subDir2.mkdir(); + + final File someFile = new File(subDir2, "a.txt"); + if (!someFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + someFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(someFile)); + try { + TestUtils.generateTestData(output, (long) 100); + } finally { + IOUtils.closeQuietly(output); + } + + final File subDir3 = new File(subDir2, "subdir3"); + subDir3.mkdir(); + + final Collection files = FileUtils.listFilesAndDirs(subDir1, + new WildcardFileFilter("*.*"), new WildcardFileFilter("*")); + + assertEquals(4, files.size()); + assertTrue("Should contain the directory.", files.contains(subDir1)); + assertTrue("Should contain the directory.", files.contains(subDir2)); + assertTrue("Should contain the file.", files.contains(someFile)); + assertTrue("Should contain the directory.", files.contains(subDir3)); + + subDir1.delete(); + } + + @Test + public void testIterateFiles() throws Exception { + final File srcDir = getTestDirectory(); + final File subDir = new File(srcDir, "list_test"); + subDir.mkdir(); + + final String[] fileNames = {"a.txt", "b.txt", "c.txt", "d.txt", "e.txt", "f.txt"}; + final int[] fileSizes = {123, 234, 345, 456, 678, 789}; + + for (int i = 0; i < fileNames.length; ++i) { + final File theFile = new File(subDir, fileNames[i]); + if (!theFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + theFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(theFile)); + try { + TestUtils.generateTestData(output, (long) fileSizes[i]); + } finally { + IOUtils.closeQuietly(output); + } + } + + final Iterator files = FileUtils.iterateFiles(subDir, + new WildcardFileFilter("*.*"), + new WildcardFileFilter("*")); + + final Map foundFileNames = new HashMap(); + + while (files.hasNext()) { + boolean found = false; + final String fileName = files.next().getName(); + + for (int j = 0; !found && j < fileNames.length; ++j) { + if (fileNames[j].equals(fileName)) { + foundFileNames.put(fileNames[j], fileNames[j]); + found = true; + } + } + } + + assertEquals(foundFileNames.size(), fileNames.length); + + subDir.delete(); + } + + @Test + public void testIterateFilesAndDirs() throws IOException { + final File srcDir = getTestDirectory(); + + final File subDir1 = new File(srcDir, "subdir"); + subDir1.mkdir(); + + final File subDir2 = new File(subDir1, "subdir2"); + subDir2.mkdir(); + + final File someFile = new File(subDir2, "a.txt"); + if (!someFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + someFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(someFile)); + try { + TestUtils.generateTestData(output, (long) 100); + } finally { + IOUtils.closeQuietly(output); + } + + final File subDir3 = new File(subDir2, "subdir3"); + subDir3.mkdir(); + + final Collection filesAndDirs = Arrays.asList(subDir1, subDir2, someFile, subDir3); + + int filesCount = 0; + final Iterator files = FileUtils.iterateFilesAndDirs(subDir1, + new WildcardFileFilter("*.*"), + new WildcardFileFilter("*")); + while (files.hasNext()) { + filesCount++; + final File file = files.next(); + assertTrue("Should contain the directory/file", filesAndDirs.contains(file)); + } + + assertEquals(filesCount, filesAndDirs.size()); + } + + @Test + public void testReadFileToStringWithDefaultEncoding() throws Exception { + final File file = new File(getTestDirectory(), "read.obj"); + final FileOutputStream out = new FileOutputStream(file); + final byte[] text = "Hello /u1234".getBytes(); + out.write(text); + out.close(); + + final String data = FileUtils.readFileToString(file); + assertEquals("Hello /u1234", data); + } + + @Test + public void testReadFileToStringWithEncoding() throws Exception { + final File file = new File(getTestDirectory(), "read.obj"); + final FileOutputStream out = new FileOutputStream(file); + final byte[] text = "Hello /u1234".getBytes("UTF8"); + out.write(text); + out.close(); + + final String data = FileUtils.readFileToString(file, "UTF8"); + assertEquals("Hello /u1234", data); + } + + @Test + public void testReadFileToByteArray() throws Exception { + final File file = new File(getTestDirectory(), "read.txt"); + final FileOutputStream out = new FileOutputStream(file); + out.write(11); + out.write(21); + out.write(31); + out.close(); + + final byte[] data = FileUtils.readFileToByteArray(file); + assertEquals(3, data.length); + assertEquals(11, data[0]); + assertEquals(21, data[1]); + assertEquals(31, data[2]); + } + + @Test + public void testReadLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + try { + final String[] data = new String[]{"hello", "/u1234", "", "this is", "some text"}; + TestUtils.createLineBasedFile(file, data); + + final List lines = FileUtils.readLines(file, "UTF-8"); + assertEquals(Arrays.asList(data), lines); + } finally { + TestUtils.deleteFile(file); + } + } + + @Test + public void testWriteStringToFile1() throws Exception { + final File file = new File(getTestDirectory(), "write.txt"); + FileUtils.writeStringToFile(file, "Hello /u1234", "UTF8"); + final byte[] text = "Hello /u1234".getBytes("UTF8"); + TestUtils.assertEqualContent(text, file); + } + + @Test + public void testWriteStringToFile2() throws Exception { + final File file = new File(getTestDirectory(), "write.txt"); + FileUtils.writeStringToFile(file, "Hello /u1234", (String) null); + final byte[] text = "Hello /u1234".getBytes(); + TestUtils.assertEqualContent(text, file); + } + + @Test + public void testWriteStringToFile3() throws Exception { + final File file = new File(getTestDirectory(), "write.txt"); + FileUtils.writeStringToFile(file, "Hello /u1234", (Charset) null); + final byte[] text = "Hello /u1234".getBytes(); + TestUtils.assertEqualContent(text, file); + } + + @Test + public void testWriteCharSequence1() throws Exception { + final File file = new File(getTestDirectory(), "write.txt"); + FileUtils.write(file, "Hello /u1234", "UTF8"); + final byte[] text = "Hello /u1234".getBytes("UTF8"); + TestUtils.assertEqualContent(text, file); + } + + @Test + public void testWriteCharSequence2() throws Exception { + final File file = new File(getTestDirectory(), "write.txt"); + FileUtils.write(file, "Hello /u1234", (String) null); + final byte[] text = "Hello /u1234".getBytes(); + TestUtils.assertEqualContent(text, file); + } + + @Test + public void testWriteByteArrayToFile() throws Exception { + final File file = new File(getTestDirectory(), "write.obj"); + final byte[] data = new byte[]{11, 21, 31}; + FileUtils.writeByteArrayToFile(file, data); + TestUtils.assertEqualContent(data, file); + } + + @Test + public void testWriteByteArrayToFile_WithOffsetAndLength() throws Exception { + final File file = new File(getTestDirectory(), "write.obj"); + final byte[] data = new byte[]{11, 21, 32, 41, 51}; + final byte[] writtenData = new byte[3]; + System.arraycopy(data, 1, writtenData, 0, 3); + FileUtils.writeByteArrayToFile(file, data, 1, 3); + TestUtils.assertEqualContent(writtenData, file); + } + + @Test + public void testWriteLines_4arg() throws Exception { + final Object[] data = new Object[]{ + "hello", new StringBuffer("world"), "", "this is", null, "some text"}; + final List list = Arrays.asList(data); + + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeLines(file, "US-ASCII", list, "*"); + + final String expected = "hello*world**this is**some text*"; + final String actual = FileUtils.readFileToString(file, "US-ASCII"); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_4arg_Writer_nullData() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeLines(file, "US-ASCII", null, "*"); + + assertEquals("Sizes differ", 0, file.length()); + } + + @Test + public void testWriteLines_4arg_nullSeparator() throws Exception { + final Object[] data = new Object[]{ + "hello", new StringBuffer("world"), "", "this is", null, "some text"}; + final List list = Arrays.asList(data); + + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeLines(file, "US-ASCII", list, null); + + final String expected = "hello" + IOUtils.LINE_SEPARATOR + "world" + IOUtils.LINE_SEPARATOR + + IOUtils.LINE_SEPARATOR + "this is" + IOUtils.LINE_SEPARATOR + + IOUtils.LINE_SEPARATOR + "some text" + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file, "US-ASCII"); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_3arg_nullSeparator() throws Exception { + final Object[] data = new Object[]{ + "hello", new StringBuffer("world"), "", "this is", null, "some text"}; + final List list = Arrays.asList(data); + + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeLines(file, "US-ASCII", list); + + final String expected = "hello" + IOUtils.LINE_SEPARATOR + "world" + IOUtils.LINE_SEPARATOR + + IOUtils.LINE_SEPARATOR + "this is" + IOUtils.LINE_SEPARATOR + + IOUtils.LINE_SEPARATOR + "some text" + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file, "US-ASCII"); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_5argsWithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, null, linesToAppend, null, true); + + final String expected = "This line was there before you..." + + "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_5argsWithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, null, linesToAppend, null, false); + + final String expected = "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_4argsWithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, linesToAppend, null, true); + + final String expected = "This line was there before you..." + + "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_4argsWithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, linesToAppend, null, false); + + final String expected = "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + + @Test + public void testWriteLinesEncoding_WithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, null, linesToAppend, true); + + final String expected = "This line was there before you..." + + "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteLinesEncoding_WithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, null, linesToAppend, false); + + final String expected = "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_3argsWithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, linesToAppend, true); + + final String expected = "This line was there before you..." + + "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_3argsWithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final List linesToAppend = Arrays.asList("my first line", "The second Line"); + FileUtils.writeLines(file, linesToAppend, false); + + final String expected = "my first line" + + IOUtils.LINE_SEPARATOR + "The second Line" + + IOUtils.LINE_SEPARATOR; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteStringToFileWithEncoding_WithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.writeStringToFile(file, "this is brand new data", (String) null, true); + + final String expected = "This line was there before you..." + + "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteStringToFileWithEncoding_WithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.writeStringToFile(file, "this is brand new data", (String) null, false); + + final String expected = "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteStringToFile_WithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.writeStringToFile(file, "this is brand new data", true); + + final String expected = "This line was there before you..." + + "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteStringToFile_WithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.writeStringToFile(file, "this is brand new data", false); + + final String expected = "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteWithEncoding_WithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.write(file, "this is brand new data", (String) null, true); + + final String expected = "This line was there before you..." + + "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteWithEncoding_WithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.write(file, "this is brand new data", (String) null, false); + + final String expected = "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWrite_WithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.write(file, "this is brand new data", true); + + final String expected = "This line was there before you..." + + "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWrite_WithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.write(file, "this is brand new data", false); + + final String expected = "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteByteArrayToFile_WithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.writeByteArrayToFile(file, "this is brand new data".getBytes(), true); + + final String expected = "This line was there before you..." + + "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteByteArrayToFile_WithAppendOptionFalse_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + FileUtils.writeByteArrayToFile(file, "this is brand new data".getBytes(), false); + + final String expected = "this is brand new data"; + final String actual = FileUtils.readFileToString(file); + assertEquals(expected, actual); + } + + @Test + public void testWriteByteArrayToFile_WithOffsetAndLength_WithAppendOptionTrue_ShouldNotDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final byte[] data = "SKIP_THIS_this is brand new data_AND_SKIP_THIS".getBytes(Charsets.UTF_8); + FileUtils.writeByteArrayToFile(file, data, 10, 22, true); + + final String expected = "This line was there before you..." + "this is brand new data"; + final String actual = FileUtils.readFileToString(file, Charsets.UTF_8); + assertEquals(expected, actual); + } + + @Test + public void testWriteByteArrayToFile_WithOffsetAndLength_WithAppendOptionTrue_ShouldDeletePreviousFileLines() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + FileUtils.writeStringToFile(file, "This line was there before you..."); + + final byte[] data = "SKIP_THIS_this is brand new data_AND_SKIP_THIS".getBytes(Charsets.UTF_8); + FileUtils.writeByteArrayToFile(file, data, 10, 22, false); + + final String expected = "this is brand new data"; + final String actual = FileUtils.readFileToString(file, Charsets.UTF_8); + assertEquals(expected, actual); + } + + //----------------------------------------------------------------------- + @Test + public void testChecksumCRC32() throws Exception { + // create a test file + final String text = "Imagination is more important than knowledge - Einstein"; + final File file = new File(getTestDirectory(), "checksum-test.txt"); + FileUtils.writeStringToFile(file, text, "US-ASCII"); + + // compute the expected checksum + final Checksum expectedChecksum = new CRC32(); + expectedChecksum.update(text.getBytes("US-ASCII"), 0, text.length()); + final long expectedValue = expectedChecksum.getValue(); + + // compute the checksum of the file + final long resultValue = FileUtils.checksumCRC32(file); + + assertEquals(expectedValue, resultValue); + } + + @Test + public void testChecksum() throws Exception { + // create a test file + final String text = "Imagination is more important than knowledge - Einstein"; + final File file = new File(getTestDirectory(), "checksum-test.txt"); + FileUtils.writeStringToFile(file, text, "US-ASCII"); + + // compute the expected checksum + final Checksum expectedChecksum = new CRC32(); + expectedChecksum.update(text.getBytes("US-ASCII"), 0, text.length()); + final long expectedValue = expectedChecksum.getValue(); + + // compute the checksum of the file + final Checksum testChecksum = new CRC32(); + final Checksum resultChecksum = FileUtils.checksum(file, testChecksum); + final long resultValue = resultChecksum.getValue(); + + assertSame(testChecksum, resultChecksum); + assertEquals(expectedValue, resultValue); + } + + @Test + public void testChecksumOnNullFile() throws Exception { + try { + FileUtils.checksum(null, new CRC32()); + fail(); + } catch (final NullPointerException ex) { + // expected + } + } + + @Test + public void testChecksumOnNullChecksum() throws Exception { + // create a test file + final String text = "Imagination is more important than knowledge - Einstein"; + final File file = new File(getTestDirectory(), "checksum-test.txt"); + FileUtils.writeStringToFile(file, text, "US-ASCII"); + try { + FileUtils.checksum(file, null); + fail(); + } catch (final NullPointerException ex) { + // expected + } + } + + @Test + public void testChecksumOnDirectory() throws Exception { + try { + FileUtils.checksum(new File("."), new CRC32()); + fail(); + } catch (final IllegalArgumentException ex) { + // expected + } + } + + @Test + public void testChecksumDouble() throws Exception { + // create a test file + final String text1 = "Imagination is more important than knowledge - Einstein"; + final File file1 = new File(getTestDirectory(), "checksum-test.txt"); + FileUtils.writeStringToFile(file1, text1, "US-ASCII"); + + // create a second test file + final String text2 = "To be or not to be - Shakespeare"; + final File file2 = new File(getTestDirectory(), "checksum-test2.txt"); + FileUtils.writeStringToFile(file2, text2, "US-ASCII"); + + // compute the expected checksum + final Checksum expectedChecksum = new CRC32(); + expectedChecksum.update(text1.getBytes("US-ASCII"), 0, text1.length()); + expectedChecksum.update(text2.getBytes("US-ASCII"), 0, text2.length()); + final long expectedValue = expectedChecksum.getValue(); + + // compute the checksum of the file + final Checksum testChecksum = new CRC32(); + FileUtils.checksum(file1, testChecksum); + FileUtils.checksum(file2, testChecksum); + final long resultValue = testChecksum.getValue(); + + assertEquals(expectedValue, resultValue); + } + + @Test + public void testDeleteDirectoryWithNonDirectory() throws Exception { + try { + FileUtils.deleteDirectory(testFile1); + fail(); + } catch (final IllegalArgumentException ex) { + // expected + } + } + + @Test + public void testDeleteQuietlyForNull() { + try { + FileUtils.deleteQuietly(null); + } catch (final Exception ex) { + fail(ex.getMessage()); + } + } + + @Test + public void testDeleteQuietlyDir() throws IOException { + final File testDirectory = new File(getTestDirectory(), "testDeleteQuietlyDir"); + final File testFile = new File(testDirectory, "testDeleteQuietlyFile"); + testDirectory.mkdirs(); + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + + assertTrue(testDirectory.exists()); + assertTrue(testFile.exists()); + FileUtils.deleteQuietly(testDirectory); + assertFalse("Check No Exist", testDirectory.exists()); + assertFalse("Check No Exist", testFile.exists()); + } + + @Test + public void testDeleteQuietlyFile() throws IOException { + final File testFile = new File(getTestDirectory(), "testDeleteQuietlyFile"); + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + + assertTrue(testFile.exists()); + FileUtils.deleteQuietly(testFile); + assertFalse("Check No Exist", testFile.exists()); + } + + @Test + public void testDeleteQuietlyNonExistent() { + final File testFile = new File("testDeleteQuietlyNonExistent"); + assertFalse(testFile.exists()); + + try { + FileUtils.deleteQuietly(testFile); + } catch (final Exception ex) { + fail(ex.getMessage()); + } + } + + @Test + public void testMoveFile_Rename() throws Exception { + final File destination = new File(getTestDirectory(), "move1.txt"); + + FileUtils.moveFile(testFile1, destination); + assertTrue("Check Exist", destination.exists()); + assertTrue("Original deleted", !testFile1.exists()); + } + + @Test + public void testMoveFile_CopyDelete() throws Exception { + final File destination = new File(getTestDirectory(), "move2.txt"); + final File src = new File(testFile1.getAbsolutePath()) { + private static final long serialVersionUID = 1L; + + // Force renameTo to fail, as if destination is on another + // filesystem + @Override + public boolean renameTo(final File f) { + return false; + } + }; + FileUtils.moveFile(src, destination); + assertTrue("Check Exist", destination.exists()); + assertTrue("Original deleted", !src.exists()); + } + + + @Test + public void testMoveFile_CopyDelete_Failed() throws Exception { + final File destination = new File(getTestDirectory(), "move3.txt"); + final File src = new File(testFile1.getAbsolutePath()) { + private static final long serialVersionUID = 1L; + + // Force renameTo to fail, as if destination is on another + // filesystem + @Override + public boolean renameTo(final File f) { + return false; + } + + // Force delete failure + @Override + public boolean delete() { + return false; + } + + }; + try { + FileUtils.moveFile(src, destination); + fail("move should have failed as src has not been deleted"); + } catch (final IOException e) { + // exepected + assertTrue("Check Rollback", !destination.exists()); + assertTrue("Original exists", src.exists()); + } + } + + @Test + public void testMoveFile_Errors() throws Exception { + try { + FileUtils.moveFile(null, new File("foo")); + fail("Expected NullPointerException when source is null"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.moveFile(new File("foo"), null); + fail("Expected NullPointerException when destination is null"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.moveFile(new File("nonexistant"), new File("foo")); + fail("Expected FileNotFoundException for source"); + } catch (final FileNotFoundException e) { + // expected + } + try { + FileUtils.moveFile(getTestDirectory(), new File("foo")); + fail("Expected IOException when source is a directory"); + } catch (final IOException e) { + // expected + } + final File testSourceFile = new File(getTestDirectory(), "testMoveFileSource"); + final File testDestFile = new File(getTestDirectory(), "testMoveFileSource"); + if (!testSourceFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testSourceFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testSourceFile)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testDestFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testDestFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testDestFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + try { + FileUtils.moveFile(testSourceFile, testDestFile); + fail("Expected FileExistsException when dest already exists"); + } catch (final FileExistsException e) { + // expected + } + + } + + @Test + public void testMoveFileToDirectory() throws Exception { + final File destDir = new File(getTestDirectory(), "moveFileDestDir"); + final File movedFile = new File(destDir, testFile1.getName()); + assertFalse("Check Exist before", destDir.exists()); + assertFalse("Check Exist before", movedFile.exists()); + + FileUtils.moveFileToDirectory(testFile1, destDir, true); + assertTrue("Check Exist after", movedFile.exists()); + assertTrue("Original deleted", !testFile1.exists()); + } + + @Test + public void testMoveFileToDirectory_Errors() throws Exception { + try { + FileUtils.moveFileToDirectory(null, new File("foo"), true); + fail("Expected NullPointerException when source is null"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.moveFileToDirectory(new File("foo"), null, true); + fail("Expected NullPointerException when destination is null"); + } catch (final NullPointerException e) { + // expected + } + final File testFile1 = new File(getTestDirectory(), "testMoveFileFile1"); + final File testFile2 = new File(getTestDirectory(), "testMoveFileFile2"); + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + try { + FileUtils.moveFileToDirectory(testFile1, testFile2, true); + fail("Expected IOException when dest not a directory"); + } catch (final IOException e) { + // expected + } + + final File nonexistant = new File(getTestDirectory(), "testMoveFileNonExistant"); + try { + FileUtils.moveFileToDirectory(testFile1, nonexistant, false); + fail("Expected IOException when dest does not exist and create=false"); + } catch (final IOException e) { + // expected + } + } + + + @Test + public void testMoveDirectory_Rename() throws Exception { + final File dir = getTestDirectory(); + final File src = new File(dir, "testMoveDirectory1Source"); + final File testDir = new File(src, "foo"); + final File testFile = new File(testDir, "bar"); + testDir.mkdirs(); + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + final File destination = new File(dir, "testMoveDirectory1Dest"); + FileUtils.deleteDirectory(destination); + + // Move the directory + FileUtils.moveDirectory(src, destination); + + // Check results + assertTrue("Check Exist", destination.exists()); + assertTrue("Original deleted", !src.exists()); + final File movedDir = new File(destination, testDir.getName()); + final File movedFile = new File(movedDir, testFile.getName()); + assertTrue("Check dir moved", movedDir.exists()); + assertTrue("Check file moved", movedFile.exists()); + } + + @Test + public void testMoveDirectory_CopyDelete() throws Exception { + + final File dir = getTestDirectory(); + final File src = new File(dir, "testMoveDirectory2Source") { + private static final long serialVersionUID = 1L; + + // Force renameTo to fail + @Override + public boolean renameTo(final File dest) { + return false; + } + }; + final File testDir = new File(src, "foo"); + final File testFile = new File(testDir, "bar"); + testDir.mkdirs(); + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + final File destination = new File(dir, "testMoveDirectory1Dest"); + FileUtils.deleteDirectory(destination); + + // Move the directory + FileUtils.moveDirectory(src, destination); + + // Check results + assertTrue("Check Exist", destination.exists()); + assertTrue("Original deleted", !src.exists()); + final File movedDir = new File(destination, testDir.getName()); + final File movedFile = new File(movedDir, testFile.getName()); + assertTrue("Check dir moved", movedDir.exists()); + assertTrue("Check file moved", movedFile.exists()); + } + + @Test + public void testMoveDirectory_Errors() throws Exception { + try { + FileUtils.moveDirectory(null, new File("foo")); + fail("Expected NullPointerException when source is null"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.moveDirectory(new File("foo"), null); + fail("Expected NullPointerException when destination is null"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.moveDirectory(new File("nonexistant"), new File("foo")); + fail("Expected FileNotFoundException for source"); + } catch (final FileNotFoundException e) { + // expected + } + final File testFile = new File(getTestDirectory(), "testMoveDirectoryFile"); + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + try { + FileUtils.moveDirectory(testFile, new File("foo")); + fail("Expected IOException when source is not a directory"); + } catch (final IOException e) { + // expected + } + final File testSrcFile = new File(getTestDirectory(), "testMoveDirectorySource"); + final File testDestFile = new File(getTestDirectory(), "testMoveDirectoryDest"); + testSrcFile.mkdir(); + testDestFile.mkdir(); + try { + FileUtils.moveDirectory(testSrcFile, testDestFile); + fail("Expected FileExistsException when dest already exists"); + } catch (final FileExistsException e) { + // expected + } + + } + + @Test + public void testMoveDirectoryToDirectory() throws Exception { + final File dir = getTestDirectory(); + final File src = new File(dir, "testMoveDirectory1Source"); + final File testChildDir = new File(src, "foo"); + final File testFile = new File(testChildDir, "bar"); + testChildDir.mkdirs(); + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + final File destDir = new File(dir, "testMoveDirectory1Dest"); + FileUtils.deleteDirectory(destDir); + assertFalse("Check Exist before", destDir.exists()); + + // Move the directory + FileUtils.moveDirectoryToDirectory(src, destDir, true); + + // Check results + assertTrue("Check Exist after", destDir.exists()); + assertTrue("Original deleted", !src.exists()); + final File movedDir = new File(destDir, src.getName()); + final File movedChildDir = new File(movedDir, testChildDir.getName()); + final File movedFile = new File(movedChildDir, testFile.getName()); + assertTrue("Check dir moved", movedDir.exists()); + assertTrue("Check child dir moved", movedChildDir.exists()); + assertTrue("Check file moved", movedFile.exists()); + } + + @Test + public void testMoveDirectoryToDirectory_Errors() throws Exception { + try { + FileUtils.moveDirectoryToDirectory(null, new File("foo"), true); + fail("Expected NullPointerException when source is null"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.moveDirectoryToDirectory(new File("foo"), null, true); + fail("Expected NullPointerException when destination is null"); + } catch (final NullPointerException e) { + // expected + } + final File testFile1 = new File(getTestDirectory(), "testMoveFileFile1"); + final File testFile2 = new File(getTestDirectory(), "testMoveFileFile2"); + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + try { + FileUtils.moveDirectoryToDirectory(testFile1, testFile2, true); + fail("Expected IOException when dest not a directory"); + } catch (final IOException e) { + // expected + } + + final File nonexistant = new File(getTestDirectory(), "testMoveFileNonExistant"); + try { + FileUtils.moveDirectoryToDirectory(testFile1, nonexistant, false); + fail("Expected IOException when dest does not exist and create=false"); + } catch (final IOException e) { + // expected + } + } + + @Test + public void testMoveToDirectory() throws Exception { + final File destDir = new File(getTestDirectory(), "testMoveToDirectoryDestDir"); + final File testDir = new File(getTestDirectory(), "testMoveToDirectoryTestDir"); + final File testFile = new File(getTestDirectory(), "testMoveToDirectoryTestFile"); + testDir.mkdirs(); + if (!testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + final File movedFile = new File(destDir, testFile.getName()); + final File movedDir = new File(destDir, testFile.getName()); + + assertFalse("Check File Doesnt exist", movedFile.exists()); + assertFalse("Check Dir Doesnt exist", movedDir.exists()); + + // Test moving a file + FileUtils.moveToDirectory(testFile, destDir, true); + assertTrue("Check File exists", movedFile.exists()); + assertFalse("Check Original File doesn't exist", testFile.exists()); + + // Test moving a directory + FileUtils.moveToDirectory(testDir, destDir, true); + assertTrue("Check Dir exists", movedDir.exists()); + assertFalse("Check Original Dir doesn't exist", testDir.exists()); + } + + @Test + public void testMoveToDirectory_Errors() throws Exception { + try { + FileUtils.moveDirectoryToDirectory(null, new File("foo"), true); + fail("Expected NullPointerException when source is null"); + } catch (final NullPointerException e) { + // expected + } + try { + FileUtils.moveDirectoryToDirectory(new File("foo"), null, true); + fail("Expected NullPointerException when destination is null"); + } catch (final NullPointerException e) { + // expected + } + final File nonexistant = new File(getTestDirectory(), "nonexistant"); + final File destDir = new File(getTestDirectory(), "MoveToDirectoryDestDir"); + try { + FileUtils.moveToDirectory(nonexistant, destDir, true); + fail("Expected IOException when source does not exist"); + } catch (final IOException e) { + // expected + } + } + + @Test + public void testIO300() throws Exception { + final File testDirectory = getTestDirectory(); + final File src = new File(testDirectory, "dir1"); + final File dest = new File(src, "dir2"); + assertTrue(dest.mkdirs()); + assertTrue(src.exists()); + try { + FileUtils.moveDirectoryToDirectory(src, dest, false); + fail("expected IOException"); + } catch (final IOException ioe) { + // expected + } + assertTrue(src.exists()); + } + + @Test + public void testIO276() throws Exception { + final File dir = new File("target", "IO276"); + assertTrue(dir + " should not be present", dir.mkdirs()); + final File file = new File(dir, "IO276.txt"); + assertTrue(file + " should not be present", file.createNewFile()); + FileUtils.forceDeleteOnExit(dir); + // If this does not work, test will fail next time (assuming target is not cleaned) + } + + // Test helper class to pretend a file is shorter than it is + private static class ShorterFile extends File { + private static final long serialVersionUID = 1L; + + public ShorterFile(String pathname) { + super(pathname); + } + + @Override + public long length() { + return super.length() - 1; + } + } + + // This test relies on FileUtils.copyFile using File.length to check the output size + @Test + public void testIncorrectOutputSize() throws Exception { + File inFile = new File("pom.xml"); + File outFile = new ShorterFile("target/pom.tmp"); // it will report a shorter file + try { + FileUtils.copyFile(inFile, outFile); + fail("Expected IOException"); + } catch (Exception e) { + final String msg = e.toString(); + assertTrue(msg, msg.contains("Failed to copy full contents")); + } finally { + outFile.delete(); // tidy up + } + } + + /** + * DirectoryWalker implementation that recursively lists all files and directories. + */ + static class ListDirectoryWalker extends DirectoryWalker { + ListDirectoryWalker() { + super(); + } + + List list(final File startDirectory) throws IOException { + final ArrayList files = new ArrayList(); + walk(startDirectory, files); + return files; + } + + @Override + protected void handleDirectoryStart(final File directory, final int depth, final Collection results) throws IOException { + // Add all directories except the starting directory + if (depth > 0) { + results.add(directory); + } + } + + @Override + protected void handleFile(final File file, final int depth, final Collection results) throws IOException { + results.add(file); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..dcbbd493bcc658d9fed8ade30c0c025d1a46296a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java" @@ -0,0 +1,64 @@ +/* + * 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 org.junit.Test; + +import java.io.File; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.junit.Assert.assertTrue; + +/** + * This is used to test FileUtils.waitFor() method for correctness. + * + * @version $Id: FileUtilsWaitForTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + * @see FileUtils + */ +public class FileUtilsWaitForTestCase { + // This class has been broken out from FileUtilsTestCase + // to solve issues as per BZ 38927 + + //----------------------------------------------------------------------- + @Test + public void testWaitFor() { + FileUtils.waitFor(new File(""), -1); + FileUtils.waitFor(new File(""), 2); + } + + @Test + public void testWaitForInterrupted() throws InterruptedException { + final AtomicBoolean wasInterrupted = new AtomicBoolean(false); + final CountDownLatch started = new CountDownLatch(1); + Runnable thread = new Runnable() { + @Override + public void run() { + started.countDown(); + FileUtils.waitFor(new File(""), 2); + wasInterrupted.set( Thread.currentThread().isInterrupted()); + } + }; + Thread thread1 = new Thread(thread); + thread1.start(); + started.await(); + thread1.interrupt(); + thread1.join(); + assertTrue( wasInterrupted.get() ); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..393007ece93b73300c3e2eb4b347cd82f02003f5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java" @@ -0,0 +1,1109 @@ +/* + * 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 org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This is used to test FilenameUtils for correctness. + * + * @version $Id: FilenameUtilsTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + * @see FilenameUtils + */ +public class FilenameUtilsTestCase extends FileBasedTestCase { + + private static final String SEP = "" + File.separatorChar; + private static final boolean WINDOWS = File.separatorChar == '\\'; + + private final File testFile1; + private final File testFile2; + + private final int testFile1Size; + private final int testFile2Size; + + public FilenameUtilsTestCase() { + testFile1 = new File(getTestDirectory(), "file1-test.txt"); + testFile2 = new File(getTestDirectory(), "file1a-test.txt"); + + testFile1Size = (int) testFile1.length(); + testFile2Size = (int) testFile2.length(); + } + + /** + * @see junit.framework.TestCase#setUp() + */ + @Before + public void setUp() throws Exception { + getTestDirectory(); + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output3 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output3, (long) testFile1Size); + } finally { + IOUtils.closeQuietly(output3); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output2 = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output2, (long) testFile2Size); + } finally { + IOUtils.closeQuietly(output2); + } + FileUtils.deleteDirectory(getTestDirectory()); + getTestDirectory(); + if (!testFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(testFile1)); + try { + TestUtils.generateTestData(output1, (long) testFile1Size); + } finally { + IOUtils.closeQuietly(output1); + } + if (!testFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + testFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(testFile2)); + try { + TestUtils.generateTestData(output, (long) testFile2Size); + } finally { + IOUtils.closeQuietly(output); + } + } + + /** + * @see junit.framework.TestCase#tearDown() + */ + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(getTestDirectory()); + } + + //----------------------------------------------------------------------- + @Test + public void testNormalize() throws Exception { + assertEquals(null, FilenameUtils.normalize(null)); + assertEquals(null, FilenameUtils.normalize(":")); + assertEquals(null, FilenameUtils.normalize("1:\\a\\b\\c.txt")); + assertEquals(null, FilenameUtils.normalize("1:")); + assertEquals(null, FilenameUtils.normalize("1:a")); + assertEquals(null, FilenameUtils.normalize("\\\\\\a\\b\\c.txt")); + assertEquals(null, FilenameUtils.normalize("\\\\a")); + + assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("a\\b/c.txt")); + assertEquals("" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("\\a\\b/c.txt")); + assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("C:\\a\\b/c.txt")); + assertEquals("" + SEP + "" + SEP + "server" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("\\\\server\\a\\b/c.txt")); + assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("~\\a\\b/c.txt")); + assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("~user\\a\\b/c.txt")); + + assertEquals("a" + SEP + "c", FilenameUtils.normalize("a/b/../c")); + assertEquals("c", FilenameUtils.normalize("a/b/../../c")); + assertEquals("c" + SEP, FilenameUtils.normalize("a/b/../../c/")); + assertEquals(null, FilenameUtils.normalize("a/b/../../../c")); + assertEquals("a" + SEP, FilenameUtils.normalize("a/b/..")); + assertEquals("a" + SEP, FilenameUtils.normalize("a/b/../")); + assertEquals("", FilenameUtils.normalize("a/b/../..")); + assertEquals("", FilenameUtils.normalize("a/b/../../")); + assertEquals(null, FilenameUtils.normalize("a/b/../../..")); + assertEquals("a" + SEP + "d", FilenameUtils.normalize("a/b/../c/../d")); + assertEquals("a" + SEP + "d" + SEP, FilenameUtils.normalize("a/b/../c/../d/")); + assertEquals("a" + SEP + "b" + SEP + "d", FilenameUtils.normalize("a/b//d")); + assertEquals("a" + SEP + "b" + SEP, FilenameUtils.normalize("a/b/././.")); + assertEquals("a" + SEP + "b" + SEP, FilenameUtils.normalize("a/b/./././")); + assertEquals("a" + SEP, FilenameUtils.normalize("./a/")); + assertEquals("a", FilenameUtils.normalize("./a")); + assertEquals("", FilenameUtils.normalize("./")); + assertEquals("", FilenameUtils.normalize(".")); + assertEquals(null, FilenameUtils.normalize("../a")); + assertEquals(null, FilenameUtils.normalize("..")); + assertEquals("", FilenameUtils.normalize("")); + + assertEquals(SEP + "a", FilenameUtils.normalize("/a")); + assertEquals(SEP + "a" + SEP, FilenameUtils.normalize("/a/")); + assertEquals(SEP + "a" + SEP + "c", FilenameUtils.normalize("/a/b/../c")); + assertEquals(SEP + "c", FilenameUtils.normalize("/a/b/../../c")); + assertEquals(null, FilenameUtils.normalize("/a/b/../../../c")); + assertEquals(SEP + "a" + SEP, FilenameUtils.normalize("/a/b/..")); + assertEquals(SEP + "", FilenameUtils.normalize("/a/b/../..")); + assertEquals(null, FilenameUtils.normalize("/a/b/../../..")); + assertEquals(SEP + "a" + SEP + "d", FilenameUtils.normalize("/a/b/../c/../d")); + assertEquals(SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalize("/a/b//d")); + assertEquals(SEP + "a" + SEP + "b" + SEP, FilenameUtils.normalize("/a/b/././.")); + assertEquals(SEP + "a", FilenameUtils.normalize("/./a")); + assertEquals(SEP + "", FilenameUtils.normalize("/./")); + assertEquals(SEP + "", FilenameUtils.normalize("/.")); + assertEquals(null, FilenameUtils.normalize("/../a")); + assertEquals(null, FilenameUtils.normalize("/..")); + assertEquals(SEP + "", FilenameUtils.normalize("/")); + + assertEquals("~" + SEP + "a", FilenameUtils.normalize("~/a")); + assertEquals("~" + SEP + "a" + SEP, FilenameUtils.normalize("~/a/")); + assertEquals("~" + SEP + "a" + SEP + "c", FilenameUtils.normalize("~/a/b/../c")); + assertEquals("~" + SEP + "c", FilenameUtils.normalize("~/a/b/../../c")); + assertEquals(null, FilenameUtils.normalize("~/a/b/../../../c")); + assertEquals("~" + SEP + "a" + SEP, FilenameUtils.normalize("~/a/b/..")); + assertEquals("~" + SEP + "", FilenameUtils.normalize("~/a/b/../..")); + assertEquals(null, FilenameUtils.normalize("~/a/b/../../..")); + assertEquals("~" + SEP + "a" + SEP + "d", FilenameUtils.normalize("~/a/b/../c/../d")); + assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalize("~/a/b//d")); + assertEquals("~" + SEP + "a" + SEP + "b" + SEP, FilenameUtils.normalize("~/a/b/././.")); + assertEquals("~" + SEP + "a", FilenameUtils.normalize("~/./a")); + assertEquals("~" + SEP, FilenameUtils.normalize("~/./")); + assertEquals("~" + SEP, FilenameUtils.normalize("~/.")); + assertEquals(null, FilenameUtils.normalize("~/../a")); + assertEquals(null, FilenameUtils.normalize("~/..")); + assertEquals("~" + SEP, FilenameUtils.normalize("~/")); + assertEquals("~" + SEP, FilenameUtils.normalize("~")); + + assertEquals("~user" + SEP + "a", FilenameUtils.normalize("~user/a")); + assertEquals("~user" + SEP + "a" + SEP, FilenameUtils.normalize("~user/a/")); + assertEquals("~user" + SEP + "a" + SEP + "c", FilenameUtils.normalize("~user/a/b/../c")); + assertEquals("~user" + SEP + "c", FilenameUtils.normalize("~user/a/b/../../c")); + assertEquals(null, FilenameUtils.normalize("~user/a/b/../../../c")); + assertEquals("~user" + SEP + "a" + SEP, FilenameUtils.normalize("~user/a/b/..")); + assertEquals("~user" + SEP + "", FilenameUtils.normalize("~user/a/b/../..")); + assertEquals(null, FilenameUtils.normalize("~user/a/b/../../..")); + assertEquals("~user" + SEP + "a" + SEP + "d", FilenameUtils.normalize("~user/a/b/../c/../d")); + assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalize("~user/a/b//d")); + assertEquals("~user" + SEP + "a" + SEP + "b" + SEP, FilenameUtils.normalize("~user/a/b/././.")); + assertEquals("~user" + SEP + "a", FilenameUtils.normalize("~user/./a")); + assertEquals("~user" + SEP + "", FilenameUtils.normalize("~user/./")); + assertEquals("~user" + SEP + "", FilenameUtils.normalize("~user/.")); + assertEquals(null, FilenameUtils.normalize("~user/../a")); + assertEquals(null, FilenameUtils.normalize("~user/..")); + assertEquals("~user" + SEP, FilenameUtils.normalize("~user/")); + assertEquals("~user" + SEP, FilenameUtils.normalize("~user")); + + assertEquals("C:" + SEP + "a", FilenameUtils.normalize("C:/a")); + assertEquals("C:" + SEP + "a" + SEP, FilenameUtils.normalize("C:/a/")); + assertEquals("C:" + SEP + "a" + SEP + "c", FilenameUtils.normalize("C:/a/b/../c")); + assertEquals("C:" + SEP + "c", FilenameUtils.normalize("C:/a/b/../../c")); + assertEquals(null, FilenameUtils.normalize("C:/a/b/../../../c")); + assertEquals("C:" + SEP + "a" + SEP, FilenameUtils.normalize("C:/a/b/..")); + assertEquals("C:" + SEP + "", FilenameUtils.normalize("C:/a/b/../..")); + assertEquals(null, FilenameUtils.normalize("C:/a/b/../../..")); + assertEquals("C:" + SEP + "a" + SEP + "d", FilenameUtils.normalize("C:/a/b/../c/../d")); + assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalize("C:/a/b//d")); + assertEquals("C:" + SEP + "a" + SEP + "b" + SEP, FilenameUtils.normalize("C:/a/b/././.")); + assertEquals("C:" + SEP + "a", FilenameUtils.normalize("C:/./a")); + assertEquals("C:" + SEP + "", FilenameUtils.normalize("C:/./")); + assertEquals("C:" + SEP + "", FilenameUtils.normalize("C:/.")); + assertEquals(null, FilenameUtils.normalize("C:/../a")); + assertEquals(null, FilenameUtils.normalize("C:/..")); + assertEquals("C:" + SEP + "", FilenameUtils.normalize("C:/")); + + assertEquals("C:" + "a", FilenameUtils.normalize("C:a")); + assertEquals("C:" + "a" + SEP, FilenameUtils.normalize("C:a/")); + assertEquals("C:" + "a" + SEP + "c", FilenameUtils.normalize("C:a/b/../c")); + assertEquals("C:" + "c", FilenameUtils.normalize("C:a/b/../../c")); + assertEquals(null, FilenameUtils.normalize("C:a/b/../../../c")); + assertEquals("C:" + "a" + SEP, FilenameUtils.normalize("C:a/b/..")); + assertEquals("C:" + "", FilenameUtils.normalize("C:a/b/../..")); + assertEquals(null, FilenameUtils.normalize("C:a/b/../../..")); + assertEquals("C:" + "a" + SEP + "d", FilenameUtils.normalize("C:a/b/../c/../d")); + assertEquals("C:" + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalize("C:a/b//d")); + assertEquals("C:" + "a" + SEP + "b" + SEP, FilenameUtils.normalize("C:a/b/././.")); + assertEquals("C:" + "a", FilenameUtils.normalize("C:./a")); + assertEquals("C:" + "", FilenameUtils.normalize("C:./")); + assertEquals("C:" + "", FilenameUtils.normalize("C:.")); + assertEquals(null, FilenameUtils.normalize("C:../a")); + assertEquals(null, FilenameUtils.normalize("C:..")); + assertEquals("C:" + "", FilenameUtils.normalize("C:")); + + assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils.normalize("//server/a")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP, FilenameUtils.normalize("//server/a/")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "c", FilenameUtils.normalize("//server/a/b/../c")); + assertEquals(SEP + SEP + "server" + SEP + "c", FilenameUtils.normalize("//server/a/b/../../c")); + assertEquals(null, FilenameUtils.normalize("//server/a/b/../../../c")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP, FilenameUtils.normalize("//server/a/b/..")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalize("//server/a/b/../..")); + assertEquals(null, FilenameUtils.normalize("//server/a/b/../../..")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "d", FilenameUtils.normalize("//server/a/b/../c/../d")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalize("//server/a/b//d")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "b" + SEP, FilenameUtils.normalize("//server/a/b/././.")); + assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils.normalize("//server/./a")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalize("//server/./")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalize("//server/.")); + assertEquals(null, FilenameUtils.normalize("//server/../a")); + assertEquals(null, FilenameUtils.normalize("//server/..")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalize("//server/")); + } + + @Test + public void testNormalize_with_nullbytes() throws Exception { + try { + assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("a\\b/c\u0000.txt")); + } catch (IllegalArgumentException ignore) { + } + + try { + assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalize("\u0000a\\b/c.txt")); + } catch (IllegalArgumentException ignore) { + } + } + + @Test + public void testNormalizeUnixWin() throws Exception { + + // Normalize (Unix Separator) + assertEquals("/a/c/", FilenameUtils.normalize("/a/b/../c/", true)); + assertEquals("/a/c/", FilenameUtils.normalize("\\a\\b\\..\\c\\", true)); + + // Normalize (Windows Separator) + assertEquals("\\a\\c\\", FilenameUtils.normalize("/a/b/../c/", false)); + assertEquals("\\a\\c\\", FilenameUtils.normalize("\\a\\b\\..\\c\\", false)); + } + + //----------------------------------------------------------------------- + @Test + public void testNormalizeNoEndSeparator() throws Exception { + assertEquals(null, FilenameUtils.normalizeNoEndSeparator(null)); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator(":")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("1:\\a\\b\\c.txt")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("1:")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("1:a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("\\\\\\a\\b\\c.txt")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("\\\\a")); + + assertEquals("a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalizeNoEndSeparator("a\\b/c.txt")); + assertEquals("" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalizeNoEndSeparator("\\a\\b/c.txt")); + assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalizeNoEndSeparator("C:\\a\\b/c.txt")); + assertEquals("" + SEP + "" + SEP + "server" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalizeNoEndSeparator("\\\\server\\a\\b/c.txt")); + assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalizeNoEndSeparator("~\\a\\b/c.txt")); + assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "c.txt", FilenameUtils.normalizeNoEndSeparator("~user\\a\\b/c.txt")); + + assertEquals("a" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("a/b/../c")); + assertEquals("c", FilenameUtils.normalizeNoEndSeparator("a/b/../../c")); + assertEquals("c", FilenameUtils.normalizeNoEndSeparator("a/b/../../c/")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("a/b/../../../c")); + assertEquals("a", FilenameUtils.normalizeNoEndSeparator("a/b/..")); + assertEquals("a", FilenameUtils.normalizeNoEndSeparator("a/b/../")); + assertEquals("", FilenameUtils.normalizeNoEndSeparator("a/b/../..")); + assertEquals("", FilenameUtils.normalizeNoEndSeparator("a/b/../../")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("a/b/../../..")); + assertEquals("a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("a/b/../c/../d")); + assertEquals("a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("a/b/../c/../d/")); + assertEquals("a" + SEP + "b" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("a/b//d")); + assertEquals("a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("a/b/././.")); + assertEquals("a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("a/b/./././")); + assertEquals("a", FilenameUtils.normalizeNoEndSeparator("./a/")); + assertEquals("a", FilenameUtils.normalizeNoEndSeparator("./a")); + assertEquals("", FilenameUtils.normalizeNoEndSeparator("./")); + assertEquals("", FilenameUtils.normalizeNoEndSeparator(".")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("../a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("..")); + assertEquals("", FilenameUtils.normalizeNoEndSeparator("")); + + assertEquals(SEP + "a", FilenameUtils.normalizeNoEndSeparator("/a")); + assertEquals(SEP + "a", FilenameUtils.normalizeNoEndSeparator("/a/")); + assertEquals(SEP + "a" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("/a/b/../c")); + assertEquals(SEP + "c", FilenameUtils.normalizeNoEndSeparator("/a/b/../../c")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("/a/b/../../../c")); + assertEquals(SEP + "a", FilenameUtils.normalizeNoEndSeparator("/a/b/..")); + assertEquals(SEP + "", FilenameUtils.normalizeNoEndSeparator("/a/b/../..")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("/a/b/../../..")); + assertEquals(SEP + "a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("/a/b/../c/../d")); + assertEquals(SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("/a/b//d")); + assertEquals(SEP + "a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("/a/b/././.")); + assertEquals(SEP + "a", FilenameUtils.normalizeNoEndSeparator("/./a")); + assertEquals(SEP + "", FilenameUtils.normalizeNoEndSeparator("/./")); + assertEquals(SEP + "", FilenameUtils.normalizeNoEndSeparator("/.")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("/../a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("/..")); + assertEquals(SEP + "", FilenameUtils.normalizeNoEndSeparator("/")); + + assertEquals("~" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~/a")); + assertEquals("~" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~/a/")); + assertEquals("~" + SEP + "a" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("~/a/b/../c")); + assertEquals("~" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("~/a/b/../../c")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~/a/b/../../../c")); + assertEquals("~" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~/a/b/..")); + assertEquals("~" + SEP + "", FilenameUtils.normalizeNoEndSeparator("~/a/b/../..")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~/a/b/../../..")); + assertEquals("~" + SEP + "a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("~/a/b/../c/../d")); + assertEquals("~" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("~/a/b//d")); + assertEquals("~" + SEP + "a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("~/a/b/././.")); + assertEquals("~" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~/./a")); + assertEquals("~" + SEP, FilenameUtils.normalizeNoEndSeparator("~/./")); + assertEquals("~" + SEP, FilenameUtils.normalizeNoEndSeparator("~/.")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~/../a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~/..")); + assertEquals("~" + SEP, FilenameUtils.normalizeNoEndSeparator("~/")); + assertEquals("~" + SEP, FilenameUtils.normalizeNoEndSeparator("~")); + + assertEquals("~user" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~user/a")); + assertEquals("~user" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~user/a/")); + assertEquals("~user" + SEP + "a" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("~user/a/b/../c")); + assertEquals("~user" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("~user/a/b/../../c")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~user/a/b/../../../c")); + assertEquals("~user" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~user/a/b/..")); + assertEquals("~user" + SEP + "", FilenameUtils.normalizeNoEndSeparator("~user/a/b/../..")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~user/a/b/../../..")); + assertEquals("~user" + SEP + "a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("~user/a/b/../c/../d")); + assertEquals("~user" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("~user/a/b//d")); + assertEquals("~user" + SEP + "a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("~user/a/b/././.")); + assertEquals("~user" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("~user/./a")); + assertEquals("~user" + SEP + "", FilenameUtils.normalizeNoEndSeparator("~user/./")); + assertEquals("~user" + SEP + "", FilenameUtils.normalizeNoEndSeparator("~user/.")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~user/../a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("~user/..")); + assertEquals("~user" + SEP, FilenameUtils.normalizeNoEndSeparator("~user/")); + assertEquals("~user" + SEP, FilenameUtils.normalizeNoEndSeparator("~user")); + + assertEquals("C:" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("C:/a")); + assertEquals("C:" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("C:/a/")); + assertEquals("C:" + SEP + "a" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("C:/a/b/../c")); + assertEquals("C:" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("C:/a/b/../../c")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:/a/b/../../../c")); + assertEquals("C:" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("C:/a/b/..")); + assertEquals("C:" + SEP + "", FilenameUtils.normalizeNoEndSeparator("C:/a/b/../..")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:/a/b/../../..")); + assertEquals("C:" + SEP + "a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("C:/a/b/../c/../d")); + assertEquals("C:" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("C:/a/b//d")); + assertEquals("C:" + SEP + "a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("C:/a/b/././.")); + assertEquals("C:" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("C:/./a")); + assertEquals("C:" + SEP + "", FilenameUtils.normalizeNoEndSeparator("C:/./")); + assertEquals("C:" + SEP + "", FilenameUtils.normalizeNoEndSeparator("C:/.")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:/../a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:/..")); + assertEquals("C:" + SEP + "", FilenameUtils.normalizeNoEndSeparator("C:/")); + + assertEquals("C:" + "a", FilenameUtils.normalizeNoEndSeparator("C:a")); + assertEquals("C:" + "a", FilenameUtils.normalizeNoEndSeparator("C:a/")); + assertEquals("C:" + "a" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("C:a/b/../c")); + assertEquals("C:" + "c", FilenameUtils.normalizeNoEndSeparator("C:a/b/../../c")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:a/b/../../../c")); + assertEquals("C:" + "a", FilenameUtils.normalizeNoEndSeparator("C:a/b/..")); + assertEquals("C:" + "", FilenameUtils.normalizeNoEndSeparator("C:a/b/../..")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:a/b/../../..")); + assertEquals("C:" + "a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("C:a/b/../c/../d")); + assertEquals("C:" + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("C:a/b//d")); + assertEquals("C:" + "a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("C:a/b/././.")); + assertEquals("C:" + "a", FilenameUtils.normalizeNoEndSeparator("C:./a")); + assertEquals("C:" + "", FilenameUtils.normalizeNoEndSeparator("C:./")); + assertEquals("C:" + "", FilenameUtils.normalizeNoEndSeparator("C:.")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:../a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("C:..")); + assertEquals("C:" + "", FilenameUtils.normalizeNoEndSeparator("C:")); + + assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("//server/a")); + assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("//server/a/")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("//server/a/b/../c")); + assertEquals(SEP + SEP + "server" + SEP + "c", FilenameUtils.normalizeNoEndSeparator("//server/a/b/../../c")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("//server/a/b/../../../c")); + assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("//server/a/b/..")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalizeNoEndSeparator("//server/a/b/../..")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("//server/a/b/../../..")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("//server/a/b/../c/../d")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "b" + SEP + "d", FilenameUtils.normalizeNoEndSeparator("//server/a/b//d")); + assertEquals(SEP + SEP + "server" + SEP + "a" + SEP + "b", FilenameUtils.normalizeNoEndSeparator("//server/a/b/././.")); + assertEquals(SEP + SEP + "server" + SEP + "a", FilenameUtils.normalizeNoEndSeparator("//server/./a")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalizeNoEndSeparator("//server/./")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalizeNoEndSeparator("//server/.")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("//server/../a")); + assertEquals(null, FilenameUtils.normalizeNoEndSeparator("//server/..")); + assertEquals(SEP + SEP + "server" + SEP + "", FilenameUtils.normalizeNoEndSeparator("//server/")); + } + + @Test + public void testNormalizeNoEndSeparatorUnixWin() throws Exception { + + // Normalize (Unix Separator) + assertEquals("/a/c", FilenameUtils.normalizeNoEndSeparator("/a/b/../c/", true)); + assertEquals("/a/c", FilenameUtils.normalizeNoEndSeparator("\\a\\b\\..\\c\\", true)); + + // Normalize (Windows Separator) + assertEquals("\\a\\c", FilenameUtils.normalizeNoEndSeparator("/a/b/../c/", false)); + assertEquals("\\a\\c", FilenameUtils.normalizeNoEndSeparator("\\a\\b\\..\\c\\", false)); + } + + //----------------------------------------------------------------------- + @Test + public void testConcat() { + assertEquals(null, FilenameUtils.concat("", null)); + assertEquals(null, FilenameUtils.concat(null, null)); + assertEquals(null, FilenameUtils.concat(null, "")); + assertEquals(null, FilenameUtils.concat(null, "a")); + assertEquals(SEP + "a", FilenameUtils.concat(null, "/a")); + + assertEquals(null, FilenameUtils.concat("", ":")); // invalid prefix + assertEquals(null, FilenameUtils.concat(":", "")); // invalid prefix + + assertEquals("f" + SEP, FilenameUtils.concat("", "f/")); + assertEquals("f", FilenameUtils.concat("", "f")); + assertEquals("a" + SEP + "f" + SEP, FilenameUtils.concat("a/", "f/")); + assertEquals("a" + SEP + "f", FilenameUtils.concat("a", "f")); + assertEquals("a" + SEP + "b" + SEP + "f" + SEP, FilenameUtils.concat("a/b/", "f/")); + assertEquals("a" + SEP + "b" + SEP + "f", FilenameUtils.concat("a/b", "f")); + + assertEquals("a" + SEP + "f" + SEP, FilenameUtils.concat("a/b/", "../f/")); + assertEquals("a" + SEP + "f", FilenameUtils.concat("a/b", "../f")); + assertEquals("a" + SEP + "c" + SEP + "g" + SEP, FilenameUtils.concat("a/b/../c/", "f/../g/")); + assertEquals("a" + SEP + "c" + SEP + "g", FilenameUtils.concat("a/b/../c", "f/../g")); + + assertEquals("a" + SEP + "c.txt" + SEP + "f", FilenameUtils.concat("a/c.txt", "f")); + + assertEquals(SEP + "f" + SEP, FilenameUtils.concat("", "/f/")); + assertEquals(SEP + "f", FilenameUtils.concat("", "/f")); + assertEquals(SEP + "f" + SEP, FilenameUtils.concat("a/", "/f/")); + assertEquals(SEP + "f", FilenameUtils.concat("a", "/f")); + + assertEquals(SEP + "c" + SEP + "d", FilenameUtils.concat("a/b/", "/c/d")); + assertEquals("C:c" + SEP + "d", FilenameUtils.concat("a/b/", "C:c/d")); + assertEquals("C:" + SEP + "c" + SEP + "d", FilenameUtils.concat("a/b/", "C:/c/d")); + assertEquals("~" + SEP + "c" + SEP + "d", FilenameUtils.concat("a/b/", "~/c/d")); + assertEquals("~user" + SEP + "c" + SEP + "d", FilenameUtils.concat("a/b/", "~user/c/d")); + assertEquals("~" + SEP, FilenameUtils.concat("a/b/", "~")); + assertEquals("~user" + SEP, FilenameUtils.concat("a/b/", "~user")); + } + + //----------------------------------------------------------------------- + @Test + public void testSeparatorsToUnix() { + assertEquals(null, FilenameUtils.separatorsToUnix(null)); + assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b/c")); + assertEquals("/a/b/c.txt", FilenameUtils.separatorsToUnix("/a/b/c.txt")); + assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("/a/b\\c")); + assertEquals("/a/b/c", FilenameUtils.separatorsToUnix("\\a\\b\\c")); + assertEquals("D:/a/b/c", FilenameUtils.separatorsToUnix("D:\\a\\b\\c")); + } + + @Test + public void testSeparatorsToWindows() { + assertEquals(null, FilenameUtils.separatorsToWindows(null)); + assertEquals("\\a\\b\\c", FilenameUtils.separatorsToWindows("\\a\\b\\c")); + assertEquals("\\a\\b\\c.txt", FilenameUtils.separatorsToWindows("\\a\\b\\c.txt")); + assertEquals("\\a\\b\\c", FilenameUtils.separatorsToWindows("\\a\\b/c")); + assertEquals("\\a\\b\\c", FilenameUtils.separatorsToWindows("/a/b/c")); + assertEquals("D:\\a\\b\\c", FilenameUtils.separatorsToWindows("D:/a/b/c")); + } + + @Test + public void testSeparatorsToSystem() { + if (WINDOWS) { + assertEquals(null, FilenameUtils.separatorsToSystem(null)); + assertEquals("\\a\\b\\c", FilenameUtils.separatorsToSystem("\\a\\b\\c")); + assertEquals("\\a\\b\\c.txt", FilenameUtils.separatorsToSystem("\\a\\b\\c.txt")); + assertEquals("\\a\\b\\c", FilenameUtils.separatorsToSystem("\\a\\b/c")); + assertEquals("\\a\\b\\c", FilenameUtils.separatorsToSystem("/a/b/c")); + assertEquals("D:\\a\\b\\c", FilenameUtils.separatorsToSystem("D:/a/b/c")); + } else { + assertEquals(null, FilenameUtils.separatorsToSystem(null)); + assertEquals("/a/b/c", FilenameUtils.separatorsToSystem("/a/b/c")); + assertEquals("/a/b/c.txt", FilenameUtils.separatorsToSystem("/a/b/c.txt")); + assertEquals("/a/b/c", FilenameUtils.separatorsToSystem("/a/b\\c")); + assertEquals("/a/b/c", FilenameUtils.separatorsToSystem("\\a\\b\\c")); + assertEquals("D:/a/b/c", FilenameUtils.separatorsToSystem("D:\\a\\b\\c")); + } + } + + //----------------------------------------------------------------------- + @Test + public void testGetPrefixLength() { + assertEquals(-1, FilenameUtils.getPrefixLength(null)); + assertEquals(-1, FilenameUtils.getPrefixLength(":")); + assertEquals(-1, FilenameUtils.getPrefixLength("1:\\a\\b\\c.txt")); + assertEquals(-1, FilenameUtils.getPrefixLength("1:")); + assertEquals(-1, FilenameUtils.getPrefixLength("1:a")); + assertEquals(-1, FilenameUtils.getPrefixLength("\\\\\\a\\b\\c.txt")); + assertEquals(-1, FilenameUtils.getPrefixLength("\\\\a")); + + assertEquals(0, FilenameUtils.getPrefixLength("")); + assertEquals(1, FilenameUtils.getPrefixLength("\\")); + assertEquals(2, FilenameUtils.getPrefixLength("C:")); + assertEquals(3, FilenameUtils.getPrefixLength("C:\\")); + assertEquals(9, FilenameUtils.getPrefixLength("//server/")); + assertEquals(2, FilenameUtils.getPrefixLength("~")); + assertEquals(2, FilenameUtils.getPrefixLength("~/")); + assertEquals(6, FilenameUtils.getPrefixLength("~user")); + assertEquals(6, FilenameUtils.getPrefixLength("~user/")); + + assertEquals(0, FilenameUtils.getPrefixLength("a\\b\\c.txt")); + assertEquals(1, FilenameUtils.getPrefixLength("\\a\\b\\c.txt")); + assertEquals(2, FilenameUtils.getPrefixLength("C:a\\b\\c.txt")); + assertEquals(3, FilenameUtils.getPrefixLength("C:\\a\\b\\c.txt")); + assertEquals(9, FilenameUtils.getPrefixLength("\\\\server\\a\\b\\c.txt")); + + assertEquals(0, FilenameUtils.getPrefixLength("a/b/c.txt")); + assertEquals(1, FilenameUtils.getPrefixLength("/a/b/c.txt")); + assertEquals(3, FilenameUtils.getPrefixLength("C:/a/b/c.txt")); + assertEquals(9, FilenameUtils.getPrefixLength("//server/a/b/c.txt")); + assertEquals(2, FilenameUtils.getPrefixLength("~/a/b/c.txt")); + assertEquals(6, FilenameUtils.getPrefixLength("~user/a/b/c.txt")); + + assertEquals(0, FilenameUtils.getPrefixLength("a\\b\\c.txt")); + assertEquals(1, FilenameUtils.getPrefixLength("\\a\\b\\c.txt")); + assertEquals(2, FilenameUtils.getPrefixLength("~\\a\\b\\c.txt")); + assertEquals(6, FilenameUtils.getPrefixLength("~user\\a\\b\\c.txt")); + + assertEquals(9, FilenameUtils.getPrefixLength("//server/a/b/c.txt")); + assertEquals(-1, FilenameUtils.getPrefixLength("\\\\\\a\\b\\c.txt")); + assertEquals(-1, FilenameUtils.getPrefixLength("///a/b/c.txt")); + } + + @Test + public void testIndexOfLastSeparator() { + assertEquals(-1, FilenameUtils.indexOfLastSeparator(null)); + assertEquals(-1, FilenameUtils.indexOfLastSeparator("noseperator.inthispath")); + assertEquals(3, FilenameUtils.indexOfLastSeparator("a/b/c")); + assertEquals(3, FilenameUtils.indexOfLastSeparator("a\\b\\c")); + } + + @Test + public void testIndexOfExtension() { + assertEquals(-1, FilenameUtils.indexOfExtension(null)); + assertEquals(-1, FilenameUtils.indexOfExtension("file")); + assertEquals(4, FilenameUtils.indexOfExtension("file.txt")); + assertEquals(13, FilenameUtils.indexOfExtension("a.txt/b.txt/c.txt")); + assertEquals(-1, FilenameUtils.indexOfExtension("a/b/c")); + assertEquals(-1, FilenameUtils.indexOfExtension("a\\b\\c")); + assertEquals(-1, FilenameUtils.indexOfExtension("a/b.notextension/c")); + assertEquals(-1, FilenameUtils.indexOfExtension("a\\b.notextension\\c")); + } + + //----------------------------------------------------------------------- + @Test + public void testGetPrefix() { + assertEquals(null, FilenameUtils.getPrefix(null)); + assertEquals(null, FilenameUtils.getPrefix(":")); + assertEquals(null, FilenameUtils.getPrefix("1:\\a\\b\\c.txt")); + assertEquals(null, FilenameUtils.getPrefix("1:")); + assertEquals(null, FilenameUtils.getPrefix("1:a")); + assertEquals(null, FilenameUtils.getPrefix("\\\\\\a\\b\\c.txt")); + assertEquals(null, FilenameUtils.getPrefix("\\\\a")); + + assertEquals("", FilenameUtils.getPrefix("")); + assertEquals("\\", FilenameUtils.getPrefix("\\")); + assertEquals("C:", FilenameUtils.getPrefix("C:")); + assertEquals("C:\\", FilenameUtils.getPrefix("C:\\")); + assertEquals("//server/", FilenameUtils.getPrefix("//server/")); + assertEquals("~/", FilenameUtils.getPrefix("~")); + assertEquals("~/", FilenameUtils.getPrefix("~/")); + assertEquals("~user/", FilenameUtils.getPrefix("~user")); + assertEquals("~user/", FilenameUtils.getPrefix("~user/")); + + assertEquals("", FilenameUtils.getPrefix("a\\b\\c.txt")); + assertEquals("\\", FilenameUtils.getPrefix("\\a\\b\\c.txt")); + assertEquals("C:\\", FilenameUtils.getPrefix("C:\\a\\b\\c.txt")); + assertEquals("\\\\server\\", FilenameUtils.getPrefix("\\\\server\\a\\b\\c.txt")); + + assertEquals("", FilenameUtils.getPrefix("a/b/c.txt")); + assertEquals("/", FilenameUtils.getPrefix("/a/b/c.txt")); + assertEquals("C:/", FilenameUtils.getPrefix("C:/a/b/c.txt")); + assertEquals("//server/", FilenameUtils.getPrefix("//server/a/b/c.txt")); + assertEquals("~/", FilenameUtils.getPrefix("~/a/b/c.txt")); + assertEquals("~user/", FilenameUtils.getPrefix("~user/a/b/c.txt")); + + assertEquals("", FilenameUtils.getPrefix("a\\b\\c.txt")); + assertEquals("\\", FilenameUtils.getPrefix("\\a\\b\\c.txt")); + assertEquals("~\\", FilenameUtils.getPrefix("~\\a\\b\\c.txt")); + assertEquals("~user\\", FilenameUtils.getPrefix("~user\\a\\b\\c.txt")); + } + + @Test + public void testGetPrefix_with_nullbyte() { + try { + assertEquals("~user\\", FilenameUtils.getPrefix("~u\u0000ser\\a\\b\\c.txt")); + } catch (IllegalArgumentException ignore) { + + } + } + + @Test + public void testGetPath() { + assertEquals(null, FilenameUtils.getPath(null)); + assertEquals("", FilenameUtils.getPath("noseperator.inthispath")); + assertEquals("", FilenameUtils.getPath("/noseperator.inthispath")); + assertEquals("", FilenameUtils.getPath("\\noseperator.inthispath")); + assertEquals("a/b/", FilenameUtils.getPath("a/b/c.txt")); + assertEquals("a/b/", FilenameUtils.getPath("a/b/c")); + assertEquals("a/b/c/", FilenameUtils.getPath("a/b/c/")); + assertEquals("a\\b\\", FilenameUtils.getPath("a\\b\\c")); + + assertEquals(null, FilenameUtils.getPath(":")); + assertEquals(null, FilenameUtils.getPath("1:/a/b/c.txt")); + assertEquals(null, FilenameUtils.getPath("1:")); + assertEquals(null, FilenameUtils.getPath("1:a")); + assertEquals(null, FilenameUtils.getPath("///a/b/c.txt")); + assertEquals(null, FilenameUtils.getPath("//a")); + + assertEquals("", FilenameUtils.getPath("")); + assertEquals("", FilenameUtils.getPath("C:")); + assertEquals("", FilenameUtils.getPath("C:/")); + assertEquals("", FilenameUtils.getPath("//server/")); + assertEquals("", FilenameUtils.getPath("~")); + assertEquals("", FilenameUtils.getPath("~/")); + assertEquals("", FilenameUtils.getPath("~user")); + assertEquals("", FilenameUtils.getPath("~user/")); + + assertEquals("a/b/", FilenameUtils.getPath("a/b/c.txt")); + assertEquals("a/b/", FilenameUtils.getPath("/a/b/c.txt")); + assertEquals("", FilenameUtils.getPath("C:a")); + assertEquals("a/b/", FilenameUtils.getPath("C:a/b/c.txt")); + assertEquals("a/b/", FilenameUtils.getPath("C:/a/b/c.txt")); + assertEquals("a/b/", FilenameUtils.getPath("//server/a/b/c.txt")); + assertEquals("a/b/", FilenameUtils.getPath("~/a/b/c.txt")); + assertEquals("a/b/", FilenameUtils.getPath("~user/a/b/c.txt")); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetPath_with_nullbyte() { + assertEquals("a/b/", FilenameUtils.getPath("~user/a/\u0000b/c.txt")); + } + + + @Test + public void testGetPathNoEndSeparator() { + assertEquals(null, FilenameUtils.getPath(null)); + assertEquals("", FilenameUtils.getPath("noseperator.inthispath")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("/noseperator.inthispath")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("\\noseperator.inthispath")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("a/b/c.txt")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("a/b/c")); + assertEquals("a/b/c", FilenameUtils.getPathNoEndSeparator("a/b/c/")); + assertEquals("a\\b", FilenameUtils.getPathNoEndSeparator("a\\b\\c")); + + assertEquals(null, FilenameUtils.getPathNoEndSeparator(":")); + assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:/a/b/c.txt")); + assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:")); + assertEquals(null, FilenameUtils.getPathNoEndSeparator("1:a")); + assertEquals(null, FilenameUtils.getPathNoEndSeparator("///a/b/c.txt")); + assertEquals(null, FilenameUtils.getPathNoEndSeparator("//a")); + + assertEquals("", FilenameUtils.getPathNoEndSeparator("")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("C:")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("C:/")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("//server/")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("~")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("~/")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("~user")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("~user/")); + + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("a/b/c.txt")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("/a/b/c.txt")); + assertEquals("", FilenameUtils.getPathNoEndSeparator("C:a")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("C:a/b/c.txt")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("C:/a/b/c.txt")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("//server/a/b/c.txt")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("~/a/b/c.txt")); + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("~user/a/b/c.txt")); + } + + @Test + public void testGetPathNoEndSeparator_with_null_byte() { + try { + assertEquals("a/b", FilenameUtils.getPathNoEndSeparator("~user/a\u0000/b/c.txt")); + } catch (IllegalArgumentException ignore) { + + } + } + + @Test + public void testGetFullPath() { + assertEquals(null, FilenameUtils.getFullPath(null)); + assertEquals("", FilenameUtils.getFullPath("noseperator.inthispath")); + assertEquals("a/b/", FilenameUtils.getFullPath("a/b/c.txt")); + assertEquals("a/b/", FilenameUtils.getFullPath("a/b/c")); + assertEquals("a/b/c/", FilenameUtils.getFullPath("a/b/c/")); + assertEquals("a\\b\\", FilenameUtils.getFullPath("a\\b\\c")); + + assertEquals(null, FilenameUtils.getFullPath(":")); + assertEquals(null, FilenameUtils.getFullPath("1:/a/b/c.txt")); + assertEquals(null, FilenameUtils.getFullPath("1:")); + assertEquals(null, FilenameUtils.getFullPath("1:a")); + assertEquals(null, FilenameUtils.getFullPath("///a/b/c.txt")); + assertEquals(null, FilenameUtils.getFullPath("//a")); + + assertEquals("", FilenameUtils.getFullPath("")); + assertEquals("C:", FilenameUtils.getFullPath("C:")); + assertEquals("C:/", FilenameUtils.getFullPath("C:/")); + assertEquals("//server/", FilenameUtils.getFullPath("//server/")); + assertEquals("~/", FilenameUtils.getFullPath("~")); + assertEquals("~/", FilenameUtils.getFullPath("~/")); + assertEquals("~user/", FilenameUtils.getFullPath("~user")); + assertEquals("~user/", FilenameUtils.getFullPath("~user/")); + + assertEquals("a/b/", FilenameUtils.getFullPath("a/b/c.txt")); + assertEquals("/a/b/", FilenameUtils.getFullPath("/a/b/c.txt")); + assertEquals("C:", FilenameUtils.getFullPath("C:a")); + assertEquals("C:a/b/", FilenameUtils.getFullPath("C:a/b/c.txt")); + assertEquals("C:/a/b/", FilenameUtils.getFullPath("C:/a/b/c.txt")); + assertEquals("//server/a/b/", FilenameUtils.getFullPath("//server/a/b/c.txt")); + assertEquals("~/a/b/", FilenameUtils.getFullPath("~/a/b/c.txt")); + assertEquals("~user/a/b/", FilenameUtils.getFullPath("~user/a/b/c.txt")); + } + + @Test + public void testGetFullPathNoEndSeparator() { + assertEquals(null, FilenameUtils.getFullPathNoEndSeparator(null)); + assertEquals("", FilenameUtils.getFullPathNoEndSeparator("noseperator.inthispath")); + assertEquals("a/b", FilenameUtils.getFullPathNoEndSeparator("a/b/c.txt")); + assertEquals("a/b", FilenameUtils.getFullPathNoEndSeparator("a/b/c")); + assertEquals("a/b/c", FilenameUtils.getFullPathNoEndSeparator("a/b/c/")); + assertEquals("a\\b", FilenameUtils.getFullPathNoEndSeparator("a\\b\\c")); + + assertEquals(null, FilenameUtils.getFullPathNoEndSeparator(":")); + assertEquals(null, FilenameUtils.getFullPathNoEndSeparator("1:/a/b/c.txt")); + assertEquals(null, FilenameUtils.getFullPathNoEndSeparator("1:")); + assertEquals(null, FilenameUtils.getFullPathNoEndSeparator("1:a")); + assertEquals(null, FilenameUtils.getFullPathNoEndSeparator("///a/b/c.txt")); + assertEquals(null, FilenameUtils.getFullPathNoEndSeparator("//a")); + + assertEquals("", FilenameUtils.getFullPathNoEndSeparator("")); + assertEquals("C:", FilenameUtils.getFullPathNoEndSeparator("C:")); + assertEquals("C:/", FilenameUtils.getFullPathNoEndSeparator("C:/")); + assertEquals("//server/", FilenameUtils.getFullPathNoEndSeparator("//server/")); + assertEquals("~", FilenameUtils.getFullPathNoEndSeparator("~")); + assertEquals("~/", FilenameUtils.getFullPathNoEndSeparator("~/")); + assertEquals("~user", FilenameUtils.getFullPathNoEndSeparator("~user")); + assertEquals("~user/", FilenameUtils.getFullPathNoEndSeparator("~user/")); + + assertEquals("a/b", FilenameUtils.getFullPathNoEndSeparator("a/b/c.txt")); + assertEquals("/a/b", FilenameUtils.getFullPathNoEndSeparator("/a/b/c.txt")); + assertEquals("C:", FilenameUtils.getFullPathNoEndSeparator("C:a")); + assertEquals("C:a/b", FilenameUtils.getFullPathNoEndSeparator("C:a/b/c.txt")); + assertEquals("C:/a/b", FilenameUtils.getFullPathNoEndSeparator("C:/a/b/c.txt")); + assertEquals("//server/a/b", FilenameUtils.getFullPathNoEndSeparator("//server/a/b/c.txt")); + assertEquals("~/a/b", FilenameUtils.getFullPathNoEndSeparator("~/a/b/c.txt")); + assertEquals("~user/a/b", FilenameUtils.getFullPathNoEndSeparator("~user/a/b/c.txt")); + } + + /** + * Test for https://issues.apache.org/jira/browse/IO-248 + */ + @Test + public void testGetFullPathNoEndSeparator_IO_248() { + + // Test single separator + assertEquals("/", FilenameUtils.getFullPathNoEndSeparator("/")); + assertEquals("\\", FilenameUtils.getFullPathNoEndSeparator("\\")); + + // Test one level directory + assertEquals("/", FilenameUtils.getFullPathNoEndSeparator("/abc")); + assertEquals("\\", FilenameUtils.getFullPathNoEndSeparator("\\abc")); + + // Test one level directory + assertEquals("/abc", FilenameUtils.getFullPathNoEndSeparator("/abc/xyz")); + assertEquals("\\abc", FilenameUtils.getFullPathNoEndSeparator("\\abc\\xyz")); + } + + @Test + public void testGetName() { + assertEquals(null, FilenameUtils.getName(null)); + assertEquals("noseperator.inthispath", FilenameUtils.getName("noseperator.inthispath")); + assertEquals("c.txt", FilenameUtils.getName("a/b/c.txt")); + assertEquals("c", FilenameUtils.getName("a/b/c")); + assertEquals("", FilenameUtils.getName("a/b/c/")); + assertEquals("c", FilenameUtils.getName("a\\b\\c")); + } + + @Test + public void testInjectionFailure() { + try { + assertEquals("c", FilenameUtils.getName("a\\b\\\u0000c")); + } catch (IllegalArgumentException ignore) { + + } + } + + @Test + public void testGetBaseName() { + assertEquals(null, FilenameUtils.getBaseName(null)); + assertEquals("noseperator", FilenameUtils.getBaseName("noseperator.inthispath")); + assertEquals("c", FilenameUtils.getBaseName("a/b/c.txt")); + assertEquals("c", FilenameUtils.getBaseName("a/b/c")); + assertEquals("", FilenameUtils.getBaseName("a/b/c/")); + assertEquals("c", FilenameUtils.getBaseName("a\\b\\c")); + assertEquals("file.txt", FilenameUtils.getBaseName("file.txt.bak")); + } + + @Test + public void testGetBaseName_with_nullByte() { + try { + assertEquals("file.txt", FilenameUtils.getBaseName("fil\u0000e.txt.bak")); + } catch (IllegalArgumentException ignore) { + + } + } + + @Test + public void testGetExtension() { + assertEquals(null, FilenameUtils.getExtension(null)); + assertEquals("ext", FilenameUtils.getExtension("file.ext")); + assertEquals("", FilenameUtils.getExtension("README")); + assertEquals("com", FilenameUtils.getExtension("domain.dot.com")); + assertEquals("jpeg", FilenameUtils.getExtension("image.jpeg")); + assertEquals("", FilenameUtils.getExtension("a.b/c")); + assertEquals("txt", FilenameUtils.getExtension("a.b/c.txt")); + assertEquals("", FilenameUtils.getExtension("a/b/c")); + assertEquals("", FilenameUtils.getExtension("a.b\\c")); + assertEquals("txt", FilenameUtils.getExtension("a.b\\c.txt")); + assertEquals("", FilenameUtils.getExtension("a\\b\\c")); + assertEquals("", FilenameUtils.getExtension("C:\\temp\\foo.bar\\README")); + assertEquals("ext", FilenameUtils.getExtension("../filename.ext")); + } + + @Test + public void testRemoveExtension() { + assertEquals(null, FilenameUtils.removeExtension(null)); + assertEquals("file", FilenameUtils.removeExtension("file.ext")); + assertEquals("README", FilenameUtils.removeExtension("README")); + assertEquals("domain.dot", FilenameUtils.removeExtension("domain.dot.com")); + assertEquals("image", FilenameUtils.removeExtension("image.jpeg")); + assertEquals("a.b/c", FilenameUtils.removeExtension("a.b/c")); + assertEquals("a.b/c", FilenameUtils.removeExtension("a.b/c.txt")); + assertEquals("a/b/c", FilenameUtils.removeExtension("a/b/c")); + assertEquals("a.b\\c", FilenameUtils.removeExtension("a.b\\c")); + assertEquals("a.b\\c", FilenameUtils.removeExtension("a.b\\c.txt")); + assertEquals("a\\b\\c", FilenameUtils.removeExtension("a\\b\\c")); + assertEquals("C:\\temp\\foo.bar\\README", FilenameUtils.removeExtension("C:\\temp\\foo.bar\\README")); + assertEquals("../filename", FilenameUtils.removeExtension("../filename.ext")); + } + + //----------------------------------------------------------------------- + @Test + public void testEquals() { + assertTrue(FilenameUtils.equals(null, null)); + assertFalse(FilenameUtils.equals(null, "")); + assertFalse(FilenameUtils.equals("", null)); + assertTrue(FilenameUtils.equals("", "")); + assertTrue(FilenameUtils.equals("file.txt", "file.txt")); + assertFalse(FilenameUtils.equals("file.txt", "FILE.TXT")); + assertFalse(FilenameUtils.equals("a\\b\\file.txt", "a/b/file.txt")); + } + + @Test + public void testEqualsOnSystem() { + assertTrue(FilenameUtils.equalsOnSystem(null, null)); + assertFalse(FilenameUtils.equalsOnSystem(null, "")); + assertFalse(FilenameUtils.equalsOnSystem("", null)); + assertTrue(FilenameUtils.equalsOnSystem("", "")); + assertTrue(FilenameUtils.equalsOnSystem("file.txt", "file.txt")); + assertEquals(WINDOWS, FilenameUtils.equalsOnSystem("file.txt", "FILE.TXT")); + assertFalse(FilenameUtils.equalsOnSystem("a\\b\\file.txt", "a/b/file.txt")); + } + + //----------------------------------------------------------------------- + @Test + public void testEqualsNormalized() { + assertTrue(FilenameUtils.equalsNormalized(null, null)); + assertFalse(FilenameUtils.equalsNormalized(null, "")); + assertFalse(FilenameUtils.equalsNormalized("", null)); + assertTrue(FilenameUtils.equalsNormalized("", "")); + assertTrue(FilenameUtils.equalsNormalized("file.txt", "file.txt")); + assertFalse(FilenameUtils.equalsNormalized("file.txt", "FILE.TXT")); + assertTrue(FilenameUtils.equalsNormalized("a\\b\\file.txt", "a/b/file.txt")); + assertFalse(FilenameUtils.equalsNormalized("a/b/", "a/b")); + } + + @Test + public void testEqualsNormalizedOnSystem() { + assertTrue(FilenameUtils.equalsNormalizedOnSystem(null, null)); + assertFalse(FilenameUtils.equalsNormalizedOnSystem(null, "")); + assertFalse(FilenameUtils.equalsNormalizedOnSystem("", null)); + assertTrue(FilenameUtils.equalsNormalizedOnSystem("", "")); + assertTrue(FilenameUtils.equalsNormalizedOnSystem("file.txt", "file.txt")); + assertEquals(WINDOWS, FilenameUtils.equalsNormalizedOnSystem("file.txt", "FILE.TXT")); + assertTrue(FilenameUtils.equalsNormalizedOnSystem("a\\b\\file.txt", "a/b/file.txt")); + assertFalse(FilenameUtils.equalsNormalizedOnSystem("a/b/", "a/b")); + } + + /** + * Test for https://issues.apache.org/jira/browse/IO-128 + */ + @Test + public void testEqualsNormalizedError_IO_128() { + try { + FilenameUtils.equalsNormalizedOnSystem("//file.txt", "file.txt"); + fail("Invalid normalized first file"); + } catch (final NullPointerException e) { + // expected result + } + try { + FilenameUtils.equalsNormalizedOnSystem("file.txt", "//file.txt"); + fail("Invalid normalized second file"); + } catch (final NullPointerException e) { + // expected result + } + try { + FilenameUtils.equalsNormalizedOnSystem("//file.txt", "//file.txt"); + fail("Invalid normalized both filse"); + } catch (final NullPointerException e) { + // expected result + } + } + + @Test + public void testEquals_fullControl() { + assertFalse(FilenameUtils.equals("file.txt", "FILE.TXT", true, IOCase.SENSITIVE)); + assertTrue(FilenameUtils.equals("file.txt", "FILE.TXT", true, IOCase.INSENSITIVE)); + assertEquals(WINDOWS, FilenameUtils.equals("file.txt", "FILE.TXT", true, IOCase.SYSTEM)); + assertFalse(FilenameUtils.equals("file.txt", "FILE.TXT", true, null)); + } + + //----------------------------------------------------------------------- + @Test + public void testIsExtension() { + assertFalse(FilenameUtils.isExtension(null, (String) null)); + assertFalse(FilenameUtils.isExtension("file.txt", (String) null)); + assertTrue(FilenameUtils.isExtension("file", (String) null)); + assertFalse(FilenameUtils.isExtension("file.txt", "")); + assertTrue(FilenameUtils.isExtension("file", "")); + assertTrue(FilenameUtils.isExtension("file.txt", "txt")); + assertFalse(FilenameUtils.isExtension("file.txt", "rtf")); + + assertFalse(FilenameUtils.isExtension("a/b/file.txt", (String) null)); + assertFalse(FilenameUtils.isExtension("a/b/file.txt", "")); + assertTrue(FilenameUtils.isExtension("a/b/file.txt", "txt")); + assertFalse(FilenameUtils.isExtension("a/b/file.txt", "rtf")); + + assertFalse(FilenameUtils.isExtension("a.b/file.txt", (String) null)); + assertFalse(FilenameUtils.isExtension("a.b/file.txt", "")); + assertTrue(FilenameUtils.isExtension("a.b/file.txt", "txt")); + assertFalse(FilenameUtils.isExtension("a.b/file.txt", "rtf")); + + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", (String) null)); + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", "")); + assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", "txt")); + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", "rtf")); + + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", (String) null)); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", "")); + assertTrue(FilenameUtils.isExtension("a.b\\file.txt", "txt")); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", "rtf")); + + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", "TXT")); + } + + @Test + public void testIsExtension_injection() { + try { + FilenameUtils.isExtension("a.b\\fi\u0000le.txt", "TXT"); + fail("Should throw IAE"); + } catch (IllegalArgumentException ignore) { + } + } + + @Test + public void testIsExtensionArray() { + assertFalse(FilenameUtils.isExtension(null, (String[]) null)); + assertFalse(FilenameUtils.isExtension("file.txt", (String[]) null)); + assertTrue(FilenameUtils.isExtension("file", (String[]) null)); + assertFalse(FilenameUtils.isExtension("file.txt", new String[0])); + assertTrue(FilenameUtils.isExtension("file.txt", new String[]{"txt"})); + assertFalse(FilenameUtils.isExtension("file.txt", new String[]{"rtf"})); + assertTrue(FilenameUtils.isExtension("file", new String[]{"rtf", ""})); + assertTrue(FilenameUtils.isExtension("file.txt", new String[]{"rtf", "txt"})); + + assertFalse(FilenameUtils.isExtension("a/b/file.txt", (String[]) null)); + assertFalse(FilenameUtils.isExtension("a/b/file.txt", new String[0])); + assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[]{"txt"})); + assertFalse(FilenameUtils.isExtension("a/b/file.txt", new String[]{"rtf"})); + assertTrue(FilenameUtils.isExtension("a/b/file.txt", new String[]{"rtf", "txt"})); + + assertFalse(FilenameUtils.isExtension("a.b/file.txt", (String[]) null)); + assertFalse(FilenameUtils.isExtension("a.b/file.txt", new String[0])); + assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[]{"txt"})); + assertFalse(FilenameUtils.isExtension("a.b/file.txt", new String[]{"rtf"})); + assertTrue(FilenameUtils.isExtension("a.b/file.txt", new String[]{"rtf", "txt"})); + + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", (String[]) null)); + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new String[0])); + assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"txt"})); + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"rtf"})); + assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new String[]{"rtf", "txt"})); + + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", (String[]) null)); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[0])); + assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"txt"})); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"rtf"})); + assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"rtf", "txt"})); + + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"TXT"})); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new String[]{"TXT", "RTF"})); + } + + @Test + public void testIsExtensionCollection() { + assertFalse(FilenameUtils.isExtension(null, (Collection) null)); + assertFalse(FilenameUtils.isExtension("file.txt", (Collection) null)); + assertTrue(FilenameUtils.isExtension("file", (Collection) null)); + assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList())); + assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList(Arrays.asList(new String[]{"txt"})))); + assertFalse(FilenameUtils.isExtension("file.txt", new ArrayList(Arrays.asList(new String[]{"rtf"})))); + assertTrue(FilenameUtils.isExtension("file", new ArrayList(Arrays.asList(new String[]{"rtf", ""})))); + assertTrue(FilenameUtils.isExtension("file.txt", new ArrayList(Arrays.asList(new String[]{"rtf", "txt"})))); + + assertFalse(FilenameUtils.isExtension("a/b/file.txt", (Collection) null)); + assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList())); + assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList(Arrays.asList(new String[]{"txt"})))); + assertFalse(FilenameUtils.isExtension("a/b/file.txt", new ArrayList(Arrays.asList(new String[]{"rtf"})))); + assertTrue(FilenameUtils.isExtension("a/b/file.txt", new ArrayList(Arrays.asList(new String[]{"rtf", "txt"})))); + + assertFalse(FilenameUtils.isExtension("a.b/file.txt", (Collection) null)); + assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList())); + assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList(Arrays.asList(new String[]{"txt"})))); + assertFalse(FilenameUtils.isExtension("a.b/file.txt", new ArrayList(Arrays.asList(new String[]{"rtf"})))); + assertTrue(FilenameUtils.isExtension("a.b/file.txt", new ArrayList(Arrays.asList(new String[]{"rtf", "txt"})))); + + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", (Collection) null)); + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList())); + assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList(Arrays.asList(new String[]{"txt"})))); + assertFalse(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList(Arrays.asList(new String[]{"rtf"})))); + assertTrue(FilenameUtils.isExtension("a\\b\\file.txt", new ArrayList(Arrays.asList(new String[]{"rtf", "txt"})))); + + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", (Collection) null)); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList())); + assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList(Arrays.asList(new String[]{"txt"})))); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList(Arrays.asList(new String[]{"rtf"})))); + assertTrue(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList(Arrays.asList(new String[]{"rtf", "txt"})))); + + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList(Arrays.asList(new String[]{"TXT"})))); + assertFalse(FilenameUtils.isExtension("a.b\\file.txt", new ArrayList(Arrays.asList(new String[]{"TXT", "RTF"})))); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..0675b8777c63a0d51e1784a20819cfeab9591262 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/FilenameUtilsWildcardTestCase.java" @@ -0,0 +1,246 @@ +/* + * 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 org.junit.Test; + +import java.io.File; +import java.util.Locale; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class FilenameUtilsWildcardTestCase { + + private static final boolean WINDOWS = File.separatorChar == '\\'; + + //----------------------------------------------------------------------- + // Testing: + // FilenameUtils.wildcardMatch(String,String) + + @Test + public void testMatch() { + assertFalse(FilenameUtils.wildcardMatch(null, "Foo")); + assertFalse(FilenameUtils.wildcardMatch("Foo", null)); + assertTrue(FilenameUtils.wildcardMatch(null, null)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo")); + assertTrue(FilenameUtils.wildcardMatch("", "")); + assertTrue(FilenameUtils.wildcardMatch("", "*")); + assertFalse(FilenameUtils.wildcardMatch("", "?")); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo*")); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo?")); + assertTrue(FilenameUtils.wildcardMatch("Foo Bar and Catflap", "Fo*")); + assertTrue(FilenameUtils.wildcardMatch("New Bookmarks", "N?w ?o?k??r?s")); + assertFalse(FilenameUtils.wildcardMatch("Foo", "Bar")); + assertTrue(FilenameUtils.wildcardMatch("Foo Bar Foo", "F*o Bar*")); + assertTrue(FilenameUtils.wildcardMatch("Adobe Acrobat Installer", "Ad*er")); + assertTrue(FilenameUtils.wildcardMatch("Foo", "*Foo")); + assertTrue(FilenameUtils.wildcardMatch("BarFoo", "*Foo")); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo*")); + assertTrue(FilenameUtils.wildcardMatch("FooBar", "Foo*")); + assertFalse(FilenameUtils.wildcardMatch("FOO", "*Foo")); + assertFalse(FilenameUtils.wildcardMatch("BARFOO", "*Foo")); + assertFalse(FilenameUtils.wildcardMatch("FOO", "Foo*")); + assertFalse(FilenameUtils.wildcardMatch("FOOBAR", "Foo*")); + } + + @Test + public void testMatchOnSystem() { + assertFalse(FilenameUtils.wildcardMatchOnSystem(null, "Foo")); + assertFalse(FilenameUtils.wildcardMatchOnSystem("Foo", null)); + assertTrue(FilenameUtils.wildcardMatchOnSystem(null, null)); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Foo", "Foo")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("", "")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Foo", "Fo*")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Foo", "Fo?")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Foo Bar and Catflap", "Fo*")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("New Bookmarks", "N?w ?o?k??r?s")); + assertFalse(FilenameUtils.wildcardMatchOnSystem("Foo", "Bar")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Foo Bar Foo", "F*o Bar*")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Adobe Acrobat Installer", "Ad*er")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Foo", "*Foo")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("BarFoo", "*Foo")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("Foo", "Foo*")); + assertTrue(FilenameUtils.wildcardMatchOnSystem("FooBar", "Foo*")); + assertEquals(WINDOWS, FilenameUtils.wildcardMatchOnSystem("FOO", "*Foo")); + assertEquals(WINDOWS, FilenameUtils.wildcardMatchOnSystem("BARFOO", "*Foo")); + assertEquals(WINDOWS, FilenameUtils.wildcardMatchOnSystem("FOO", "Foo*")); + assertEquals(WINDOWS, FilenameUtils.wildcardMatchOnSystem("FOOBAR", "Foo*")); + } + + @Test + public void testMatchCaseSpecified() { + assertFalse(FilenameUtils.wildcardMatch(null, "Foo", IOCase.SENSITIVE)); + assertFalse(FilenameUtils.wildcardMatch("Foo", null, IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch(null, null, IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("", "", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo*", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Fo?", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo Bar and Catflap", "Fo*", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("New Bookmarks", "N?w ?o?k??r?s", IOCase.SENSITIVE)); + assertFalse(FilenameUtils.wildcardMatch("Foo", "Bar", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo Bar Foo", "F*o Bar*", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Adobe Acrobat Installer", "Ad*er", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "*Foo", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo*", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "*Foo", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("BarFoo", "*Foo", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("Foo", "Foo*", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("FooBar", "Foo*", IOCase.SENSITIVE)); + + assertFalse(FilenameUtils.wildcardMatch("FOO", "*Foo", IOCase.SENSITIVE)); + assertFalse(FilenameUtils.wildcardMatch("BARFOO", "*Foo", IOCase.SENSITIVE)); + assertFalse(FilenameUtils.wildcardMatch("FOO", "Foo*", IOCase.SENSITIVE)); + assertFalse(FilenameUtils.wildcardMatch("FOOBAR", "Foo*", IOCase.SENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("FOO", "*Foo", IOCase.INSENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("BARFOO", "*Foo", IOCase.INSENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("FOO", "Foo*", IOCase.INSENSITIVE)); + assertTrue(FilenameUtils.wildcardMatch("FOOBAR", "Foo*", IOCase.INSENSITIVE)); + assertEquals(WINDOWS, FilenameUtils.wildcardMatch("FOO", "*Foo", IOCase.SYSTEM)); + assertEquals(WINDOWS, FilenameUtils.wildcardMatch("BARFOO", "*Foo", IOCase.SYSTEM)); + assertEquals(WINDOWS, FilenameUtils.wildcardMatch("FOO", "Foo*", IOCase.SYSTEM)); + assertEquals(WINDOWS, FilenameUtils.wildcardMatch("FOOBAR", "Foo*", IOCase.SYSTEM)); + } + + @Test + public void testSplitOnTokens() { + assertArrayEquals(new String[] { "Ad", "*", "er" }, FilenameUtils.splitOnTokens("Ad*er")); + assertArrayEquals(new String[] { "Ad", "?", "er" }, FilenameUtils.splitOnTokens("Ad?er")); + assertArrayEquals(new String[] { "Test", "*", "?", "One" }, FilenameUtils.splitOnTokens("Test*?One")); + assertArrayEquals(new String[] { "Test", "?", "*", "One" }, FilenameUtils.splitOnTokens("Test?*One")); + assertArrayEquals(new String[] { "*" }, FilenameUtils.splitOnTokens("****")); + assertArrayEquals(new String[] { "*", "?", "?", "*" }, FilenameUtils.splitOnTokens("*??*")); + assertArrayEquals(new String[] { "*", "?", "*", "?", "*" }, FilenameUtils.splitOnTokens("*?**?*")); + assertArrayEquals(new String[] { "*", "?", "*", "?", "*" }, FilenameUtils.splitOnTokens("*?***?*")); + assertArrayEquals(new String[] { "h", "?", "?", "*" }, FilenameUtils.splitOnTokens("h??*")); + assertArrayEquals(new String[] { "" }, FilenameUtils.splitOnTokens("")); + } + + private void assertMatch(final String text, final String wildcard, final boolean expected) { + assertEquals(text + " " + wildcard, expected, FilenameUtils.wildcardMatch(text, wildcard)); + } + + // A separate set of tests, added to this batch + @Test + public void testMatch2() { + assertMatch("log.txt", "log.txt", true); + assertMatch("log.txt1", "log.txt", false); + + assertMatch("log.txt", "log.txt*", true); + assertMatch("log.txt", "log.txt*1", false); + assertMatch("log.txt", "*log.txt*", true); + + assertMatch("log.txt", "*.txt", true); + assertMatch("txt.log", "*.txt", false); + assertMatch("config.ini", "*.ini", true); + + assertMatch("config.txt.bak", "con*.txt", false); + + assertMatch("log.txt9", "*.txt?", true); + assertMatch("log.txt", "*.txt?", false); + + assertMatch("progtestcase.java~5~", "*test*.java~*~", true); + assertMatch("progtestcase.java;5~", "*test*.java~*~", false); + assertMatch("progtestcase.java~5", "*test*.java~*~", false); + + assertMatch("log.txt", "log.*", true); + + assertMatch("log.txt", "log?*", true); + + assertMatch("log.txt12", "log.txt??", true); + + assertMatch("log.log", "log**log", true); + assertMatch("log.log", "log**", true); + assertMatch("log.log", "log.**", true); + assertMatch("log.log", "**.log", true); + assertMatch("log.log", "**log", true); + + assertMatch("log.log", "log*log", true); + assertMatch("log.log", "log*", true); + assertMatch("log.log", "log.*", true); + assertMatch("log.log", "*.log", true); + assertMatch("log.log", "*log", true); + + assertMatch("log.log", "*log?", false); + assertMatch("log.log", "*log?*", true); + assertMatch("log.log.abc", "*log?abc", true); + assertMatch("log.log.abc.log.abc", "*log?abc", true); + assertMatch("log.log.abc.log.abc.d", "*log?abc?d", true); + } + + /** + * See https://issues.apache.org/jira/browse/IO-246 + */ + @Test + public void test_IO_246() { + + // Tests for "*?" + assertMatch("aaa", "aa*?", true); + // these ought to work as well, but "*?" does not work properly at present +// assertMatch("aaa", "a*?", true); +// assertMatch("aaa", "*?", true); + + // Tests for "?*" + assertMatch("", "?*", false); + assertMatch("a", "a?*", false); + assertMatch("aa", "aa?*", false); + assertMatch("a", "?*", true); + assertMatch("aa", "?*", true); + assertMatch("aaa", "?*", true); + + // Test ending on "?" + assertMatch("", "?", false); + assertMatch("a", "a?", false); + assertMatch("aa", "aa?", false); + assertMatch("aab", "aa?", true); + assertMatch("aaa", "*a", true); + } + + @Test + public void testLocaleIndependence() { + final Locale orig = Locale.getDefault(); + + final Locale[] locales = Locale.getAvailableLocales(); + + final String[][] data = { + { "I", "i"}, + { "i", "I"}, + { "i", "\u0130"}, + { "i", "\u0131"}, + { "\u03A3", "\u03C2"}, + { "\u03A3", "\u03C3"}, + { "\u03C2", "\u03C3"}, + }; + + try { + for (int i = 0; i < data.length; i++) { + for (final Locale locale : locales) { + Locale.setDefault(locale); + assertTrue("Test data corrupt: " + i, data[i][0].equalsIgnoreCase(data[i][1])); + final boolean match = FilenameUtils.wildcardMatch(data[i][0], data[i][1], IOCase.INSENSITIVE); + assertTrue(Locale.getDefault().toString() + ": " + i, match); + } + } + } finally { + Locale.setDefault(orig); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/HexDumpTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/HexDumpTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..68ab424857593284ec106825eb9a709346512521 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/HexDumpTest.java" @@ -0,0 +1,242 @@ +/* + * 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 org.apache.commons.io.output.ByteArrayOutputStream; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + + +/** + * @version $Id: HexDumpTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class HexDumpTest { + + private char toHex(final int n) { + final char[] hexChars = + { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; + + return hexChars[n % 16]; + } + + @Test + public void testDump() + throws IOException { + final byte[] testArray = new byte[256]; + + for (int j = 0; j < 256; j++) { + testArray[j] = (byte) j; + } + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + + HexDump.dump(testArray, 0, stream, 0); + byte[] outputArray = new byte[16 * (73 + HexDump.EOL.length())]; + + for (int j = 0; j < 16; j++) { + int offset = (73 + HexDump.EOL.length()) * j; + + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) toHex(j); + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) ' '; + for (int k = 0; k < 16; k++) { + outputArray[offset++] = (byte) toHex(j); + outputArray[offset++] = (byte) toHex(k); + outputArray[offset++] = (byte) ' '; + } + for (int k = 0; k < 16; k++) { + outputArray[offset++] = (byte) toAscii((j * 16) + k); + } + System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset, + HexDump.EOL.getBytes().length); + } + byte[] actualOutput = stream.toByteArray(); + + assertEquals("array size mismatch", outputArray.length, + actualOutput.length); + for (int j = 0; j < outputArray.length; j++) { + assertEquals("array[ " + j + "] mismatch", outputArray[j], + actualOutput[j]); + } + + // verify proper behavior with non-zero offset + stream = new ByteArrayOutputStream(); + HexDump.dump(testArray, 0x10000000, stream, 0); + outputArray = new byte[16 * (73 + HexDump.EOL.length())]; + for (int j = 0; j < 16; j++) { + int offset = (73 + HexDump.EOL.length()) * j; + + outputArray[offset++] = (byte) '1'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) toHex(j); + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) ' '; + for (int k = 0; k < 16; k++) { + outputArray[offset++] = (byte) toHex(j); + outputArray[offset++] = (byte) toHex(k); + outputArray[offset++] = (byte) ' '; + } + for (int k = 0; k < 16; k++) { + outputArray[offset++] = (byte) toAscii((j * 16) + k); + } + System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset, + HexDump.EOL.getBytes().length); + } + actualOutput = stream.toByteArray(); + assertEquals("array size mismatch", outputArray.length, + actualOutput.length); + for (int j = 0; j < outputArray.length; j++) { + assertEquals("array[ " + j + "] mismatch", outputArray[j], + actualOutput[j]); + } + + // verify proper behavior with negative offset + stream = new ByteArrayOutputStream(); + HexDump.dump(testArray, 0xFF000000, stream, 0); + outputArray = new byte[16 * (73 + HexDump.EOL.length())]; + for (int j = 0; j < 16; j++) { + int offset = (73 + HexDump.EOL.length()) * j; + + outputArray[offset++] = (byte) 'F'; + outputArray[offset++] = (byte) 'F'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) toHex(j); + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) ' '; + for (int k = 0; k < 16; k++) { + outputArray[offset++] = (byte) toHex(j); + outputArray[offset++] = (byte) toHex(k); + outputArray[offset++] = (byte) ' '; + } + for (int k = 0; k < 16; k++) { + outputArray[offset++] = (byte) toAscii((j * 16) + k); + } + System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset, + HexDump.EOL.getBytes().length); + } + actualOutput = stream.toByteArray(); + assertEquals("array size mismatch", outputArray.length, + actualOutput.length); + for (int j = 0; j < outputArray.length; j++) { + assertEquals("array[ " + j + "] mismatch", outputArray[j], + actualOutput[j]); + } + + // verify proper behavior with non-zero index + stream = new ByteArrayOutputStream(); + HexDump.dump(testArray, 0x10000000, stream, 0x81); + outputArray = new byte[(8 * (73 + HexDump.EOL.length())) - 1]; + for (int j = 0; j < 8; j++) { + int offset = (73 + HexDump.EOL.length()) * j; + + outputArray[offset++] = (byte) '1'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) '0'; + outputArray[offset++] = (byte) toHex(j + 8); + outputArray[offset++] = (byte) '1'; + outputArray[offset++] = (byte) ' '; + for (int k = 0; k < 16; k++) { + final int index = 0x81 + (j * 16) + k; + + if (index < 0x100) { + outputArray[offset++] = (byte) toHex(index / 16); + outputArray[offset++] = (byte) toHex(index); + } else { + outputArray[offset++] = (byte) ' '; + outputArray[offset++] = (byte) ' '; + } + outputArray[offset++] = (byte) ' '; + } + for (int k = 0; k < 16; k++) { + final int index = 0x81 + (j * 16) + k; + + if (index < 0x100) { + outputArray[offset++] = (byte) toAscii(index); + } + } + System.arraycopy(HexDump.EOL.getBytes(), 0, outputArray, offset, + HexDump.EOL.getBytes().length); + } + actualOutput = stream.toByteArray(); + assertEquals("array size mismatch", outputArray.length, + actualOutput.length); + for (int j = 0; j < outputArray.length; j++) { + assertEquals("array[ " + j + "] mismatch", outputArray[j], + actualOutput[j]); + } + + // verify proper behavior with negative index + try { + HexDump.dump(testArray, 0x10000000, new ByteArrayOutputStream(), + -1); + fail("should have caught ArrayIndexOutOfBoundsException on negative index"); + } catch (final ArrayIndexOutOfBoundsException ignored_exception) { + + // as expected + } + + // verify proper behavior with index that is too large + try { + HexDump.dump(testArray, 0x10000000, new ByteArrayOutputStream(), + testArray.length); + fail("should have caught ArrayIndexOutOfBoundsException on large index"); + } catch (final ArrayIndexOutOfBoundsException ignored_exception) { + + // as expected + } + + // verify proper behavior with null stream + try { + HexDump.dump(testArray, 0x10000000, null, 0); + fail("should have caught IllegalArgumentException on negative index"); + } catch (final IllegalArgumentException ignored_exception) { + + // as expected + } + } + + private char toAscii(final int c) { + char rval = '.'; + + if ((c >= 32) && (c <= 126)) { + rval = (char) c; + } + return rval; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOCaseTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOCaseTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..939dfa043553eaadded176b5926091c47f9e961d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOCaseTestCase.java" @@ -0,0 +1,383 @@ +/* + * 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.ByteArrayOutputStream; +import java.io.File; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This is used to test IOCase for correctness. + * + * @version $Id: IOCaseTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class IOCaseTestCase extends FileBasedTestCase { + + private static final boolean WINDOWS = File.separatorChar == '\\'; + + //----------------------------------------------------------------------- + @Test + public void test_forName() throws Exception { + assertEquals(IOCase.SENSITIVE, IOCase.forName("Sensitive")); + assertEquals(IOCase.INSENSITIVE, IOCase.forName("Insensitive")); + assertEquals(IOCase.SYSTEM, IOCase.forName("System")); + try { + IOCase.forName("Blah"); + fail(); + } catch (final IllegalArgumentException ignore) {} + try { + IOCase.forName(null); + fail(); + } catch (final IllegalArgumentException ignore) {} + } + + @Test + public void test_serialization() throws Exception { + assertSame(IOCase.SENSITIVE, serialize(IOCase.SENSITIVE)); + assertSame(IOCase.INSENSITIVE, serialize(IOCase.INSENSITIVE)); + assertSame(IOCase.SYSTEM, serialize(IOCase.SYSTEM)); + } + + @Test + public void test_getName() throws Exception { + assertEquals("Sensitive", IOCase.SENSITIVE.getName()); + assertEquals("Insensitive", IOCase.INSENSITIVE.getName()); + assertEquals("System", IOCase.SYSTEM.getName()); + } + + @Test + public void test_toString() throws Exception { + assertEquals("Sensitive", IOCase.SENSITIVE.toString()); + assertEquals("Insensitive", IOCase.INSENSITIVE.toString()); + assertEquals("System", IOCase.SYSTEM.toString()); + } + + @Test + public void test_isCaseSensitive() throws Exception { + assertTrue(IOCase.SENSITIVE.isCaseSensitive()); + assertFalse(IOCase.INSENSITIVE.isCaseSensitive()); + assertEquals(!WINDOWS, IOCase.SYSTEM.isCaseSensitive()); + } + //----------------------------------------------------------------------- + @Test + public void test_checkCompare_functionality() throws Exception { + assertTrue(IOCase.SENSITIVE.checkCompareTo("ABC", "") > 0); + assertTrue(IOCase.SENSITIVE.checkCompareTo("", "ABC") < 0); + assertTrue(IOCase.SENSITIVE.checkCompareTo("ABC", "DEF") < 0); + assertTrue(IOCase.SENSITIVE.checkCompareTo("DEF", "ABC") > 0); + assertEquals(0, IOCase.SENSITIVE.checkCompareTo("ABC", "ABC")); + assertEquals(0, IOCase.SENSITIVE.checkCompareTo("", "")); + + try { + IOCase.SENSITIVE.checkCompareTo("ABC", null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkCompareTo(null, "ABC"); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkCompareTo(null, null); + fail(); + } catch (final NullPointerException ignore) {} + } + + @Test + public void test_checkCompare_case() throws Exception { + assertEquals(0, IOCase.SENSITIVE.checkCompareTo("ABC", "ABC")); + assertTrue(IOCase.SENSITIVE.checkCompareTo("ABC", "abc") < 0); + assertTrue(IOCase.SENSITIVE.checkCompareTo("abc", "ABC") > 0); + + assertEquals(0, IOCase.INSENSITIVE.checkCompareTo("ABC", "ABC")); + assertEquals(0, IOCase.INSENSITIVE.checkCompareTo("ABC", "abc")); + assertEquals(0, IOCase.INSENSITIVE.checkCompareTo("abc", "ABC")); + + assertEquals(0, IOCase.SYSTEM.checkCompareTo("ABC", "ABC")); + assertEquals(WINDOWS, IOCase.SYSTEM.checkCompareTo("ABC", "abc") == 0); + assertEquals(WINDOWS, IOCase.SYSTEM.checkCompareTo("abc", "ABC") == 0); + } + + + //----------------------------------------------------------------------- + @Test + public void test_checkEquals_functionality() throws Exception { + assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "")); + assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "A")); + assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "AB")); + assertTrue(IOCase.SENSITIVE.checkEquals("ABC", "ABC")); + assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "BC")); + assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "C")); + assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "ABCD")); + assertFalse(IOCase.SENSITIVE.checkEquals("", "ABC")); + assertTrue(IOCase.SENSITIVE.checkEquals("", "")); + + try { + IOCase.SENSITIVE.checkEquals("ABC", null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkEquals(null, "ABC"); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkEquals(null, null); + fail(); + } catch (final NullPointerException ignore) {} + } + + @Test + public void test_checkEquals_case() throws Exception { + assertTrue(IOCase.SENSITIVE.checkEquals("ABC", "ABC")); + assertFalse(IOCase.SENSITIVE.checkEquals("ABC", "Abc")); + + assertTrue(IOCase.INSENSITIVE.checkEquals("ABC", "ABC")); + assertTrue(IOCase.INSENSITIVE.checkEquals("ABC", "Abc")); + + assertTrue(IOCase.SYSTEM.checkEquals("ABC", "ABC")); + assertEquals(WINDOWS, IOCase.SYSTEM.checkEquals("ABC", "Abc")); + } + + //----------------------------------------------------------------------- + @Test + public void test_checkStartsWith_functionality() throws Exception { + assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", "")); + assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", "A")); + assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", "AB")); + assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", "ABC")); + assertFalse(IOCase.SENSITIVE.checkStartsWith("ABC", "BC")); + assertFalse(IOCase.SENSITIVE.checkStartsWith("ABC", "C")); + assertFalse(IOCase.SENSITIVE.checkStartsWith("ABC", "ABCD")); + assertFalse(IOCase.SENSITIVE.checkStartsWith("", "ABC")); + assertTrue(IOCase.SENSITIVE.checkStartsWith("", "")); + + try { + IOCase.SENSITIVE.checkStartsWith("ABC", null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkStartsWith(null, "ABC"); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkStartsWith(null, null); + fail(); + } catch (final NullPointerException ignore) {} + } + + @Test + public void test_checkStartsWith_case() throws Exception { + assertTrue(IOCase.SENSITIVE.checkStartsWith("ABC", "AB")); + assertFalse(IOCase.SENSITIVE.checkStartsWith("ABC", "Ab")); + + assertTrue(IOCase.INSENSITIVE.checkStartsWith("ABC", "AB")); + assertTrue(IOCase.INSENSITIVE.checkStartsWith("ABC", "Ab")); + + assertTrue(IOCase.SYSTEM.checkStartsWith("ABC", "AB")); + assertEquals(WINDOWS, IOCase.SYSTEM.checkStartsWith("ABC", "Ab")); + } + + //----------------------------------------------------------------------- + @Test + public void test_checkEndsWith_functionality() throws Exception { + assertTrue(IOCase.SENSITIVE.checkEndsWith("ABC", "")); + assertFalse(IOCase.SENSITIVE.checkEndsWith("ABC", "A")); + assertFalse(IOCase.SENSITIVE.checkEndsWith("ABC", "AB")); + assertTrue(IOCase.SENSITIVE.checkEndsWith("ABC", "ABC")); + assertTrue(IOCase.SENSITIVE.checkEndsWith("ABC", "BC")); + assertTrue(IOCase.SENSITIVE.checkEndsWith("ABC", "C")); + assertFalse(IOCase.SENSITIVE.checkEndsWith("ABC", "ABCD")); + assertFalse(IOCase.SENSITIVE.checkEndsWith("", "ABC")); + assertTrue(IOCase.SENSITIVE.checkEndsWith("", "")); + + try { + IOCase.SENSITIVE.checkEndsWith("ABC", null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkEndsWith(null, "ABC"); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkEndsWith(null, null); + fail(); + } catch (final NullPointerException ignore) {} + } + + @Test + public void test_checkEndsWith_case() throws Exception { + assertTrue(IOCase.SENSITIVE.checkEndsWith("ABC", "BC")); + assertFalse(IOCase.SENSITIVE.checkEndsWith("ABC", "Bc")); + + assertTrue(IOCase.INSENSITIVE.checkEndsWith("ABC", "BC")); + assertTrue(IOCase.INSENSITIVE.checkEndsWith("ABC", "Bc")); + + assertTrue(IOCase.SYSTEM.checkEndsWith("ABC", "BC")); + assertEquals(WINDOWS, IOCase.SYSTEM.checkEndsWith("ABC", "Bc")); + } + + //----------------------------------------------------------------------- + @Test + public void test_checkIndexOf_functionality() throws Exception { + + // start + assertEquals(0, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "A")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 1, "A")); + assertEquals(0, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "AB")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 1, "AB")); + assertEquals(0, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "ABC")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 1, "ABC")); + + // middle + assertEquals(3, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "D")); + assertEquals(3, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 3, "D")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 4, "D")); + assertEquals(3, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "DE")); + assertEquals(3, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 3, "DE")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 4, "DE")); + assertEquals(3, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "DEF")); + assertEquals(3, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 3, "DEF")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 4, "DEF")); + + // end + assertEquals(9, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "J")); + assertEquals(9, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 8, "J")); + assertEquals(9, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 9, "J")); + assertEquals(8, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "IJ")); + assertEquals(8, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 8, "IJ")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 9, "IJ")); + assertEquals(7, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 6, "HIJ")); + assertEquals(7, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 7, "HIJ")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 8, "HIJ")); + + // not found + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABCDEFGHIJ", 0, "DED")); + + // too long + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("DEF", 0, "ABCDEFGHIJ")); + + try { + IOCase.SENSITIVE.checkIndexOf("ABC", 0, null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkIndexOf(null, 0, "ABC"); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkIndexOf(null, 0, null); + fail(); + } catch (final NullPointerException ignore) {} + } + + @Test + public void test_checkIndexOf_case() throws Exception { + assertEquals(1, IOCase.SENSITIVE.checkIndexOf("ABC", 0, "BC")); + assertEquals(-1, IOCase.SENSITIVE.checkIndexOf("ABC", 0, "Bc")); + + assertEquals(1, IOCase.INSENSITIVE.checkIndexOf("ABC", 0, "BC")); + assertEquals(1, IOCase.INSENSITIVE.checkIndexOf("ABC", 0, "Bc")); + + assertEquals(1, IOCase.SYSTEM.checkIndexOf("ABC", 0, "BC")); + assertEquals(WINDOWS ? 1 : -1, IOCase.SYSTEM.checkIndexOf("ABC", 0, "Bc")); + } + + //----------------------------------------------------------------------- + @Test + public void test_checkRegionMatches_functionality() throws Exception { + assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "")); + assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "A")); + assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "AB")); + assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "ABC")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "BC")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "C")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "ABCD")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("", 0, "ABC")); + assertTrue(IOCase.SENSITIVE.checkRegionMatches("", 0, "")); + + assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 1, "")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 1, "A")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 1, "AB")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 1, "ABC")); + assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 1, "BC")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 1, "C")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 1, "ABCD")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("", 1, "ABC")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("", 1, "")); + + try { + IOCase.SENSITIVE.checkRegionMatches("ABC", 0, null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkRegionMatches(null, 0, "ABC"); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkRegionMatches(null, 0, null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkRegionMatches("ABC", 1, null); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkRegionMatches(null, 1, "ABC"); + fail(); + } catch (final NullPointerException ignore) {} + try { + IOCase.SENSITIVE.checkRegionMatches(null, 1, null); + fail(); + } catch (final NullPointerException ignore) {} + } + + @Test + public void test_checkRegionMatches_case() throws Exception { + assertTrue(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "AB")); + assertFalse(IOCase.SENSITIVE.checkRegionMatches("ABC", 0, "Ab")); + + assertTrue(IOCase.INSENSITIVE.checkRegionMatches("ABC", 0, "AB")); + assertTrue(IOCase.INSENSITIVE.checkRegionMatches("ABC", 0, "Ab")); + + assertTrue(IOCase.SYSTEM.checkRegionMatches("ABC", 0, "AB")); + assertEquals(WINDOWS, IOCase.SYSTEM.checkRegionMatches("ABC", 0, "Ab")); + } + + //----------------------------------------------------------------------- + private IOCase serialize(final IOCase value) throws Exception { + final ByteArrayOutputStream buf = new ByteArrayOutputStream(); + final ObjectOutputStream out = new ObjectOutputStream(buf); + out.writeObject(value); + out.flush(); + out.close(); + + final ByteArrayInputStream bufin = new ByteArrayInputStream(buf.toByteArray()); + final ObjectInputStream in = new ObjectInputStream(bufin); + return (IOCase) in.readObject(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..177e0c8873bb3681b297ebf2429f6a6e962251ea --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOExceptionWithCauseTestCase.java" @@ -0,0 +1,61 @@ +/* + * 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 junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + +/** + * Tests IOExceptionWithCause + * + * @version $Id: IOExceptionWithCauseTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class IOExceptionWithCauseTestCase { + + /** + * Tests the {@link IOExceptionWithCause#IOExceptionWithCause(String,Throwable)} constructor. + */ + @Test + public void testIOExceptionStringThrowable() { + final Throwable cause = new IllegalArgumentException("cause"); + final IOException exception = new IOException("message", cause); + this.validate(exception, cause, "message"); + } + + /** + * Tests the {@link IOExceptionWithCause#IOExceptionWithCause(Throwable)} constructor. + */ + + @Test + public void testIOExceptionThrowable() { + final Throwable cause = new IllegalArgumentException("cause"); + final IOException exception = new IOException(cause); + this.validate(exception, cause, "java.lang.IllegalArgumentException: cause"); + } + + void validate(final Throwable throwable, final Throwable expectedCause, final String expectedMessage) { + assertEquals(expectedMessage, throwable.getMessage()); + assertEquals(expectedCause, throwable.getCause()); + assertSame(expectedCause, throwable.getCause()); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..e30a3f575162d3b19c57b11b8ecbe3505885f51f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsCopyTestCase.java" @@ -0,0 +1,381 @@ +/* + * 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 org.apache.commons.io.input.NullInputStream; +import org.apache.commons.io.input.NullReader; +import org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.io.output.NullOutputStream; +import org.apache.commons.io.output.NullWriter; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.apache.commons.io.testtools.YellOnCloseInputStream; +import org.apache.commons.io.testtools.YellOnFlushAndCloseOutputStream; +import org.junit.Test; + +import java.io.*; +import java.util.Arrays; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * JUnit tests for IOUtils copy methods. + * + * @version $Id: IOUtilsCopyTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + * @see IOUtils + */ +public class IOUtilsCopyTestCase extends FileBasedTestCase { + + /* + * NOTE this is not particularly beautiful code. A better way to check for + * flush and close status would be to implement "trojan horse" wrapper + * implementations of the various stream classes, which set a flag when + * relevant methods are called. (JT) + */ + + private static final int FILE_SIZE = 1024 * 4 + 1; + + + private final byte[] inData = TestUtils.generateTestData((long) FILE_SIZE); + + //----------------------------------------------------------------------- + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_inputStreamToOutputStream() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + final int count = IOUtils.copy(in, out); + + assertEquals("Not all bytes were read", 0, in.available()); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + assertEquals(inData.length,count); + } + + @Test + public void testCopy_inputStreamToOutputStreamWithBufferSize() throws Exception { + testCopy_inputStreamToOutputStreamWithBufferSize(1); + testCopy_inputStreamToOutputStreamWithBufferSize(2); + testCopy_inputStreamToOutputStreamWithBufferSize(4); + testCopy_inputStreamToOutputStreamWithBufferSize(8); + testCopy_inputStreamToOutputStreamWithBufferSize(16); + testCopy_inputStreamToOutputStreamWithBufferSize(32); + testCopy_inputStreamToOutputStreamWithBufferSize(64); + testCopy_inputStreamToOutputStreamWithBufferSize(128); + testCopy_inputStreamToOutputStreamWithBufferSize(256); + testCopy_inputStreamToOutputStreamWithBufferSize(512); + testCopy_inputStreamToOutputStreamWithBufferSize(1024); + testCopy_inputStreamToOutputStreamWithBufferSize(2048); + testCopy_inputStreamToOutputStreamWithBufferSize(4096); + testCopy_inputStreamToOutputStreamWithBufferSize(8192); + testCopy_inputStreamToOutputStreamWithBufferSize(16384); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + private void testCopy_inputStreamToOutputStreamWithBufferSize(final int bufferSize) throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + final long count = IOUtils.copy(in, out, bufferSize); + + assertEquals("Not all bytes were read", 0, in.available()); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + assertEquals(inData.length,count); + } + + @Test(expected = NullPointerException.class) + public void testCopy_inputStreamToOutputStream_nullIn() throws Exception { + final OutputStream out = new ByteArrayOutputStream(); + IOUtils.copy((InputStream) null, out); + } + + @Test(expected = NullPointerException.class) + public void testCopy_inputStreamToOutputStream_nullOut() throws Exception { + final InputStream in = new ByteArrayInputStream(inData); + IOUtils.copy(in, (OutputStream) null); + } + + /* + * Test Copying file > 2GB - see issue# IO-84 + */ + @Test + public void testCopy_inputStreamToOutputStream_IO84() throws Exception { + final long size = (long)Integer.MAX_VALUE + (long)1; + final InputStream in = new NullInputStream(size); + final OutputStream out = new NullOutputStream(); + + // Test copy() method + assertEquals(-1, IOUtils.copy(in, out)); + + // reset the input + in.close(); + + // Test copyLarge() method + assertEquals("copyLarge()", size, IOUtils.copyLarge(in, out)); + } + + //----------------------------------------------------------------------- + @SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed + @Test + public void testCopy_inputStreamToWriter() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.copy(in, writer); // deliberately testing deprecated method + out.off(); + writer.flush(); + + assertEquals("Not all bytes were read", 0, in.available()); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test(expected = NullPointerException.class) + public void testCopy_inputStreamToWriter_nullIn() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(out, "US-ASCII"); + IOUtils.copy((InputStream) null, writer); + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test(expected = NullPointerException.class) + public void testCopy_inputStreamToWriter_nullOut() throws Exception { + final InputStream in = new ByteArrayInputStream(inData); + IOUtils.copy(in, (Writer) null); // deliberately testing deprecated method + } + + //----------------------------------------------------------------------- + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_inputStreamToWriter_Encoding() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.copy(in, writer, "UTF8"); + out.off(); + writer.flush(); + + assertEquals("Not all bytes were read", 0, in.available()); + byte[] bytes = baout.toByteArray(); + bytes = new String(bytes, "UTF8").getBytes("US-ASCII"); + assertTrue("Content differs", Arrays.equals(inData, bytes)); + } + + @Test(expected = NullPointerException.class) + public void testCopy_inputStreamToWriter_Encoding_nullIn() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(out, "US-ASCII"); + IOUtils.copy(null, writer, "UTF8"); + } + + @Test(expected = NullPointerException.class) + public void testCopy_inputStreamToWriter_Encoding_nullOut() throws Exception { + final InputStream in = new ByteArrayInputStream(inData); + IOUtils.copy(in, null, "UTF8"); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_inputStreamToWriter_Encoding_nullEncoding() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.copy(in, writer, (String) null); + out.off(); + writer.flush(); + + assertEquals("Not all bytes were read", 0, in.available()); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + //----------------------------------------------------------------------- + @SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed + @Test + public void testCopy_readerToOutputStream() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new InputStreamReader(in, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.copy(reader, out); // deliberately testing deprecated method + //Note: this method *does* flush. It is equivalent to: + // OutputStreamWriter _out = new OutputStreamWriter(fout); + // IOUtils.copy( fin, _out, 4096 ); // copy( Reader, Writer, int ); + // _out.flush(); + // out = fout; + + // Note: rely on the method to flush + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @SuppressWarnings("deprecation") + @Test(expected = NullPointerException.class) + public void testCopy_readerToOutputStream_nullIn() throws Exception { // deliberately testing deprecated method + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + IOUtils.copy((Reader) null, out); + } + + @SuppressWarnings({ "resource", "deprecation" }) // 'in' is deliberately not closed + @Test(expected = NullPointerException.class) + public void testCopy_readerToOutputStream_nullOut() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new InputStreamReader(in, "US-ASCII"); + IOUtils.copy(reader, (OutputStream) null); // deliberately testing deprecated method + } + + //----------------------------------------------------------------------- + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_readerToOutputStream_Encoding() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new InputStreamReader(in, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.copy(reader, out, "UTF16"); + // note: this method *does* flush. + // note: we don't flush here; this IOUtils method does it for us + + byte[] bytes = baout.toByteArray(); + bytes = new String(bytes, "UTF16").getBytes("US-ASCII"); + assertTrue("Content differs", Arrays.equals(inData, bytes)); + } + + @Test(expected = NullPointerException.class) + public void testCopy_readerToOutputStream_Encoding_nullIn() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + IOUtils.copy(null, out, "UTF16"); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test(expected = NullPointerException.class) + public void testCopy_readerToOutputStream_Encoding_nullOut() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new InputStreamReader(in, "US-ASCII"); + IOUtils.copy(reader, null, "UTF16"); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_readerToOutputStream_Encoding_nullEncoding() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new InputStreamReader(in, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.copy(reader, out, (String) null); + // note: this method *does* flush. + // note: we don't flush here; this IOUtils method does it for us + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + //----------------------------------------------------------------------- + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test + public void testCopy_readerToWriter() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new InputStreamReader(in, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + final int count = IOUtils.copy(reader, writer); + out.off(); + writer.flush(); + assertEquals("The number of characters returned by copy is wrong", inData.length, count); + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test(expected = NullPointerException.class) + public void testCopy_readerToWriter_nullIn() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final OutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(out, "US-ASCII"); + IOUtils.copy((Reader) null, writer); + } + + @SuppressWarnings("resource") // 'in' is deliberately not closed + @Test(expected = NullPointerException.class) + public void testCopy_readerToWriter_nullOut() throws Exception { + InputStream in = new ByteArrayInputStream(inData); + in = new YellOnCloseInputStream(in); + final Reader reader = new InputStreamReader(in, "US-ASCII"); + IOUtils.copy(reader, (Writer) null); + } + + /* + * Test Copying file > 2GB - see issue# IO-84 + */ + @Test + public void testCopy_readerToWriter_IO84() throws Exception { + final long size = (long)Integer.MAX_VALUE + (long)1; + final Reader reader = new NullReader(size); + final Writer writer = new NullWriter(); + + // Test copy() method + assertEquals(-1, IOUtils.copy(reader, writer)); + + // reset the input + reader.close(); + + // Test copyLarge() method + assertEquals("copyLarge()", size, IOUtils.copyLarge(reader, writer)); + + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..3dc5dec614ee4d960ad7c753a5cbceaf144706db --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsTestCase.java" @@ -0,0 +1,1378 @@ +/* + * 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 org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.io.*; +import java.net.*; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.channels.Selector; +import java.util.Arrays; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This is used to test IOUtils for correctness. The following checks are performed: + *
    + *
  • The return must not be null, must be the same type and equals() to the method's second arg
  • + *
  • All bytes must have been read from the source (available() == 0)
  • + *
  • The source and destination content must be identical (byte-wise comparison check)
  • + *
  • The output stream must not have been closed (a byte/char is written to test this, and subsequent size checked)
  • + *
+ * Due to interdependencies in IOUtils and IOUtilsTestlet, one bug may cause multiple tests to fail. + */ +public class IOUtilsTestCase extends FileBasedTestCase { + + private static final int FILE_SIZE = 1024 * 4 + 1; + + /** Determine if this is windows. */ + private static final boolean WINDOWS = File.separatorChar == '\\'; + /* + * Note: this is not particularly beautiful code. A better way to check for flush and close status would be to + * implement "trojan horse" wrapper implementations of the various stream classes, which set a flag when relevant + * methods are called. (JT) + */ + + private char[] carr = null; + + private byte[] iarr = null; + + private File m_testFile; + + /** Assert that the contents of two byte arrays are the same. */ + private void assertEqualContent(final byte[] b0, final byte[] b1) { + assertTrue("Content not equal according to java.util.Arrays#equals()", Arrays.equals(b0, b1)); + } + + @Before + public void setUp() { + try { + getTestDirectory().mkdirs(); + m_testFile = new File(getTestDirectory(), "file2-test.txt"); + + if (!m_testFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + m_testFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(m_testFile)); + try { + TestUtils.generateTestData(output, (long) FILE_SIZE); + } finally { + IOUtils.closeQuietly(output); + } + } catch (final IOException ioe) { + throw new RuntimeException("Can't run this test because the environment could not be built: " + + ioe.getMessage()); + } + // Create and init a byte array as input data + iarr = new byte[200]; + Arrays.fill( iarr, (byte)-1); + for( int i=0; i< 80; i++){ + iarr[i] = (byte) i; + } + carr = new char[200]; + Arrays.fill( carr, (char)-1); + for( int i=0; i< 80; i++){ + carr[i] = (char) i; + } + } + + @After + public void tearDown() { + carr = null; + iarr = null; + try { + FileUtils.deleteDirectory(getTestDirectory()); + } catch (final IOException e) { + throw new RuntimeException("Could not clear up " + getTestDirectory() + ": " + e); + } + } + + @Test public void testCloseQuietly_AllCloseableIOException() { + final Closeable closeable = new Closeable() { + public void close() throws IOException { + throw new IOException(); + } + }; + IOUtils.closeQuietly(closeable, null, closeable); + } + + @Test public void testCloseQuietly_CloseableIOException() { + IOUtils.closeQuietly(new Closeable() { + public void close() throws IOException { + throw new IOException(); + } + }); + } + + @Test public void testCloseQuietly_Selector() { + Selector selector = null; + try { + selector = Selector.open(); + } catch (final IOException ignore) { + } finally { + IOUtils.closeQuietly(selector); + } + } + + @Test public void testCloseQuietly_SelectorIOException() { + final Selector selector = new SelectorAdapter() { + @Override + public void close() throws IOException { + throw new IOException(); + } + }; + IOUtils.closeQuietly(selector); + } + + @Test public void testCloseQuietly_SelectorNull() { + final Selector selector = null; + IOUtils.closeQuietly(selector); + } + + @Test public void testCloseQuietly_SelectorTwice() { + Selector selector = null; + try { + selector = Selector.open(); + } catch (final IOException ignore) { + } finally { + IOUtils.closeQuietly(selector); + IOUtils.closeQuietly(selector); + } + } + + @Test public void testCloseQuietly_ServerSocket() throws IOException { + IOUtils.closeQuietly((ServerSocket) null); + IOUtils.closeQuietly(new ServerSocket()); + } + + @Test public void testCloseQuietly_ServerSocketIOException() throws IOException { + IOUtils.closeQuietly(new ServerSocket() { + @Override + public void close() throws IOException { + throw new IOException(); + } + }); + } + + @Test public void testCloseQuietly_Socket() { + IOUtils.closeQuietly((Socket) null); + IOUtils.closeQuietly(new Socket()); + } + + @Test public void testCloseQuietly_SocketIOException() { + IOUtils.closeQuietly(new Socket() { + @Override + public synchronized void close() throws IOException { + throw new IOException(); + } + }); + } + + @Test public void testConstants() throws Exception { + assertEquals('/', IOUtils.DIR_SEPARATOR_UNIX); + assertEquals('\\', IOUtils.DIR_SEPARATOR_WINDOWS); + assertEquals("\n", IOUtils.LINE_SEPARATOR_UNIX); + assertEquals("\r\n", IOUtils.LINE_SEPARATOR_WINDOWS); + if (WINDOWS) { + assertEquals('\\', IOUtils.DIR_SEPARATOR); + assertEquals("\r\n", IOUtils.LINE_SEPARATOR); + } else { + assertEquals('/', IOUtils.DIR_SEPARATOR); + assertEquals("\n", IOUtils.LINE_SEPARATOR); + } + } + + @SuppressWarnings("deprecation") // unavoidable until Java 7 + @Test public void testContentEquals_InputStream_InputStream() throws Exception { + { + final ByteArrayInputStream input1 = new ByteArrayInputStream("".getBytes(Charsets.UTF_8)); + assertTrue(IOUtils.contentEquals(input1, input1)); + } + { + final ByteArrayInputStream input1 = new ByteArrayInputStream("ABC".getBytes(Charsets.UTF_8)); + assertTrue(IOUtils.contentEquals(input1, input1)); + } + assertTrue(IOUtils + .contentEquals(new ByteArrayInputStream("".getBytes(Charsets.UTF_8)), new ByteArrayInputStream("".getBytes(Charsets.UTF_8)))); + assertTrue(IOUtils.contentEquals(new BufferedInputStream(new ByteArrayInputStream("".getBytes(Charsets.UTF_8))), new BufferedInputStream( + new ByteArrayInputStream("".getBytes(Charsets.UTF_8))))); + assertTrue(IOUtils.contentEquals(new ByteArrayInputStream("ABC".getBytes(Charsets.UTF_8)), + new ByteArrayInputStream("ABC".getBytes(Charsets.UTF_8)))); + assertFalse(IOUtils.contentEquals(new ByteArrayInputStream("ABCD".getBytes(Charsets.UTF_8)), + new ByteArrayInputStream("ABC".getBytes(Charsets.UTF_8)))); + assertFalse(IOUtils.contentEquals(new ByteArrayInputStream("ABC".getBytes(Charsets.UTF_8)), + new ByteArrayInputStream("ABCD".getBytes(Charsets.UTF_8)))); + } + + @Test public void testContentEquals_Reader_Reader() throws Exception { + { + final StringReader input1 = new StringReader(""); + assertTrue(IOUtils.contentEquals(input1, input1)); + } + { + final StringReader input1 = new StringReader("ABC"); + assertTrue(IOUtils.contentEquals(input1, input1)); + } + assertTrue(IOUtils.contentEquals(new StringReader(""), new StringReader(""))); + assertTrue(IOUtils.contentEquals(new BufferedReader(new StringReader("")), new BufferedReader(new StringReader("")))); + assertTrue(IOUtils.contentEquals(new StringReader("ABC"), new StringReader("ABC"))); + assertFalse(IOUtils.contentEquals(new StringReader("ABCD"), new StringReader("ABC"))); + assertFalse(IOUtils.contentEquals(new StringReader("ABC"), new StringReader("ABCD"))); + } + + @Test public void testContentEqualsIgnoreEOL() throws Exception { + { + final Reader input1 = new CharArrayReader("".toCharArray()); + assertTrue(IOUtils.contentEqualsIgnoreEOL(input1, input1)); + } + { + final Reader input1 = new CharArrayReader("321\r\n".toCharArray()); + assertTrue(IOUtils.contentEqualsIgnoreEOL(input1, input1)); + } + + Reader r1; + Reader r2; + + r1 = new CharArrayReader("".toCharArray()); + r2 = new CharArrayReader("".toCharArray()); + assertTrue(IOUtils.contentEqualsIgnoreEOL(r1, r2)); + + r1 = new CharArrayReader("1".toCharArray()); + r2 = new CharArrayReader("1".toCharArray()); + assertTrue(IOUtils.contentEqualsIgnoreEOL(r1, r2)); + + r1 = new CharArrayReader("1".toCharArray()); + r2 = new CharArrayReader("2".toCharArray()); + assertFalse(IOUtils.contentEqualsIgnoreEOL(r1, r2)); + + r1 = new CharArrayReader("123\rabc".toCharArray()); + r2 = new CharArrayReader("123\nabc".toCharArray()); + assertTrue(IOUtils.contentEqualsIgnoreEOL(r1, r2)); + + r1 = new CharArrayReader("321".toCharArray()); + r2 = new CharArrayReader("321\r\n".toCharArray()); + assertTrue(IOUtils.contentEqualsIgnoreEOL(r1, r2)); + } + + @SuppressWarnings("deprecation") + // testing deprecated method + @Test public void testCopy_ByteArray_OutputStream() throws Exception { + final File destination = TestUtils.newFile(getTestDirectory(), "copy8.txt"); + final FileInputStream fin = new FileInputStream(m_testFile); + byte[] in; + try { + // Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid. + in = IOUtils.toByteArray(fin); + } finally { + fin.close(); + } + + final FileOutputStream fout = new FileOutputStream(destination); + try { + CopyUtils.copy(in, fout); + + fout.flush(); + + TestUtils.checkFile(destination, m_testFile); + TestUtils.checkWrite(fout); + } finally { + fout.close(); + } + TestUtils.deleteFile(destination); + } + + @SuppressWarnings("deprecation") + // testing deprecated method + @Test public void testCopy_ByteArray_Writer() throws Exception { + final File destination = TestUtils.newFile(getTestDirectory(), "copy7.txt"); + final FileInputStream fin = new FileInputStream(m_testFile); + byte[] in; + try { + // Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid. + in = IOUtils.toByteArray(fin); + } finally { + fin.close(); + } + + final FileWriter fout = new FileWriter(destination); + try { + CopyUtils.copy(in, fout); + fout.flush(); + TestUtils.checkFile(destination, m_testFile); + TestUtils.checkWrite(fout); + } finally { + fout.close(); + } + TestUtils.deleteFile(destination); + } + + @SuppressWarnings("deprecation") + // testing deprecated method + @Test public void testCopy_String_Writer() throws Exception { + final File destination = TestUtils.newFile(getTestDirectory(), "copy6.txt"); + final FileReader fin = new FileReader(m_testFile); + String str; + try { + // Create our String. Rely on testReaderToString() to make sure this is valid. + str = IOUtils.toString(fin); + } finally { + fin.close(); + } + + final FileWriter fout = new FileWriter(destination); + try { + CopyUtils.copy(str, fout); + fout.flush(); + + TestUtils.checkFile(destination, m_testFile); + TestUtils.checkWrite(fout); + } finally { + fout.close(); + } + TestUtils.deleteFile(destination); + } + + @Test public void testCopyLarge_CharExtraLength() throws IOException { + CharArrayReader is = null; + CharArrayWriter os = null; + try { + // Create streams + is = new CharArrayReader(carr); + os = new CharArrayWriter(); + + // Test our copy method + // for extra length, it reads till EOF + assertEquals(200, IOUtils.copyLarge(is, os, 0, 2000)); + final char[] oarr = os.toCharArray(); + + // check that output length is correct + assertEquals(200, oarr.length); + // check that output data corresponds to input data + assertEquals(1, oarr[1]); + assertEquals(79, oarr[79]); + assertEquals((char) -1, oarr[80]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_CharFullLength() throws IOException { + CharArrayReader is = null; + CharArrayWriter os = null; + try { + // Create streams + is = new CharArrayReader(carr); + os = new CharArrayWriter(); + + // Test our copy method + assertEquals(200, IOUtils.copyLarge(is, os, 0, -1)); + final char[] oarr = os.toCharArray(); + + // check that output length is correct + assertEquals(200, oarr.length); + // check that output data corresponds to input data + assertEquals(1, oarr[1]); + assertEquals(79, oarr[79]); + assertEquals((char) -1, oarr[80]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_CharNoSkip() throws IOException { + CharArrayReader is = null; + CharArrayWriter os = null; + try { + // Create streams + is = new CharArrayReader(carr); + os = new CharArrayWriter(); + + // Test our copy method + assertEquals(100, IOUtils.copyLarge(is, os, 0, 100)); + final char[] oarr = os.toCharArray(); + + // check that output length is correct + assertEquals(100, oarr.length); + // check that output data corresponds to input data + assertEquals(1, oarr[1]); + assertEquals(79, oarr[79]); + assertEquals((char) -1, oarr[80]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_CharSkip() throws IOException { + CharArrayReader is = null; + CharArrayWriter os = null; + try { + // Create streams + is = new CharArrayReader(carr); + os = new CharArrayWriter(); + + // Test our copy method + assertEquals(100, IOUtils.copyLarge(is, os, 10, 100)); + final char[] oarr = os.toCharArray(); + + // check that output length is correct + assertEquals(100, oarr.length); + // check that output data corresponds to input data + assertEquals(11, oarr[1]); + assertEquals(79, oarr[69]); + assertEquals((char) -1, oarr[70]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_CharSkipInvalid() throws IOException { + CharArrayReader is = null; + CharArrayWriter os = null; + try { + // Create streams + is = new CharArrayReader(carr); + os = new CharArrayWriter(); + + // Test our copy method + IOUtils.copyLarge(is, os, 1000, 100); + fail("Should have thrown EOFException"); + } catch (final EOFException ignore) { + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_ExtraLength() throws IOException { + ByteArrayInputStream is = null; + ByteArrayOutputStream os = null; + try { + // Create streams + is = new ByteArrayInputStream(iarr); + os = new ByteArrayOutputStream(); + + // Test our copy method + // for extra length, it reads till EOF + assertEquals(200, IOUtils.copyLarge(is, os, 0, 2000)); + final byte[] oarr = os.toByteArray(); + + // check that output length is correct + assertEquals(200, oarr.length); + // check that output data corresponds to input data + assertEquals(1, oarr[1]); + assertEquals(79, oarr[79]); + assertEquals(-1, oarr[80]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_FullLength() throws IOException { + ByteArrayInputStream is = null; + ByteArrayOutputStream os = null; + try { + // Create streams + is = new ByteArrayInputStream(iarr); + os = new ByteArrayOutputStream(); + + // Test our copy method + assertEquals(200, IOUtils.copyLarge(is, os, 0, -1)); + final byte[] oarr = os.toByteArray(); + + // check that output length is correct + assertEquals(200, oarr.length); + // check that output data corresponds to input data + assertEquals(1, oarr[1]); + assertEquals(79, oarr[79]); + assertEquals(-1, oarr[80]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_NoSkip() throws IOException { + ByteArrayInputStream is = null; + ByteArrayOutputStream os = null; + try { + // Create streams + is = new ByteArrayInputStream(iarr); + os = new ByteArrayOutputStream(); + + // Test our copy method + assertEquals(100, IOUtils.copyLarge(is, os, 0, 100)); + final byte[] oarr = os.toByteArray(); + + // check that output length is correct + assertEquals(100, oarr.length); + // check that output data corresponds to input data + assertEquals(1, oarr[1]); + assertEquals(79, oarr[79]); + assertEquals(-1, oarr[80]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_Skip() throws IOException { + ByteArrayInputStream is = null; + ByteArrayOutputStream os = null; + try { + // Create streams + is = new ByteArrayInputStream(iarr); + os = new ByteArrayOutputStream(); + + // Test our copy method + assertEquals(100, IOUtils.copyLarge(is, os, 10, 100)); + final byte[] oarr = os.toByteArray(); + + // check that output length is correct + assertEquals(100, oarr.length); + // check that output data corresponds to input data + assertEquals(11, oarr[1]); + assertEquals(79, oarr[69]); + assertEquals(-1, oarr[70]); + + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testCopyLarge_SkipInvalid() throws IOException { + ByteArrayInputStream is = null; + ByteArrayOutputStream os = null; + try { + // Create streams + is = new ByteArrayInputStream(iarr); + os = new ByteArrayOutputStream(); + + // Test our copy method + IOUtils.copyLarge(is, os, 1000, 100); + fail("Should have thrown EOFException"); + } catch (final EOFException ignore) { + } finally { + IOUtils.closeQuietly(is); + IOUtils.closeQuietly(os); + } + } + + @Test public void testRead_ReadableByteChannel() throws Exception { + final ByteBuffer buffer = ByteBuffer.allocate(FILE_SIZE); + final FileInputStream fileInputStream = new FileInputStream(m_testFile); + final FileChannel input = fileInputStream.getChannel(); + try { + assertEquals(FILE_SIZE, IOUtils.read(input, buffer)); + assertEquals(0, IOUtils.read(input, buffer)); + assertEquals(0, buffer.remaining()); + assertEquals(0, input.read(buffer)); + buffer.clear(); + try { + IOUtils.readFully(input, buffer); + fail("Should have failed with EOFxception"); + } catch (final EOFException expected) { + // expected + } + } finally { + IOUtils.closeQuietly(input, fileInputStream); + }} + + @Test public void testReadFully_InputStream_ByteArray() throws Exception { + final int size = 1027; + + final byte[] buffer = new byte[size]; + + final InputStream input = new ByteArrayInputStream(new byte[size]); + try { + IOUtils.readFully(input, buffer, 0, -1); + fail("Should have failed with IllegalArgumentException"); + } catch (final IllegalArgumentException expected) { + // expected + } + IOUtils.readFully(input, buffer, 0, 0); + IOUtils.readFully(input, buffer, 0, size - 1); + try { + IOUtils.readFully(input, buffer, 0, 2); + fail("Should have failed with EOFxception"); + } catch (final EOFException expected) { + // expected + } + IOUtils.closeQuietly(input); + + } + + @Test public void testReadFully_InputStream__ReturnByteArray() throws Exception { + final byte[] bytes = "abcd1234".getBytes("UTF-8"); + final ByteArrayInputStream stream = new ByteArrayInputStream(bytes); + + final byte[] result = IOUtils.readFully(stream, bytes.length); + + IOUtils.closeQuietly(stream); + + assertEqualContent(result, bytes); + } + + @Test public void testReadFully_InputStream_Offset() throws Exception { + final byte[] bytes = "abcd1234".getBytes("UTF-8"); + final ByteArrayInputStream stream = new ByteArrayInputStream(bytes); + final byte[] buffer = "wx00000000".getBytes("UTF-8"); + IOUtils.readFully(stream, buffer, 2, 8); + assertEquals("wxabcd1234", new String(buffer, 0, buffer.length, "UTF-8")); + IOUtils.closeQuietly(stream); + } + + @Test public void testReadFully_ReadableByteChannel() throws Exception { + final ByteBuffer buffer = ByteBuffer.allocate(FILE_SIZE); + final FileInputStream fileInputStream = new FileInputStream(m_testFile); + final FileChannel input = fileInputStream.getChannel(); + try { + IOUtils.readFully(input, buffer); + assertEquals(FILE_SIZE, buffer.position()); + assertEquals(0, buffer.remaining()); + assertEquals(0, input.read(buffer)); + IOUtils.readFully(input, buffer); + assertEquals(FILE_SIZE, buffer.position()); + assertEquals(0, buffer.remaining()); + assertEquals(0, input.read(buffer)); + IOUtils.readFully(input, buffer); + buffer.clear(); + try { + IOUtils.readFully(input, buffer); + fail("Should have failed with EOFxception"); + } catch (final EOFException expected) { + // expected + } + } finally { + IOUtils.closeQuietly(input, fileInputStream); + } + } + + @Test public void testReadFully_Reader() throws Exception { + final int size = 1027; + + final char[] buffer = new char[size]; + + final Reader input = new CharArrayReader(new char[size]); + IOUtils.readFully(input, buffer, 0, 0); + IOUtils.readFully(input, buffer, 0, size - 3); + try { + IOUtils.readFully(input, buffer, 0, -1); + fail("Should have failed with IllegalArgumentException"); + } catch (final IllegalArgumentException expected) { + // expected + } + try { + IOUtils.readFully(input, buffer, 0, 5); + fail("Should have failed with EOFException"); + } catch (final EOFException expected) { + // expected + } + IOUtils.closeQuietly(input); + } + + @Test public void testReadFully_Reader_Offset() throws Exception { + final Reader reader = new StringReader("abcd1234"); + final char[] buffer = "wx00000000".toCharArray(); + IOUtils.readFully(reader, buffer, 2, 8); + assertEquals("wxabcd1234", new String(buffer)); + IOUtils.closeQuietly(reader); + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test public void testReadLines_InputStream() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + InputStream in = null; + try { + final String[] data = new String[] { "hello", "world", "", "this is", "some text" }; + TestUtils.createLineBasedFile(file, data); + + in = new FileInputStream(file); + final List lines = IOUtils.readLines(in); + assertEquals(Arrays.asList(data), lines); + assertEquals(-1, in.read()); + } finally { + IOUtils.closeQuietly(in); + TestUtils.deleteFile(file); + } + } + + @Test public void testReadLines_InputStream_String() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + InputStream in = null; + try { + final String[] data = new String[] { "hello", "/u1234", "", "this is", "some text" }; + TestUtils.createLineBasedFile(file, data); + + in = new FileInputStream(file); + final List lines = IOUtils.readLines(in, "UTF-8"); + assertEquals(Arrays.asList(data), lines); + assertEquals(-1, in.read()); + } finally { + IOUtils.closeQuietly(in); + TestUtils.deleteFile(file); + } + } + + @Test public void testReadLines_Reader() throws Exception { + final File file = TestUtils.newFile(getTestDirectory(), "lines.txt"); + Reader in = null; + try { + final String[] data = new String[] { "hello", "/u1234", "", "this is", "some text" }; + TestUtils.createLineBasedFile(file, data); + + in = new InputStreamReader(new FileInputStream(file)); + final List lines = IOUtils.readLines(in); + assertEquals(Arrays.asList(data), lines); + assertEquals(-1, in.read()); + } finally { + IOUtils.closeQuietly(in); + TestUtils.deleteFile(file); + } + } + + @Test public void testSkip_FileReader() throws Exception { + final FileReader in = new FileReader(m_testFile); + try { + assertEquals(FILE_SIZE - 10, IOUtils.skip(in, FILE_SIZE - 10)); + assertEquals(10, IOUtils.skip(in, 20)); + assertEquals(0, IOUtils.skip(in, 10)); + } finally { + in.close(); + } + } + + @Test public void testSkip_InputStream() throws Exception { + final InputStream in = new FileInputStream(m_testFile); + try { + assertEquals(FILE_SIZE - 10, IOUtils.skip(in, FILE_SIZE - 10)); + assertEquals(10, IOUtils.skip(in, 20)); + assertEquals(0, IOUtils.skip(in, 10)); + } finally { + in.close(); + } + } + + @Test public void testSkip_ReadableByteChannel() throws Exception { + final FileInputStream fileInputStream = new FileInputStream(m_testFile); + final FileChannel fileChannel = fileInputStream.getChannel(); + try { + assertEquals(FILE_SIZE - 10, IOUtils.skip(fileChannel, FILE_SIZE - 10)); + assertEquals(10, IOUtils.skip(fileChannel, 20)); + assertEquals(0, IOUtils.skip(fileChannel, 10)); + } finally { + IOUtils.closeQuietly(fileChannel, fileInputStream); + } + } + + @Test public void testSkipFully_InputStream() throws Exception { + final int size = 1027; + + final InputStream input = new ByteArrayInputStream(new byte[size]); + try { + IOUtils.skipFully(input, -1); + fail("Should have failed with IllegalArgumentException"); + } catch (final IllegalArgumentException expected) { + // expected + } + IOUtils.skipFully(input, 0); + IOUtils.skipFully(input, size - 1); + try { + IOUtils.skipFully(input, 2); + fail("Should have failed with IOException"); + } catch (final IOException expected) { + // expected + } + IOUtils.closeQuietly(input); + + } + + @Test public void testSkipFully_ReadableByteChannel() throws Exception { + final FileInputStream fileInputStream = new FileInputStream(m_testFile); + final FileChannel fileChannel = fileInputStream.getChannel(); + try { + try { + IOUtils.skipFully(fileChannel, -1); + fail("Should have failed with IllegalArgumentException"); + } catch (final IllegalArgumentException expected) { + // expected + } + IOUtils.skipFully(fileChannel, 0); + IOUtils.skipFully(fileChannel, FILE_SIZE - 1); + try { + IOUtils.skipFully(fileChannel, 2); + fail("Should have failed with IOException"); + } catch (final IOException expected) { + // expected + } + } finally { + IOUtils.closeQuietly(fileChannel, fileInputStream); + } + } + + @Test public void testSkipFully_Reader() throws Exception { + final int size = 1027; + + final Reader input = new CharArrayReader(new char[size]); + IOUtils.skipFully(input, 0); + IOUtils.skipFully(input, size - 3); + try { + IOUtils.skipFully(input, -1); + fail("Should have failed with IllegalArgumentException"); + } catch (final IllegalArgumentException expected) { + // expected + } + try { + IOUtils.skipFully(input, 5); + fail("Should have failed with IOException"); + } catch (final IOException expected) { + // expected + } + IOUtils.closeQuietly(input); + } + + @SuppressWarnings("deprecation") + // testing deprecated method + @Test public void testStringToOutputStream() throws Exception { + final File destination = TestUtils.newFile(getTestDirectory(), "copy5.txt"); + final FileReader fin = new FileReader(m_testFile); + String str; + try { + // Create our String. Rely on testReaderToString() to make sure this is valid. + str = IOUtils.toString(fin); + } finally { + fin.close(); + } + + final FileOutputStream fout = new FileOutputStream(destination); + try { + CopyUtils.copy(str, fout); + // Note: this method *does* flush. It is equivalent to: + // OutputStreamWriter _out = new OutputStreamWriter(fout); + // CopyUtils.copy( str, _out, 4096 ); // copy( Reader, Writer, int ); + // _out.flush(); + // out = fout; + // note: we don't flush here; this IOUtils method does it for us + + TestUtils.checkFile(destination, m_testFile); + TestUtils.checkWrite(fout); + } finally { + fout.close(); + } + TestUtils.deleteFile(destination); + } + + @Test public void testToBufferedInputStream_InputStream() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final InputStream in = IOUtils.toBufferedInputStream(fin); + final byte[] out = IOUtils.toByteArray(in); + assertNotNull(out); + assertEquals("Not all bytes were read", 0, fin.available()); + assertEquals("Wrong output size", FILE_SIZE, out.length); + TestUtils.assertEqualContent(out, m_testFile); + } finally { + fin.close(); + } + } + + @Test public void testToBufferedInputStreamWithBufferSize_InputStream() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final InputStream in = IOUtils.toBufferedInputStream(fin, 2048); + final byte[] out = IOUtils.toByteArray(in); + assertNotNull(out); + assertEquals("Not all bytes were read", 0, fin.available()); + assertEquals("Wrong output size", FILE_SIZE, out.length); + TestUtils.assertEqualContent(out, m_testFile); + } finally { + fin.close(); + } + } + + @Test public void testToByteArray_InputStream() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final byte[] out = IOUtils.toByteArray(fin); + assertNotNull(out); + assertEquals("Not all bytes were read", 0, fin.available()); + assertEquals("Wrong output size", FILE_SIZE, out.length); + TestUtils.assertEqualContent(out, m_testFile); + } finally { + fin.close(); + } + } + + @Test public void testToByteArray_InputStream_NegativeSize() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + + try { + IOUtils.toByteArray(fin, -1); + fail("IllegalArgumentException excepted"); + } catch (final IllegalArgumentException exc) { + assertTrue("Exception message does not start with \"Size must be equal or greater than zero\"", exc + .getMessage().startsWith("Size must be equal or greater than zero")); + } finally { + fin.close(); + } + + } + + @Test public void testToByteArray_InputStream_Size() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final byte[] out = IOUtils.toByteArray(fin, m_testFile.length()); + assertNotNull(out); + assertEquals("Not all bytes were read", 0, fin.available()); + assertEquals("Wrong output size: out.length=" + out.length + "!=" + FILE_SIZE, FILE_SIZE, out.length); + TestUtils.assertEqualContent(out, m_testFile); + } finally { + fin.close(); + } + } + + @Test public void testToByteArray_InputStream_SizeIllegal() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + + try { + IOUtils.toByteArray(fin, m_testFile.length() + 1); + fail("IOException excepted"); + } catch (final IOException exc) { + assertTrue("Exception message does not start with \"Unexpected readed size\"", + exc.getMessage().startsWith("Unexpected readed size")); + } finally { + fin.close(); + } + + } + + @Test public void testToByteArray_InputStream_SizeLong() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + + try { + IOUtils.toByteArray(fin, (long) Integer.MAX_VALUE + 1); + fail("IOException excepted"); + } catch (final IllegalArgumentException exc) { + assertTrue("Exception message does not start with \"Size cannot be greater than Integer max value\"", exc + .getMessage().startsWith("Size cannot be greater than Integer max value")); + } finally { + fin.close(); + } + + } + + @Test public void testToByteArray_InputStream_SizeZero() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + + try { + final byte[] out = IOUtils.toByteArray(fin, 0); + assertNotNull("Out cannot be null", out); + assertEquals("Out length must be 0", 0, out.length); + } finally { + fin.close(); + } + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test public void testToByteArray_Reader() throws IOException { + final String charsetName = "UTF-8"; + final byte[] expecteds = charsetName.getBytes(charsetName); + byte[] actuals = IOUtils.toByteArray(new InputStreamReader(new ByteArrayInputStream(expecteds))); + Assert.assertArrayEquals(expecteds, actuals); + actuals = IOUtils.toByteArray(new InputStreamReader(new ByteArrayInputStream(expecteds)), charsetName); + Assert.assertArrayEquals(expecteds, actuals); + } + + @SuppressWarnings("deprecation") + // testing deprecated method + @Test public void testToByteArray_String() throws Exception { + final FileReader fin = new FileReader(m_testFile); + try { + // Create our String. Rely on testReaderToString() to make sure this is valid. + final String str = IOUtils.toString(fin); + + final byte[] out = IOUtils.toByteArray(str); + assertEqualContent(str.getBytes(), out); + } finally { + fin.close(); + } + } + + @Test public void testToByteArray_URI() throws Exception { + final URI url = m_testFile.toURI(); + final byte[] actual = IOUtils.toByteArray(url); + assertEquals(FILE_SIZE, actual.length); + } + + @Test public void testToByteArray_URL() throws Exception { + final URL url = m_testFile.toURI().toURL(); + final byte[] actual = IOUtils.toByteArray(url); + assertEquals(FILE_SIZE, actual.length); + } + + @Test public void testToByteArray_URLConnection() throws Exception { + final URLConnection urlConn = m_testFile.toURI().toURL().openConnection(); + byte[] actual; + try { + actual = IOUtils.toByteArray(urlConn); + } finally { + IOUtils.close(urlConn); + } + assertEquals(FILE_SIZE, actual.length); + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test public void testToCharArray_InputStream() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final char[] out = IOUtils.toCharArray(fin); + assertNotNull(out); + assertEquals("Not all chars were read", 0, fin.available()); + assertEquals("Wrong output size", FILE_SIZE, out.length); + TestUtils.assertEqualContent(out, m_testFile); + } finally { + fin.close(); + } + } + + @Test public void testToCharArray_InputStream_CharsetName() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final char[] out = IOUtils.toCharArray(fin, "UTF-8"); + assertNotNull(out); + assertEquals("Not all chars were read", 0, fin.available()); + assertEquals("Wrong output size", FILE_SIZE, out.length); + TestUtils.assertEqualContent(out, m_testFile); + } finally { + fin.close(); + } + } + + @Test public void testToCharArray_Reader() throws Exception { + final FileReader fr = new FileReader(m_testFile); + try { + final char[] out = IOUtils.toCharArray(fr); + assertNotNull(out); + assertEquals("Wrong output size", FILE_SIZE, out.length); + TestUtils.assertEqualContent(out, m_testFile); + } finally { + fr.close(); + } + } + + /** + * Test for {@link IOUtils#toInputStream(CharSequence)} and {@link IOUtils#toInputStream(CharSequence, String)}. + * Note, this test utilizes on {@link IOUtils#toByteArray(java.io.InputStream)} and so relies on + * {@link #testToByteArray_InputStream()} to ensure this method functions correctly. + * + * @throws Exception + * on error + */ + @SuppressWarnings("javadoc") // deliberately testing deprecated method + @Test public void testToInputStream_CharSequence() throws Exception { + final CharSequence csq = new StringBuilder("Abc123Xyz!"); + @SuppressWarnings("deprecation") + InputStream inStream = IOUtils.toInputStream(csq); // deliberately testing deprecated method + byte[] bytes = IOUtils.toByteArray(inStream); + assertEqualContent(csq.toString().getBytes(), bytes); + inStream = IOUtils.toInputStream(csq, (String) null); + bytes = IOUtils.toByteArray(inStream); + assertEqualContent(csq.toString().getBytes(), bytes); + inStream = IOUtils.toInputStream(csq, "UTF-8"); + bytes = IOUtils.toByteArray(inStream); + assertEqualContent(csq.toString().getBytes("UTF-8"), bytes); + } + + // Tests from IO-305 + + /** + * Test for {@link IOUtils#toInputStream(String)} and {@link IOUtils#toInputStream(String, String)}. Note, this test + * utilizes on {@link IOUtils#toByteArray(java.io.InputStream)} and so relies on + * {@link #testToByteArray_InputStream()} to ensure this method functions correctly. + * + * @throws Exception + * on error + */ + @SuppressWarnings("javadoc") // deliberately testing deprecated method + @Test public void testToInputStream_String() throws Exception { + final String str = "Abc123Xyz!"; + @SuppressWarnings("deprecation") // deliberately testing deprecated method + InputStream inStream = IOUtils.toInputStream(str); + byte[] bytes = IOUtils.toByteArray(inStream); + assertEqualContent(str.getBytes(), bytes); + inStream = IOUtils.toInputStream(str, (String) null); + bytes = IOUtils.toByteArray(inStream); + assertEqualContent(str.getBytes(), bytes); + inStream = IOUtils.toInputStream(str, "UTF-8"); + bytes = IOUtils.toByteArray(inStream); + assertEqualContent(str.getBytes("UTF-8"), bytes); + } + + @SuppressWarnings("deprecation") + // testing deprecated method + @Test public void testToString_ByteArray() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final byte[] in = IOUtils.toByteArray(fin); + // Create our byte[]. Rely on testInputStreamToByteArray() to make sure this is valid. + final String str = IOUtils.toString(in); + assertEqualContent(in, str.getBytes()); + } finally { + fin.close(); + } + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test public void testToString_InputStream() throws Exception { + final FileInputStream fin = new FileInputStream(m_testFile); + try { + final String out = IOUtils.toString(fin); + assertNotNull(out); + assertEquals("Not all bytes were read", 0, fin.available()); + assertEquals("Wrong output size", FILE_SIZE, out.length()); + } finally { + fin.close(); + } + } + + @Test public void testToString_Reader() throws Exception { + final FileReader fin = new FileReader(m_testFile); + try { + final String out = IOUtils.toString(fin); + assertNotNull(out); + assertEquals("Wrong output size", FILE_SIZE, out.length()); + } finally { + fin.close(); + } + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test public void testToString_URI() throws Exception { + final URI url = m_testFile.toURI(); + final String out = IOUtils.toString(url); + assertNotNull(out); + assertEquals("Wrong output size", FILE_SIZE, out.length()); + } + + private void testToString_URI(final String encoding) throws Exception { + final URI uri = m_testFile.toURI(); + final String out = IOUtils.toString(uri, encoding); + assertNotNull(out); + assertEquals("Wrong output size", FILE_SIZE, out.length()); + } + + @Test public void testToString_URI_CharsetName() throws Exception { + testToString_URI("US-ASCII"); + } + + @Test public void testToString_URI_CharsetNameNull() throws Exception { + testToString_URI(null); + } + + @SuppressWarnings("deprecation") // deliberately testing deprecated method + @Test public void testToString_URL() throws Exception { + final URL url = m_testFile.toURI().toURL(); + final String out = IOUtils.toString(url); + assertNotNull(out); + assertEquals("Wrong output size", FILE_SIZE, out.length()); + } + + private void testToString_URL(final String encoding) throws Exception { + final URL url = m_testFile.toURI().toURL(); + final String out = IOUtils.toString(url, encoding); + assertNotNull(out); + assertEquals("Wrong output size", FILE_SIZE, out.length()); + } + + @Test public void testToString_URL_CharsetName() throws Exception { + testToString_URL("US-ASCII"); + } + + @Test public void testToString_URL_CharsetNameNull() throws Exception { + testToString_URL(null); + } + + @Test public void testAsBufferedNull() { + try { + IOUtils.buffer((InputStream) null); + fail("Expected NullPointerException"); + } catch (NullPointerException npe) { + // expected + } + try { + IOUtils.buffer((OutputStream) null); + fail("Expected NullPointerException"); + } catch (NullPointerException npe) { + // expected + } + try { + IOUtils.buffer((Reader) null); + fail("Expected NullPointerException"); + } catch (NullPointerException npe) { + // expected + } + try { + IOUtils.buffer((Writer) null); + fail("Expected NullPointerException"); + } catch (NullPointerException npe) { + // expected + } + } + + @Test public void testAsBufferedInputStream() { + InputStream is = new InputStream() { + @Override + public int read() throws IOException { + return 0; + } + }; + final BufferedInputStream bis = IOUtils.buffer(is); + assertNotSame(is, bis); + assertSame(bis, IOUtils.buffer(bis)); + } + + @Test public void testAsBufferedInputStreamWithBufferSize() { + InputStream is = new InputStream() { + @Override + public int read() throws IOException { + return 0; + } + }; + final BufferedInputStream bis = IOUtils.buffer(is, 2048); + assertNotSame(is, bis); + assertSame(bis, IOUtils.buffer(bis)); + assertSame(bis, IOUtils.buffer(bis, 1024)); + } + + @Test public void testAsBufferedOutputStream() { + OutputStream is = new OutputStream() { + @Override + public void write(int b) throws IOException { } + }; + final BufferedOutputStream bis = IOUtils.buffer(is); + assertNotSame(is, bis); + assertSame(bis, IOUtils.buffer(bis)); + } + + @Test public void testAsBufferedOutputStreamWithBufferSize() { + OutputStream os = new OutputStream() { + @Override + public void write(int b) throws IOException { } + }; + final BufferedOutputStream bos = IOUtils.buffer(os, 2048); + assertNotSame(os, bos); + assertSame(bos, IOUtils.buffer(bos)); + assertSame(bos, IOUtils.buffer(bos, 1024)); + } + + @Test public void testAsBufferedReader() { + Reader is = new Reader() { + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + return 0; + } + @Override + public void close() throws IOException { } + }; + final BufferedReader bis = IOUtils.buffer(is); + assertNotSame(is, bis); + assertSame(bis, IOUtils.buffer(bis)); + } + + @Test public void testAsBufferedReaderWithBufferSize() { + Reader r = new Reader() { + @Override + public int read(char[] cbuf, int off, int len) throws IOException { + return 0; + } + @Override + public void close() throws IOException { } + }; + final BufferedReader br = IOUtils.buffer(r, 2048); + assertNotSame(r, br); + assertSame(br, IOUtils.buffer(br)); + assertSame(br, IOUtils.buffer(br, 1024)); + } + + @Test public void testAsBufferedWriter() { + Writer is = new Writer() { + @Override + public void write(int b) throws IOException { } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException { } + + @Override + public void flush() throws IOException { } + + @Override + public void close() throws IOException { } + }; + final BufferedWriter bis = IOUtils.buffer(is); + assertNotSame(is, bis); + assertSame(bis, IOUtils.buffer(bis)); + } + + @Test + public void testAsBufferedWriterWithBufferSize() { + Writer w = new Writer() { + @Override + public void write(int b) throws IOException { } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException { } + + @Override + public void flush() throws IOException { } + + @Override + public void close() throws IOException { } + }; + final BufferedWriter bw = IOUtils.buffer(w, 2024); + assertNotSame(w, bw); + assertSame(bw, IOUtils.buffer(bw)); + assertSame(bw, IOUtils.buffer(bw, 1024)); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsWriteTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsWriteTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..5936c6612681b96a88d729fe9231ff02ee523205 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/IOUtilsWriteTestCase.java" @@ -0,0 +1,789 @@ +/* + * 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 org.apache.commons.io.output.ByteArrayOutputStream; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.apache.commons.io.testtools.YellOnFlushAndCloseOutputStream; +import org.junit.Test; + +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.Arrays; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * JUnit tests for IOUtils write methods. + * + * @version $Id: IOUtilsWriteTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + * @see IOUtils + */ +@SuppressWarnings("deprecation") // includes tests for deprecated methods +public class IOUtilsWriteTestCase extends FileBasedTestCase { + + private static final int FILE_SIZE = 1024 * 4 + 1; + + + private final byte[] inData = TestUtils.generateTestData((long) FILE_SIZE); + + // ---------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------- + + //----------------------------------------------------------------------- + @Test + public void testWrite_byteArrayToOutputStream() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(inData, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_byteArrayToOutputStream_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write((byte[]) null, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_byteArrayToOutputStream_nullStream() throws Exception { + try { + IOUtils.write(inData, (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_byteArrayToWriter() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write(inData, writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_byteArrayToWriter_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write((byte[]) null, writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_byteArrayToWriter_nullWriter() throws Exception { + try { + IOUtils.write(inData, (Writer) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_byteArrayToWriter_Encoding() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write(inData, writer, "UTF8"); + out.off(); + writer.flush(); + + byte[] bytes = baout.toByteArray(); + bytes = new String(bytes, "UTF8").getBytes("US-ASCII"); + assertTrue("Content differs", Arrays.equals(inData, bytes)); + } + + @Test + public void testWrite_byteArrayToWriter_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write(null, writer, "UTF8"); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_byteArrayToWriter_Encoding_nullWriter() throws Exception { + try { + IOUtils.write(inData, null, "UTF8"); + fail(); + } catch (final NullPointerException ignore) { + } + } + + @Test + public void testWrite_byteArrayToWriter_Encoding_nullEncoding() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write(inData, writer, (String) null); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_charSequenceToOutputStream() throws Exception { + final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII")); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(csq, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_charSequenceToOutputStream_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write((CharSequence) null, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_charSequenceToOutputStream_nullStream() throws Exception { + final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII")); + try { + IOUtils.write(csq, (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_charSequenceToOutputStream_Encoding() throws Exception { + final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII")); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(csq, out, "UTF16"); + out.off(); + out.flush(); + + byte[] bytes = baout.toByteArray(); + bytes = new String(bytes, "UTF16").getBytes("US-ASCII"); + assertTrue("Content differs", Arrays.equals(inData, bytes)); + } + + @Test + public void testWrite_charSequenceToOutputStream_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write((CharSequence) null, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_charSequenceToOutputStream_Encoding_nullStream() throws Exception { + final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII")); + try { + IOUtils.write(csq, (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + @Test + public void testWrite_charSequenceToOutputStream_nullEncoding() throws Exception { + final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII")); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(csq, out, (String) null); + out.off(); + out.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_charSequenceToWriter() throws Exception { + final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII")); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write(csq, writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_charSequenceToWriter_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write((CharSequence) null, writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_charSequenceToWriter_Encoding_nullStream() throws Exception { + final CharSequence csq = new StringBuilder(new String(inData, "US-ASCII")); + try { + IOUtils.write(csq, (Writer) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_stringToOutputStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(str, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_stringToOutputStream_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write((String) null, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_stringToOutputStream_nullStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + try { + IOUtils.write(str, (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_stringToOutputStream_Encoding() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(str, out, "UTF16"); + out.off(); + out.flush(); + + byte[] bytes = baout.toByteArray(); + bytes = new String(bytes, "UTF16").getBytes("US-ASCII"); + assertTrue("Content differs", Arrays.equals(inData, bytes)); + } + + @Test + public void testWrite_stringToOutputStream_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write((String) null, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_stringToOutputStream_Encoding_nullStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + try { + IOUtils.write(str, (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + @Test + public void testWrite_stringToOutputStream_nullEncoding() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(str, out, (String) null); + out.off(); + out.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_stringToWriter() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write(str, writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_stringToWriter_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write((String) null, writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_stringToWriter_Encoding_nullStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + try { + IOUtils.write(str, (Writer) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_charArrayToOutputStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(str.toCharArray(), out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_charArrayToOutputStream_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write((char[]) null, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_charArrayToOutputStream_nullStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + try { + IOUtils.write(str.toCharArray(), (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_charArrayToOutputStream_Encoding() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(str.toCharArray(), out, "UTF16"); + out.off(); + out.flush(); + + byte[] bytes = baout.toByteArray(); + bytes = new String(bytes, "UTF16").getBytes("US-ASCII"); + assertTrue("Content differs", Arrays.equals(inData, bytes)); + } + + @Test + public void testWrite_charArrayToOutputStream_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write((char[]) null, out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_charArrayToOutputStream_Encoding_nullStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + try { + IOUtils.write(str.toCharArray(), (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + @Test + public void testWrite_charArrayToOutputStream_nullEncoding() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + + IOUtils.write(str.toCharArray(), out, (String) null); + out.off(); + out.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + //----------------------------------------------------------------------- + @Test + public void testWrite_charArrayToWriter() throws Exception { + final String str = new String(inData, "US-ASCII"); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write(str.toCharArray(), writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", inData.length, baout.size()); + assertTrue("Content differs", Arrays.equals(inData, baout.toByteArray())); + } + + @Test + public void testWrite_charArrayToWriter_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.write((char[]) null, writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWrite_charArrayToWriter_Encoding_nullStream() throws Exception { + final String str = new String(inData, "US-ASCII"); + try { + IOUtils.write(str.toCharArray(), (Writer) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWriteLines_OutputStream() throws Exception { + final Object[] data = new Object[]{ + "hello", new StringBuffer("world"), "", "this is", null, "some text"}; + final List list = Arrays.asList(data); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.writeLines(list, "*", out); + + out.off(); + out.flush(); + + final String expected = "hello*world**this is**some text*"; + final String actual = baout.toString(); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_OutputStream_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.writeLines(null, "*", out); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWriteLines_OutputStream_nullSeparator() throws Exception { + final Object[] data = new Object[]{"hello", "world"}; + final List list = Arrays.asList(data); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.writeLines(list, null, out); + out.off(); + out.flush(); + + final String expected = "hello" + IOUtils.LINE_SEPARATOR + "world" + IOUtils.LINE_SEPARATOR; + final String actual = baout.toString(); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_OutputStream_nullStream() throws Exception { + final Object[] data = new Object[]{"hello", "world"}; + final List list = Arrays.asList(data); + try { + IOUtils.writeLines(list, "*", (OutputStream) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + + //----------------------------------------------------------------------- + @Test + public void testWriteLines_OutputStream_Encoding() throws Exception { + final Object[] data = new Object[]{ + "hello\u8364", new StringBuffer("world"), "", "this is", null, "some text"}; + final List list = Arrays.asList(data); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.writeLines(list, "*", out, "UTF-8"); + + out.off(); + out.flush(); + + final String expected = "hello\u8364*world**this is**some text*"; + final String actual = baout.toString("UTF-8"); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_OutputStream_Encoding_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.writeLines(null, "*", out, "US-ASCII"); + out.off(); + out.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWriteLines_OutputStream_Encoding_nullSeparator() throws Exception { + final Object[] data = new Object[]{"hello", "world"}; + final List list = Arrays.asList(data); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.writeLines(list, null, out, "US-ASCII"); + out.off(); + out.flush(); + + final String expected = "hello" + IOUtils.LINE_SEPARATOR + "world" + IOUtils.LINE_SEPARATOR; + final String actual = baout.toString(); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_OutputStream_Encoding_nullStream() throws Exception { + final Object[] data = new Object[]{"hello", "world"}; + final List list = Arrays.asList(data); + try { + IOUtils.writeLines(list, "*", null, "US-ASCII"); + fail(); + } catch (final NullPointerException ignore) { + } + } + + @Test + public void testWriteLines_OutputStream_Encoding_nullEncoding() throws Exception { + final Object[] data = new Object[]{ + "hello", new StringBuffer("world"), "", "this is", null, "some text"}; + final List list = Arrays.asList(data); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, false, true); + + IOUtils.writeLines(list, "*", out, (String) null); + + out.off(); + out.flush(); + + final String expected = "hello*world**this is**some text*"; + final String actual = baout.toString(); + assertEquals(expected, actual); + } + + //----------------------------------------------------------------------- + @Test + public void testWriteLines_Writer() throws Exception { + final Object[] data = new Object[]{ + "hello", new StringBuffer("world"), "", "this is", null, "some text"}; + final List list = Arrays.asList(data); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.writeLines(list, "*", writer); + + out.off(); + writer.flush(); + + final String expected = "hello*world**this is**some text*"; + final String actual = baout.toString(); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_Writer_nullData() throws Exception { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.writeLines(null, "*", writer); + out.off(); + writer.flush(); + + assertEquals("Sizes differ", 0, baout.size()); + } + + @Test + public void testWriteLines_Writer_nullSeparator() throws Exception { + final Object[] data = new Object[]{"hello", "world"}; + final List list = Arrays.asList(data); + + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + @SuppressWarnings("resource") // deliberately not closed + final YellOnFlushAndCloseOutputStream out = new YellOnFlushAndCloseOutputStream(baout, true, true); + final Writer writer = new OutputStreamWriter(baout, "US-ASCII"); + + IOUtils.writeLines(list, null, writer); + out.off(); + writer.flush(); + + final String expected = "hello" + IOUtils.LINE_SEPARATOR + "world" + IOUtils.LINE_SEPARATOR; + final String actual = baout.toString(); + assertEquals(expected, actual); + } + + @Test + public void testWriteLines_Writer_nullStream() throws Exception { + final Object[] data = new Object[]{"hello", "world"}; + final List list = Arrays.asList(data); + try { + IOUtils.writeLines(list, "*", (Writer) null); + fail(); + } catch (final NullPointerException ignore) { + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/Java7SupportTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/Java7SupportTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..bafed450fee5cb4f43de728e47532b0a2c5a0950 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/Java7SupportTest.java" @@ -0,0 +1,57 @@ +package 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.File; +import java.util.Locale; + +import org.junit.Assume; +import org.junit.Test; + +public class Java7SupportTest { + @Test + public void testIsSymLink() + throws Exception { + + File file = new File("."); + if (Java7Support.isAtLeastJava7()) { + assertFalse(Java7Support.isSymLink(file)); + } + } + + @Test + public void createAndReadSymlink() + throws Exception { + + Assume.assumeFalse(System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows")); + + File file = new File("target/fzz"); + if (Java7Support.isAtLeastJava7()) { + Java7Support.createSymbolicLink(file, new File("../target")); + + final File file1 = Java7Support.readSymbolicLink(file); + assertEquals("target", file1.getName()); + Java7Support.delete(file); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/LineIteratorTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/LineIteratorTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..0b754f53e395234b11f5298d4da029ff04a679c3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/LineIteratorTestCase.java" @@ -0,0 +1,443 @@ +/* + * 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.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.nio.charset.UnsupportedCharsetException; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * This is used to test LineIterator for correctness. + * + * @version $Id: LineIteratorTestCase.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class LineIteratorTestCase extends FileBasedTestCase { + + private void assertLines(final List lines, final LineIterator iterator) { + try { + for (int i = 0; i < lines.size(); i++) { + final String line = iterator.nextLine(); + assertEquals("nextLine() line " + i, lines.get(i), line); + } + assertFalse("No more expected", iterator.hasNext()); + } finally { + LineIterator.closeQuietly(iterator); + } + } + + /** + * Creates a test file with a specified number of lines. + * + * @param file target file + * @param lineCount number of lines to create + * + * @throws IOException If an I/O error occurs + */ + private List createLinesFile(final File file, final int lineCount) throws IOException { + final List lines = createStringLines(lineCount); + FileUtils.writeLines(file, lines); + return lines; + } + + /** + * Creates a test file with a specified number of lines. + * + * @param file target file + * @param encoding the encoding to use while writing the lines + * @param lineCount number of lines to create + * + * @throws IOException If an I/O error occurs + */ + private List createLinesFile(final File file, final String encoding, final int lineCount) throws IOException { + final List lines = createStringLines(lineCount); + FileUtils.writeLines(file, encoding, lines); + return lines; + } + + /** + * Creates String data lines. + * + * @param lineCount number of lines to create + * @return a new lines list. + */ + private List createStringLines(final int lineCount) { + final List lines = new ArrayList(); + for (int i = 0; i < lineCount; i++) { + lines.add("LINE " + i); + } + return lines; + } + + @Before + public void setUp() throws Exception { + final File dir = getTestDirectory(); + if (dir.exists()) { + FileUtils.deleteDirectory(dir); + } + dir.mkdirs(); + + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(getTestDirectory()); + } + + // ----------------------------------------------------------------------- + + @Test + public void testConstructor() throws Exception { + try { + new LineIterator(null); + fail(); + } catch (final IllegalArgumentException ex) { + // expected + } + } + + @Test + public void testZeroLines() throws Exception { + doTestFileWithSpecifiedLines(0); + } + + @Test + public void testOneLines() throws Exception { + doTestFileWithSpecifiedLines(1); + } + + @Test + public void testTwoLines() throws Exception { + doTestFileWithSpecifiedLines(2); + } + + @Test + public void testThreeLines() throws Exception { + doTestFileWithSpecifiedLines(3); + } + + @Test + public void testMissingFile() throws Exception { + final File testFile = new File(getTestDirectory(), "dummy-missing-file.txt"); + + LineIterator iterator = null; + try { + iterator = FileUtils.lineIterator(testFile, "UTF-8"); + fail("Expected FileNotFoundException"); + } catch (final FileNotFoundException expected) { + // ignore, expected result + } finally { + LineIterator.closeQuietly(iterator); + } + } + + @Test + public void testValidEncoding() throws Exception { + final String encoding = "UTF-8"; + + final File testFile = new File(getTestDirectory(), "LineIterator-validEncoding.txt"); + createLinesFile(testFile, encoding, 3); + + final LineIterator iterator = FileUtils.lineIterator(testFile, encoding); + try { + int count = 0; + while (iterator.hasNext()) { + assertNotNull(iterator.next()); + count++; + } + assertEquals(3, count); + } finally { + LineIterator.closeQuietly(iterator); + } + } + + @Test + public void testInvalidEncoding() throws Exception { + final String encoding = "XXXXXXXX"; + + final File testFile = new File(getTestDirectory(), "LineIterator-invalidEncoding.txt"); + createLinesFile(testFile, "UTF-8", 3); + + LineIterator iterator = null; + try { + iterator = FileUtils.lineIterator(testFile, encoding); + fail("Expected UnsupportedCharsetException"); + } catch (final UnsupportedCharsetException expected) { + // ignore, expected result + } finally { + LineIterator.closeQuietly(iterator); + } + } + + @Test + public void testNextLineOnlyDefaultEncoding() throws Exception { + final File testFile = new File(getTestDirectory(), "LineIterator-nextOnly.txt"); + final List lines = createLinesFile(testFile, 3); + + final LineIterator iterator = FileUtils.lineIterator(testFile); + assertLines(lines, iterator); + } + + @Test + public void testNextLineOnlyNullEncoding() throws Exception { + final String encoding = null; + + final File testFile = new File(getTestDirectory(), "LineIterator-nextOnly.txt"); + final List lines = createLinesFile(testFile, encoding, 3); + + final LineIterator iterator = FileUtils.lineIterator(testFile, encoding); + assertLines(lines, iterator); + } + + @Test + public void testNextLineOnlyUtf8Encoding() throws Exception { + final String encoding = "UTF-8"; + + final File testFile = new File(getTestDirectory(), "LineIterator-nextOnly.txt"); + final List lines = createLinesFile(testFile, encoding, 3); + + final LineIterator iterator = FileUtils.lineIterator(testFile, encoding); + assertLines(lines, iterator); + } + + @Test + public void testNextOnly() throws Exception { + final String encoding = null; + + final File testFile = new File(getTestDirectory(), "LineIterator-nextOnly.txt"); + final List lines = createLinesFile(testFile, encoding, 3); + + final LineIterator iterator = FileUtils.lineIterator(testFile, encoding); + try { + for (int i = 0; i < lines.size(); i++) { + final String line = iterator.next(); + assertEquals("next() line " + i, lines.get(i), line); + } + assertEquals("No more expected", false, iterator.hasNext()); + } finally { + LineIterator.closeQuietly(iterator); + } + } + + @Test + public void testNextWithException() throws Exception { + final Reader reader = new BufferedReader(new StringReader("")) { + @Override + public String readLine() throws IOException { + throw new IOException("hasNext"); + } + }; + try { + new LineIterator(reader).hasNext(); + fail("Expected IllegalStateException"); + } catch (final IllegalStateException e) { + // expected + } + } + + @Test + public void testCloseEarly() throws Exception { + final String encoding = "UTF-8"; + + final File testFile = new File(getTestDirectory(), "LineIterator-closeEarly.txt"); + createLinesFile(testFile, encoding, 3); + + final LineIterator iterator = FileUtils.lineIterator(testFile, encoding); + try { + // get + assertNotNull("Line expected", iterator.next()); + assertTrue("More expected", iterator.hasNext()); + + // close + iterator.close(); + assertFalse("No more expected", iterator.hasNext()); + try { + iterator.next(); + fail(); + } catch (final NoSuchElementException ex) { + // expected + } + try { + iterator.nextLine(); + fail(); + } catch (final NoSuchElementException ex) { + // expected + } + + // try closing again + iterator.close(); + try { + iterator.next(); + fail(); + } catch (final NoSuchElementException ex) { + // expected + } + try { + iterator.nextLine(); + fail(); + } catch (final NoSuchElementException ex) { + // expected + } + } finally { + LineIterator.closeQuietly(iterator); + } + } + + /** + * Utility method to create and test a file with a specified number of lines. + * + * @param lineCount the lines to create in the test file + * + * @throws IOException If an I/O error occurs while creating the file + */ + private void doTestFileWithSpecifiedLines(final int lineCount) throws IOException { + final String encoding = "UTF-8"; + + final String fileName = "LineIterator-" + lineCount + "-test.txt"; + final File testFile = new File(getTestDirectory(), fileName); + final List lines = createLinesFile(testFile, encoding, lineCount); + + final LineIterator iterator = FileUtils.lineIterator(testFile, encoding); + try { + try { + iterator.remove(); + fail("Remove is unsupported"); + } catch (final UnsupportedOperationException ex) { + // expected + } + + int idx = 0; + while (iterator.hasNext()) { + final String line = iterator.next(); + assertEquals("Comparing line " + idx, lines.get(idx), line); + assertTrue("Exceeded expected idx=" + idx + " size=" + lines.size(), idx < lines.size()); + idx++; + } + assertEquals("Line Count doesn't match", idx, lines.size()); + + // try calling next() after file processed + try { + iterator.next(); + fail("Expected NoSuchElementException"); + } catch (final NoSuchElementException expected) { + // ignore, expected result + } + try { + iterator.nextLine(); + fail("Expected NoSuchElementException"); + } catch (final NoSuchElementException expected) { + // ignore, expected result + } + } finally { + LineIterator.closeQuietly(iterator); + } + } + + // ----------------------------------------------------------------------- + @Test + public void testFilteringFileReader() throws Exception { + final String encoding = "UTF-8"; + + final String fileName = "LineIterator-Filter-test.txt"; + final File testFile = new File(getTestDirectory(), fileName); + final List lines = createLinesFile(testFile, encoding, 9); + + final Reader reader = new FileReader(testFile); + this.testFiltering(lines, reader); + } + + @Test + public void testFilteringBufferedReader() throws Exception { + final String encoding = "UTF-8"; + + final String fileName = "LineIterator-Filter-test.txt"; + final File testFile = new File(getTestDirectory(), fileName); + final List lines = createLinesFile(testFile, encoding, 9); + + final Reader reader = new BufferedReader(new FileReader(testFile)); + this.testFiltering(lines, reader); + } + + private void testFiltering(final List lines, final Reader reader) { + final LineIterator iterator = new LineIterator(reader) { + @Override + protected boolean isValidLine(final String line) { + final char c = line.charAt(line.length() - 1); + return (c - 48) % 3 != 1; + } + }; + try { + try { + iterator.remove(); + fail("Remove is unsupported"); + } catch (final UnsupportedOperationException ex) { + // expected + } + + int idx = 0; + int actualLines = 0; + while (iterator.hasNext()) { + final String line = iterator.next(); + actualLines++; + assertEquals("Comparing line " + idx, lines.get(idx), line); + assertTrue("Exceeded expected idx=" + idx + " size=" + lines.size(), idx < lines.size()); + idx++; + if (idx % 3 == 1) { + idx++; + } + } + assertEquals("Line Count doesn't match", 9, lines.size()); + assertEquals("Line Count doesn't match", 9, idx); + assertEquals("Line Count doesn't match", 6, actualLines); + + // try calling next() after file processed + try { + iterator.next(); + fail("Expected NoSuchElementException"); + } catch (final NoSuchElementException expected) { + // ignore, expected result + } + try { + iterator.nextLine(); + fail("Expected NoSuchElementException"); + } catch (final NoSuchElementException expected) { + // ignore, expected result + } + } finally { + LineIterator.closeQuietly(iterator); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/SelectorAdapter.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/SelectorAdapter.java" new file mode 100644 index 0000000000000000000000000000000000000000..44f368f09e68690b6a6b2fc57423d97f47613b46 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/SelectorAdapter.java" @@ -0,0 +1,76 @@ +/* + * 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.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.spi.SelectorProvider; +import java.util.Set; + +/** + * Extends {@link Selector} with no-ops for testing. + * + * @version $Id: SelectorAdapter.java 1471765 2013-04-24 23:20:29Z sebb $ + */ +public class SelectorAdapter extends Selector { + + @Override + public boolean isOpen() { + return false; + } + + @Override + public SelectorProvider provider() { + return null; + } + + @Override + public Set keys() { + return null; + } + + @Override + public Set selectedKeys() { + return null; + } + + @Override + public int selectNow() throws IOException { + return 0; + } + + @Override + public int select(final long timeout) throws IOException { + return 0; + } + + @Override + public int select() throws IOException { + return 0; + } + + @Override + public Selector wakeup() { + return null; + } + + @Override + public void close() throws IOException { + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/TaggedIOExceptionTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/TaggedIOExceptionTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..9fd09440fdb2bb7021143e95688cbfc0442d4a7a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/TaggedIOExceptionTest.java" @@ -0,0 +1,46 @@ +/* + * 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; +import java.util.UUID; + +import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * JUnit Test Case for {@link TaggedIOException}. + */ +public class TaggedIOExceptionTest { + + @Test + public void testTaggedIOException() { + final Serializable tag = UUID.randomUUID(); + final IOException exception = new IOException("Test exception"); + final TaggedIOException tagged = new TaggedIOException(exception, tag); + assertTrue(TaggedIOException.isTaggedWith(tagged, tag)); + assertFalse(TaggedIOException.isTaggedWith(tagged, UUID.randomUUID())); + assertEquals(exception, tagged.getCause()); + assertEquals(exception.getMessage(), tagged.getMessage()); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..784c50d3788ec8d524ac7f02870697c1beebcbbd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/ThreadMonitorTestCase.java" @@ -0,0 +1,86 @@ +/* + * 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 org.apache.commons.io.testtools.TestUtils; +import org.junit.Test; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +/** + * Tests for {@link ThreadMonitor}. + */ +public class ThreadMonitorTestCase { + + /** + * Test timeout. + */ + @Test + public void testTimeout() { + try { + final Thread monitor = ThreadMonitor.start(100); + TestUtils.sleep(200); + ThreadMonitor.stop(monitor); + fail("Expected InterruptedException"); + } catch (final InterruptedException e) { + // expected result - timeout + } + } + + /** + * Test task completed before timeout. + */ + @Test + public void testCompletedWithoutTimeout() { + try { + final Thread monitor = ThreadMonitor.start(200); + TestUtils.sleep(100); + ThreadMonitor.stop(monitor); + } catch (final InterruptedException e) { + fail("Timed Out"); + } + } + + /** + * Test No timeout. + */ + @Test + public void testNoTimeout() { + + // timeout = -1 + try { + final Thread monitor = ThreadMonitor.start(-1); + assertNull("Timeout -1, Monitor should be null", monitor); + TestUtils.sleep(100); + ThreadMonitor.stop(monitor); + } catch (final Exception e) { + fail("Timeout -1, threw " + e); + } + + // timeout = 0 + try { + final Thread monitor = ThreadMonitor.start(0); + assertNull("Timeout 0, Monitor should be null", monitor); + TestUtils.sleep(100); + ThreadMonitor.stop(monitor); + } catch (final Exception e) { + fail("Timeout 0, threw " + e); + } + } +} + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..2383908dcb5123c6d7f09912e8d037ca3d4f7297 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java" @@ -0,0 +1,145 @@ +/* + * 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.ArrayList; +import java.util.Comparator; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +/** + * Base Test case for Comparator implementations. + */ +public abstract class ComparatorAbstractTestCase extends FileBasedTestCase { + + /** comparator instance */ + protected AbstractFileComparator comparator; + + /** reverse comparator instance */ + protected Comparator reverse; + + /** File which compares equal to "equalFile2" */ + protected File equalFile1; + + /** File which compares equal to "equalFile1" */ + protected File equalFile2; + + /** File which is less than the "moreFile" */ + protected File lessFile; + + /** File which is more than the "lessFile" */ + protected File moreFile; + + /** @see junit.framework.TestCase#tearDown() */ + @After + public void tearDown() throws Exception { + comparator = null; + reverse = null; + equalFile1 = null; + equalFile2 = null; + lessFile = null; + moreFile = null; + FileUtils.deleteDirectory(getTestDirectory()); + } + + /** + * Test the comparator. + */ + @Test + public void testComparator() { + assertEquals("equal", 0, comparator.compare(equalFile1, equalFile2)); + assertTrue("less", comparator.compare(lessFile, moreFile) < 0); + assertTrue("more", comparator.compare(moreFile, lessFile) > 0); + } + + /** + * Test the comparator reversed. + */ + @Test + public void testReverseComparator() { + assertEquals("equal", 0, reverse.compare(equalFile1, equalFile2)); + assertTrue("less", reverse.compare(moreFile, lessFile) < 0); + assertTrue("more", reverse.compare(lessFile, moreFile) > 0); + } + + /** + * Test comparator array sort is null safe. + */ + @Test + public void testSortArrayNull() { + assertNull(comparator.sort((File[])null)); + } + + /** + * Test the comparator array sort. + */ + @Test + public void testSortArray() { + final File[] files = new File[3]; + files[0] = equalFile1; + files[1] = moreFile; + files[2] = lessFile; + comparator.sort(files); + assertSame("equal", lessFile, files[0]); + assertSame("less", equalFile1, files[1]); + assertSame("more", moreFile, files[2]); + } + + /** + * Test the comparator array sort. + */ + @Test + public void testSortList() { + final List files = new ArrayList(); + files.add(equalFile1); + files.add(moreFile); + files.add(lessFile); + comparator.sort(files); + assertSame("equal", lessFile, files.get(0)); + assertSame("less", equalFile1, files.get(1)); + assertSame("more", moreFile, files.get(2)); + } + + /** + * Test comparator list sort is null safe. + */ + @Test + public void testSortListNull() { + assertNull(comparator.sort((List)null)); + } + + /** + * Test comparator toString. + */ + @Test + public void testToString() { + assertNotNull("comparator", comparator.toString()); + assertTrue("reverse", reverse.toString().startsWith("ReverseComparator[")); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..2363642e5c7e35d6dd395af803cb55cd8111f159 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/CompositeFileComparatorTest.java" @@ -0,0 +1,134 @@ +/* + * 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 org.apache.commons.io.IOUtils; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.Before; +import org.junit.Test; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Test case for {@link CompositeFileComparator}. + */ +public class CompositeFileComparatorTest extends ComparatorAbstractTestCase { + + @Before + public void setUp() throws Exception { + comparator = new CompositeFileComparator( + new AbstractFileComparator[] { + (AbstractFileComparator) SizeFileComparator.SIZE_COMPARATOR, + (AbstractFileComparator) ExtensionFileComparator.EXTENSION_COMPARATOR}); + reverse = new ReverseComparator(comparator); + final File dir = getTestDirectory(); + lessFile = new File(dir, "xyz.txt"); + equalFile1 = new File(dir, "foo.txt"); + equalFile2 = new File(dir, "bar.txt"); + moreFile = new File(dir, "foo.xyz"); + if (!lessFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + lessFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output3 = + new BufferedOutputStream(new FileOutputStream(lessFile)); + try { + TestUtils.generateTestData(output3, (long) 32); + } finally { + IOUtils.closeQuietly(output3); + } + if (!equalFile1.getParentFile().exists()) { + throw new IOException("Cannot create file " + equalFile1 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output2 = + new BufferedOutputStream(new FileOutputStream(equalFile1)); + try { + TestUtils.generateTestData(output2, (long) 48); + } finally { + IOUtils.closeQuietly(output2); + } + if (!equalFile2.getParentFile().exists()) { + throw new IOException("Cannot create file " + equalFile2 + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(equalFile2)); + try { + TestUtils.generateTestData(output1, (long) 48); + } finally { + IOUtils.closeQuietly(output1); + } + if (!moreFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + moreFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(moreFile)); + try { + TestUtils.generateTestData(output, (long) 48); + } finally { + IOUtils.closeQuietly(output); + } + } + + /** + * Test Constructor with null Iterable + */ + @Test + public void constructorIterable_order() { + final List> list = new ArrayList>(); + list.add(SizeFileComparator.SIZE_COMPARATOR); + list.add(ExtensionFileComparator.EXTENSION_COMPARATOR); + final Comparator c = new CompositeFileComparator(list); + + assertEquals("equal", 0, c.compare(equalFile1, equalFile2)); + assertTrue("less", c.compare(lessFile, moreFile) < 0); + assertTrue("more", c.compare(moreFile, lessFile) > 0); + } + + /** + * Test Constructor with null Iterable + */ + @Test + public void constructorIterable_Null() { + final Comparator c = new CompositeFileComparator((Iterable>)null); + assertEquals("less,more", 0, c.compare(lessFile, moreFile)); + assertEquals("more,less", 0, c.compare(moreFile, lessFile)); + assertEquals("toString", "CompositeFileComparator{}", c.toString()); + } + + /** + * Test Constructor with null array + */ + @Test + public void constructorArray_Null() { + final Comparator c = new CompositeFileComparator((Comparator[])null); + assertEquals("less,more", 0, c.compare(lessFile, moreFile)); + assertEquals("more,less", 0, c.compare(moreFile, lessFile)); + assertEquals("toString", "CompositeFileComparator{}", c.toString()); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/DefaultFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/DefaultFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..bbf0f74572caf65c1aebd55f2e409f3cf68e777c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/DefaultFileComparatorTest.java" @@ -0,0 +1,37 @@ +/* + * 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 org.junit.Before; + +import java.io.File; + +/** + * Test case for {@link DefaultFileComparator}. + */ +public class DefaultFileComparatorTest extends ComparatorAbstractTestCase { + + @Before + public void setUp() throws Exception { + comparator = (AbstractFileComparator) DefaultFileComparator.DEFAULT_COMPARATOR; + reverse = DefaultFileComparator.DEFAULT_REVERSE; + equalFile1 = new File("foo"); + equalFile2 = new File("foo"); + lessFile = new File("abc"); + moreFile = new File("xyz"); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/DirectoryFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/DirectoryFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..673937dd191e2b7d2ae9c0cd3a1319f3a2f39f8e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/DirectoryFileComparatorTest.java" @@ -0,0 +1,56 @@ +/* + * 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 org.junit.Before; +import org.junit.Test; + +import java.io.File; + +/** + * Test case for {@link DirectoryFileComparator}. + */ +public class DirectoryFileComparatorTest extends ComparatorAbstractTestCase { + + @Before + public void setUp() throws Exception { + comparator = (AbstractFileComparator) DirectoryFileComparator.DIRECTORY_COMPARATOR; + reverse = DirectoryFileComparator.DIRECTORY_REVERSE; + final File currentDir = new File("."); + equalFile1 = new File(currentDir, "src"); + equalFile2 = new File(currentDir, "src/site/xdoc"); + lessFile = new File(currentDir, "src"); + moreFile = new File(currentDir, "pom.xml"); + } + + /** + * Test the comparator array sort. + */ + @Test + public void testSortArray() { + // skip sort test + } + + /** + * Test the comparator array sort. + */ + @Override + public void testSortList() { + // skip sort test + } +} + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/ExtensionFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/ExtensionFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..79d84b5fe3e9774b2aed1a02c1e9f8380a845b9e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/ExtensionFileComparatorTest.java" @@ -0,0 +1,58 @@ +/* + * 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 org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.Comparator; + +import static org.junit.Assert.assertTrue; + +/** + * Test case for {@link ExtensionFileComparator}. + */ +public class ExtensionFileComparatorTest extends ComparatorAbstractTestCase { + + + @Before + public void setUp() throws Exception { + comparator = (AbstractFileComparator) ExtensionFileComparator.EXTENSION_COMPARATOR; + reverse = ExtensionFileComparator.EXTENSION_REVERSE; + equalFile1 = new File("abc.foo"); + equalFile2 = new File("def.foo"); + lessFile = new File("abc.abc"); + moreFile = new File("abc.xyz"); + } + + /** Test case sensitivity */ + @Test + public void testCaseSensitivity() { + final File file3 = new File("abc.FOO"); + final Comparator sensitive = new ExtensionFileComparator(null); /* test null as well */ + assertTrue("sensitive file1 & file2 = 0", sensitive.compare(equalFile1, equalFile2) == 0); + assertTrue("sensitive file1 & file3 > 0", sensitive.compare(equalFile1, file3) > 0); + assertTrue("sensitive file1 & less > 0", sensitive.compare(equalFile1, lessFile) > 0); + + final Comparator insensitive = ExtensionFileComparator.EXTENSION_INSENSITIVE_COMPARATOR; + assertTrue("insensitive file1 & file2 = 0", insensitive.compare(equalFile1, equalFile2) == 0); + assertTrue("insensitive file1 & file3 = 0", insensitive.compare(equalFile1, file3) == 0); + assertTrue("insensitive file1 & file4 > 0", insensitive.compare(equalFile1, lessFile) > 0); + assertTrue("insensitive file3 & less > 0", insensitive.compare(file3, lessFile) > 0); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..f85c1968289dac03a961f16e091496f60c949fb1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/LastModifiedFileComparatorTest.java" @@ -0,0 +1,90 @@ +/* + * 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 org.apache.commons.io.IOUtils; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.Before; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * Test case for {@link LastModifiedFileComparator}. + */ +public class LastModifiedFileComparatorTest extends ComparatorAbstractTestCase { + + @Before + public void setUp() throws Exception { + comparator = (AbstractFileComparator) LastModifiedFileComparator.LASTMODIFIED_COMPARATOR; + reverse = LastModifiedFileComparator.LASTMODIFIED_REVERSE; + final File dir = getTestDirectory(); + final File olderFile = new File(dir, "older.txt"); + if (!olderFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + olderFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output2 = + new BufferedOutputStream(new FileOutputStream(olderFile)); + try { + TestUtils.generateTestData(output2, (long) 0); + } finally { + IOUtils.closeQuietly(output2); + } + + final File equalFile = new File(dir, "equal.txt"); + if (!equalFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + equalFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(equalFile)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + do { + TestUtils.sleepQuietly(300); + equalFile.setLastModified(System.currentTimeMillis()); + } while( olderFile.lastModified() == equalFile.lastModified() ); + + final File newerFile = new File(dir, "newer.txt"); + if (!newerFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + newerFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(newerFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + do { + TestUtils.sleepQuietly(300); + newerFile.setLastModified(System.currentTimeMillis()); + } while( equalFile.lastModified() == newerFile.lastModified() ); + equalFile1 = equalFile; + equalFile2 = equalFile; + lessFile = olderFile; + moreFile = newerFile; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/NameFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/NameFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..5214c5c0c81c713d4d98abadf0947749023ab2a2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/NameFileComparatorTest.java" @@ -0,0 +1,58 @@ +/* + * 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 org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.Comparator; + +import static org.junit.Assert.assertTrue; + +/** + * Test case for {@link NameFileComparator}. + */ +public class NameFileComparatorTest extends ComparatorAbstractTestCase { + + /** @see junit.framework.TestCase#setUp() */ + @Before + public void setUp() throws Exception { + comparator = (AbstractFileComparator) NameFileComparator.NAME_INSENSITIVE_COMPARATOR; + reverse = NameFileComparator.NAME_REVERSE; + equalFile1 = new File("a/foo.txt"); + equalFile2 = new File("b/foo.txt"); + lessFile = new File("c/ABC.txt"); + moreFile = new File("d/XYZ.txt"); + } + + /** Test case sensitivity */ + @Test + public void testCaseSensitivity() { + final File file3 = new File("a/FOO.txt"); + final Comparator sensitive = new NameFileComparator(null); /* test null as well */ + assertTrue("sensitive file1 & file2 = 0", sensitive.compare(equalFile1, equalFile2) == 0); + assertTrue("sensitive file1 & file3 > 0", sensitive.compare(equalFile1, file3) > 0); + assertTrue("sensitive file1 & less > 0", sensitive.compare(equalFile1, lessFile) > 0); + + final Comparator insensitive = NameFileComparator.NAME_INSENSITIVE_COMPARATOR; + assertTrue("insensitive file1 & file2 = 0", insensitive.compare(equalFile1, equalFile2) == 0); + assertTrue("insensitive file1 & file3 = 0", insensitive.compare(equalFile1, file3) == 0); + assertTrue("insensitive file1 & file4 > 0", insensitive.compare(equalFile1, lessFile) > 0); + assertTrue("insensitive file3 & less > 0", insensitive.compare(file3, lessFile) > 0); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/PathFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/PathFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..f84916e25c7894aed8e7a938d2e280f9041dc4fa --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/PathFileComparatorTest.java" @@ -0,0 +1,58 @@ +/* + * 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 org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.Comparator; + +import static org.junit.Assert.assertTrue; + +/** + * Test case for {@link PathFileComparator}. + */ +public class PathFileComparatorTest extends ComparatorAbstractTestCase { + + + @Before + public void setUp() throws Exception { + comparator = (AbstractFileComparator) PathFileComparator.PATH_COMPARATOR; + reverse = PathFileComparator.PATH_REVERSE; + equalFile1 = new File("foo/file.txt"); + equalFile2 = new File("foo/file.txt"); + lessFile = new File("abc/file.txt"); + moreFile = new File("xyz/file.txt"); + } + + /** Test case sensitivity */ + @Test + public void testCaseSensitivity() { + final File file3 = new File("FOO/file.txt"); + final Comparator sensitive = new PathFileComparator(null); /* test null as well */ + assertTrue("sensitive file1 & file2 = 0", sensitive.compare(equalFile1, equalFile2) == 0); + assertTrue("sensitive file1 & file3 > 0", sensitive.compare(equalFile1, file3) > 0); + assertTrue("sensitive file1 & less > 0", sensitive.compare(equalFile1, lessFile) > 0); + + final Comparator insensitive = PathFileComparator.PATH_INSENSITIVE_COMPARATOR; + assertTrue("insensitive file1 & file2 = 0", insensitive.compare(equalFile1, equalFile2) == 0); + assertTrue("insensitive file1 & file3 = 0", insensitive.compare(equalFile1, file3) == 0); + assertTrue("insensitive file1 & file4 > 0", insensitive.compare(equalFile1, lessFile) > 0); + assertTrue("insensitive file3 & less > 0", insensitive.compare(file3, lessFile) > 0); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..84c25b8f3b45aca0746efb938960067d001e1d25 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/comparator/SizeFileComparatorTest.java" @@ -0,0 +1,114 @@ +/* + * 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 org.apache.commons.io.IOUtils; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.Before; +import org.junit.Test; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Test case for {@link SizeFileComparator}. + */ +public class SizeFileComparatorTest extends ComparatorAbstractTestCase { + + private File smallerDir; + private File largerDir; + private File smallerFile; + private File largerFile; + + /** @see junit.framework.TestCase#setUp() */ + @Before + public void setUp() throws Exception { + comparator = (AbstractFileComparator) SizeFileComparator.SIZE_COMPARATOR; + reverse = SizeFileComparator.SIZE_REVERSE; + final File dir = getTestDirectory(); + smallerDir = new File(dir, "smallerdir"); + largerDir = new File(dir, "largerdir"); + smallerFile = new File(smallerDir, "smaller.txt"); + final File equalFile = new File(dir, "equal.txt"); + largerFile = new File(largerDir, "larger.txt"); + smallerDir.mkdir(); + largerDir.mkdir(); + if (!smallerFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + smallerFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output2 = + new BufferedOutputStream(new FileOutputStream(smallerFile)); + try { + TestUtils.generateTestData(output2, (long) 32); + } finally { + IOUtils.closeQuietly(output2); + } + if (!equalFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + equalFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(equalFile)); + try { + TestUtils.generateTestData(output1, (long) 48); + } finally { + IOUtils.closeQuietly(output1); + } + if (!largerFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + largerFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(largerFile)); + try { + TestUtils.generateTestData(output, (long) 64); + } finally { + IOUtils.closeQuietly(output); + } + equalFile1 = equalFile; + equalFile2 = equalFile; + lessFile = smallerFile; + moreFile = largerFile; + } + + /** + * Test a file which doesn't exist. + */ + @Test + public void testNonexistantFile() { + final File nonexistantFile = new File(new File("."), "nonexistant.txt"); + assertFalse(nonexistantFile.exists()); + assertTrue("less", comparator.compare(nonexistantFile, moreFile) < 0); + } + + /** + * Test a file which doesn't exist. + */ + @Test + public void testCompareDirectorySizes() { + assertEquals("sumDirectoryContents=false", 0, comparator.compare(smallerDir, largerDir)); + assertEquals("less", -1, SizeFileComparator.SIZE_SUMDIR_COMPARATOR.compare(smallerDir, largerDir)); + assertEquals("less", 1, SizeFileComparator.SIZE_SUMDIR_REVERSE.compare(smallerDir, largerDir)); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..ea3fe8efc79559414471594281febe0fdca54e17 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/AndFileFilterTestCase.java" @@ -0,0 +1,294 @@ +/* + * 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 org.junit.Before; + +import java.util.ArrayList; +import java.util.List; + +public class AndFileFilterTestCase extends ConditionalFileFilterAbstractTestCase { + + private static final String DEFAULT_WORKING_PATH = "./AndFileFilterTestCase/"; + private static final String WORKING_PATH_NAME_PROPERTY_KEY = AndFileFilterTestCase.class.getName() + ".workingDirectory"; + + private List> testFilters; + private List testTrueResults; + private List testFalseResults; + private List testFileResults; + private List testFilenameResults; + + @Override + protected IOFileFilter buildFilterUsingAdd(final List filters) { + final AndFileFilter filter = new AndFileFilter(); + for (IOFileFilter filter1 : filters) { + filter.addFileFilter(filter1); + } + return filter; + } + + @Override + protected IOFileFilter buildFilterUsingConstructor(final List filters) { + return new AndFileFilter(filters); + } + + @Override + protected ConditionalFileFilter getConditionalFileFilter() { + return new AndFileFilter(); + } + + @Override + protected String getDefaultWorkingPath() { + return DEFAULT_WORKING_PATH; + } + + @Override + protected List getFalseResults() { + return this.testFalseResults; + } + + @Override + protected List getFileResults() { + return this.testFileResults; + } + + @Override + protected List getFilenameResults() { + return this.testFilenameResults; + } + + @Override + protected List> getTestFilters() { + return this.testFilters; + } + + @Override + protected List getTrueResults() { + return this.testTrueResults; + } + + @Override + protected String getWorkingPathNamePropertyKey() { + return WORKING_PATH_NAME_PROPERTY_KEY; + } + + @Before + public void setUpTestFilters() { + // filters + //tests + this.testFilters = new ArrayList>(); + this.testTrueResults = new ArrayList(); + this.testFalseResults = new ArrayList(); + this.testFileResults = new ArrayList(); + this.testFilenameResults = new ArrayList(); + + // test 0 - add empty elements + { + testFilters.add(0, null); + testTrueResults.add(0, null); + testFalseResults.add(0, null); + testFileResults.add(0, null); + testFilenameResults.add(0, null); + } + + // test 1 - Test conditional and with all filters returning true + { + // test 1 filters + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + // test 1 true results + final boolean[] trueResults = new boolean[] {true, true, true}; + // test 1 false results + final boolean[] falseResults = new boolean[] {false, false, false}; + + testFilters.add(1, filters); + testTrueResults.add(1, trueResults); + testFalseResults.add(1, falseResults); + testFileResults.add(1, Boolean.TRUE); + testFilenameResults.add(1, Boolean.TRUE); + } + + // test 2 - Test conditional and with first filter returning false + { + // test 2 filters + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 2 true results + final boolean[] trueResults = new boolean[] {false, false, false}; + // test 2 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(2, filters); + testTrueResults.add(2, trueResults); + testFalseResults.add(2, falseResults); + testFileResults.add(2, Boolean.FALSE); + testFilenameResults.add(2, Boolean.FALSE); + } + + // test 3 - Test conditional and with second filter returning false + { + // test 3 filters + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(falseFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 3 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 3 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(3, filters); + testTrueResults.add(3, trueResults); + testFalseResults.add(3, falseResults); + testFileResults.add(3, Boolean.FALSE); + testFilenameResults.add(3, Boolean.FALSE); + } + + // test 4 - Test conditional and with third filter returning false + { + // test 4 filters + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(falseFilters[1]); + filters.add(trueFilters[3]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 4 true results + final boolean[] trueResults = new boolean[] {true, true, false}; + // test 4 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(4, filters); + testTrueResults.add(4, trueResults); + testFalseResults.add(4, falseResults); + testFileResults.add(4, Boolean.FALSE); + testFilenameResults.add(4, Boolean.FALSE); + } + + // test 5 - Test conditional and with first and third filters returning false + { + // test 5 filters + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(trueFilters[1]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + // test 5 true results + final boolean[] trueResults = new boolean[] {false, false, false}; + // test 5 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(5, filters); + testTrueResults.add(5, trueResults); + testFalseResults.add(5, falseResults); + testFileResults.add(5, Boolean.FALSE); + testFilenameResults.add(5, Boolean.FALSE); + } + + // test 6 - Test conditional and with second and third filters returning false + { + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(falseFilters[1]); + filters.add(falseFilters[2]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[3]); + // test 6 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 6 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(6, filters); + testTrueResults.add(6, trueResults); + testFalseResults.add(6, falseResults); + testFileResults.add(6, Boolean.FALSE); + testFilenameResults.add(6, Boolean.FALSE); + } + + // test 7 - Test conditional and with first and second filters returning false + { + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(falseFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[3]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + // test 7 true results + final boolean[] trueResults = new boolean[] {false, false, false}; + // test 7 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(7, filters); + testTrueResults.add(7, trueResults); + testFalseResults.add(7, falseResults); + testFileResults.add(7, Boolean.FALSE); + testFilenameResults.add(7, Boolean.FALSE); + } + + // test 8 - Test conditional and with fourth filters returning false + { + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[1]); + // test 8 true results + final boolean[] trueResults = new boolean[] {true, true, true}; + // test 8 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(8, filters); + testTrueResults.add(8, trueResults); + testFalseResults.add(8, falseResults); + testFileResults.add(8, Boolean.FALSE); + testFilenameResults.add(8, Boolean.FALSE); + } + + // test 9 - Test conditional and with all filters returning false + { + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 9 true results + final boolean[] trueResults = new boolean[] {false, false, false}; + // test 9 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(9, filters); + testTrueResults.add(9, trueResults); + testFalseResults.add(9, falseResults); + testFileResults.add(9, Boolean.FALSE); + testFilenameResults.add(9, Boolean.FALSE); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..9d0afa25a6b85dd1795b77ac9efe02694b777f96 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/ConditionalFileFilterAbstractTestCase.java" @@ -0,0 +1,183 @@ +/* + * 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 org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public abstract class ConditionalFileFilterAbstractTestCase extends IOFileFilterAbstractTestCase { + + private static final String TEST_FILE_NAME_PREFIX = "TestFile"; + private static final String TEST_FILE_TYPE = ".tst"; + + protected TesterTrueFileFilter[] trueFilters; + protected TesterFalseFileFilter[] falseFilters; + + private File file; + private File workingPath; + + @Before + public void setUp() throws Exception { + this.workingPath = determineWorkingDirectoryPath(this.getWorkingPathNamePropertyKey(), this.getDefaultWorkingPath()); + this.file = new File(this.workingPath, TEST_FILE_NAME_PREFIX + 1 + TEST_FILE_TYPE); + this.trueFilters = new TesterTrueFileFilter[4]; + this.falseFilters = new TesterFalseFileFilter[4]; + this.trueFilters[1] = new TesterTrueFileFilter(); + this.trueFilters[2] = new TesterTrueFileFilter(); + this.trueFilters[3] = new TesterTrueFileFilter(); + this.falseFilters[1] = new TesterFalseFileFilter(); + this.falseFilters[2] = new TesterFalseFileFilter(); + this.falseFilters[3] = new TesterFalseFileFilter(); + } + + @Test + public void testAdd() { + final List filters = new ArrayList(); + final ConditionalFileFilter fileFilter = this.getConditionalFileFilter(); + filters.add(new TesterTrueFileFilter()); + filters.add(new TesterTrueFileFilter()); + filters.add(new TesterTrueFileFilter()); + filters.add(new TesterTrueFileFilter()); + for (int i = 0; i < filters.size(); i++) { + assertEquals("file filters count: ", i, fileFilter.getFileFilters().size()); + fileFilter.addFileFilter(filters.get(i)); + assertEquals("file filters count: ", i + 1, fileFilter.getFileFilters().size()); + } + for (final IOFileFilter filter : fileFilter.getFileFilters()) { + assertTrue("found file filter", filters.contains(filter)); + } + assertEquals("file filters count", filters.size(), fileFilter.getFileFilters().size()); + } + + @Test + public void testRemove() { + final List filters = new ArrayList(); + final ConditionalFileFilter fileFilter = this.getConditionalFileFilter(); + filters.add(new TesterTrueFileFilter()); + filters.add(new TesterTrueFileFilter()); + filters.add(new TesterTrueFileFilter()); + filters.add(new TesterTrueFileFilter()); + for (TesterTrueFileFilter filter : filters) { + fileFilter.removeFileFilter(filter); + assertTrue("file filter removed", !fileFilter.getFileFilters().contains(filter)); + } + assertEquals("file filters count", 0, fileFilter.getFileFilters().size()); + } + + @Test + public void testNoFilters() throws Exception { + final ConditionalFileFilter fileFilter = this.getConditionalFileFilter(); + final File file = new File(this.workingPath, TEST_FILE_NAME_PREFIX + 1 + TEST_FILE_TYPE); + assertFileFiltering(1, (IOFileFilter) fileFilter, file, false); + assertFilenameFiltering(1, (IOFileFilter) fileFilter, file, false); + } + + @Test + public void testFilterBuiltUsingConstructor() throws Exception { + final List> testFilters = this.getTestFilters(); + final List testTrueResults = this.getTrueResults(); + final List testFalseResults = this.getFalseResults(); + final List testFileResults = this.getFileResults(); + final List testFilenameResults = this.getFilenameResults(); + + for (int i = 1; i < testFilters.size(); i++) { + final List filters = testFilters.get(i); + final boolean[] trueResults = testTrueResults.get(i); + final boolean[] falseResults = testFalseResults.get(i); + final boolean fileResults = testFileResults.get(i); + final boolean filenameResults = testFilenameResults.get(i); + + // Test conditional AND filter created by passing filters to the constructor + final IOFileFilter filter = this.buildFilterUsingConstructor(filters); + + // Test as a file filter + resetTrueFilters(this.trueFilters); + resetFalseFilters(this.falseFilters); + assertFileFiltering(i, filter, this.file, fileResults); + assertTrueFiltersInvoked(i, trueFilters, trueResults); + assertFalseFiltersInvoked(i, falseFilters, falseResults); + + // Test as a filename filter + resetTrueFilters(this.trueFilters); + resetFalseFilters(this.falseFilters); + assertFilenameFiltering(i, filter, this.file, filenameResults); + assertTrueFiltersInvoked(i, trueFilters, trueResults); + assertFalseFiltersInvoked(i, falseFilters, falseResults); + } + } + + @Test + public void testFilterBuiltUsingAdd() throws Exception { + final List> testFilters = this.getTestFilters(); + final List testTrueResults = this.getTrueResults(); + final List testFalseResults = this.getFalseResults(); + final List testFileResults = this.getFileResults(); + final List testFilenameResults = this.getFilenameResults(); + + for (int i = 1; i < testFilters.size(); i++) { + final List filters = testFilters.get(i); + final boolean[] trueResults = testTrueResults.get(i); + final boolean[] falseResults = testFalseResults.get(i); + final boolean fileResults = testFileResults.get(i); + final boolean filenameResults = testFilenameResults.get(i); + + // Test conditional AND filter created by passing filters to the constructor + final IOFileFilter filter = this.buildFilterUsingAdd(filters); + + // Test as a file filter + resetTrueFilters(this.trueFilters); + resetFalseFilters(this.falseFilters); + assertFileFiltering(i, filter, this.file, fileResults); + assertTrueFiltersInvoked(i, trueFilters, trueResults); + assertFalseFiltersInvoked(i, falseFilters, falseResults); + + // Test as a filename filter + resetTrueFilters(this.trueFilters); + resetFalseFilters(this.falseFilters); + assertFilenameFiltering(i, filter, this.file, filenameResults); + assertTrueFiltersInvoked(i, trueFilters, trueResults); + assertFalseFiltersInvoked(i, falseFilters, falseResults); + } + } + + protected abstract ConditionalFileFilter getConditionalFileFilter(); + + protected abstract IOFileFilter buildFilterUsingAdd(List filters); + + protected abstract IOFileFilter buildFilterUsingConstructor(List filters); + + protected abstract List> getTestFilters(); + + protected abstract List getTrueResults(); + + protected abstract List getFalseResults(); + + protected abstract List getFileResults(); + + protected abstract List getFilenameResults(); + + protected abstract String getWorkingPathNamePropertyKey(); + + protected abstract String getDefaultWorkingPath(); +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..51d092bb0b7cdce7e443192ad3543dda2b6934ce --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java" @@ -0,0 +1,1567 @@ +/* + * 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 org.apache.commons.io.Charsets; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOCase; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.*; +import java.util.*; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Used to test FileFilterUtils. + */ +public class FileFilterTestCase extends FileBasedTestCase { + + /** + * The subversion directory name. + */ + static final String SVN_DIR_NAME = ".svn"; + + private static final boolean WINDOWS = File.separatorChar == '\\'; + + @Before + public void setUp() { + getTestDirectory(); + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(getTestDirectory()); + } + + public void assertFiltering(final IOFileFilter filter, final File file, final boolean expected) throws Exception { + // Note. This only tests the (File, String) version if the parent of + // the File passed in is not null + assertEquals( + "Filter(File) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file)); + + if (file != null && file.getParentFile() != null) { + assertEquals( + "Filter(File, String) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file.getParentFile(), file.getName())); + } else if (file == null) { + assertEquals( + "Filter(File, String) " + filter.getClass().getName() + " not " + expected + " for null", + expected, filter.accept(file)); + } + assertNotNull(filter.toString()); + } + + + + @Test + public void testSuffix() throws Exception { + IOFileFilter filter = new SuffixFileFilter(new String[] { "tes", "est" }); + final File testFile = new File( "test" ); + final File fredFile = new File( "fred" ); + assertFiltering(filter, new File("fred.tes"), true); + assertFiltering(filter, new File("fred.est"), true); + assertFiltering(filter, new File("fred.EST"), false); //case-sensitive + assertFiltering(filter, new File("fred.exe"), false); + + filter = FileFilterUtils.or( + FileFilterUtils.suffixFileFilter( "tes" ), + FileFilterUtils.suffixFileFilter( "est" ) ); + assertFiltering(filter, new File("fred"), false); + assertFiltering(filter, new File(".tes"), true); + assertFiltering(filter, new File("fred.test"), true); + + filter = new SuffixFileFilter("est"); + assertFiltering(filter, new File("test"), true); + assertFiltering(filter, new File("fred"), false); + + assertTrue( filter.accept( testFile.getParentFile(), testFile.getName() ) ); + assertTrue( !filter.accept( fredFile.getParentFile(), fredFile.getName() ) ); + + final List prefixes = Arrays.asList("ood", "red"); + final IOFileFilter listFilter = new SuffixFileFilter( prefixes ); + + assertTrue( !listFilter.accept( testFile.getParentFile(), testFile.getName() ) ); + assertTrue( listFilter.accept( fredFile.getParentFile(), fredFile.getName() ) ); + + try { + new SuffixFileFilter((String) null); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new SuffixFileFilter((String[]) null); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new SuffixFileFilter((List) null); + fail(); + } catch (final IllegalArgumentException ignore) { + } +} + + @Test + public void testSuffixCaseInsensitive() throws Exception { + + IOFileFilter filter = new SuffixFileFilter(new String[] { "tes", "est" }, IOCase.INSENSITIVE); + assertFiltering(filter, new File("foo.tes"), true); + assertFiltering(filter, new File("foo.est"), true); + assertFiltering(filter, new File("foo.EST"), true); //case-sensitive + assertFiltering(filter, new File("foo.TES"), true); //case-sensitive + assertFiltering(filter, new File("foo.exe"), false); + + filter = new SuffixFileFilter("est", IOCase.INSENSITIVE); + assertFiltering(filter, new File("test"), true); + assertFiltering(filter, new File("TEST"), true); + + final List suffixes = Arrays.asList("tes", "est"); + filter = new SuffixFileFilter(suffixes, IOCase.INSENSITIVE); + assertFiltering(filter, new File("bar.tes"), true); + assertFiltering(filter, new File("bar.est"), true); + assertFiltering(filter, new File("bar.EST"), true); //case-sensitive + assertFiltering(filter, new File("bar.TES"), true); //case-sensitive + assertFiltering(filter, new File("bar.exe"), false); + + try { + new SuffixFileFilter((String) null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new SuffixFileFilter((String[]) null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new SuffixFileFilter((List) null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + // FileFilterUtils.suffixFileFilter(String, IOCase) tests + filter = FileFilterUtils.suffixFileFilter("est", IOCase.INSENSITIVE); + assertFiltering(filter, new File("test"), true); + assertFiltering(filter, new File("TEST"), true); + + try { + FileFilterUtils.suffixFileFilter(null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ex) { + } + } + + @Test + public void testDirectory() throws Exception { + // XXX: This test presumes the current working dir is the base dir of the source checkout. + final IOFileFilter filter = new DirectoryFileFilter(); + + assertFiltering(filter, new File("src/"), true); + assertFiltering(filter, new File("src/main/java/"), true); + + assertFiltering(filter, new File("pom.xml"), false); + + assertFiltering(filter, new File("imaginary"), false); + assertFiltering(filter, new File("imaginary/"), false); + + assertFiltering(filter, new File("LICENSE.txt"), false); + + assertSame(DirectoryFileFilter.DIRECTORY, DirectoryFileFilter.INSTANCE); + } + + @Test + public void testFiles() throws Exception { + // XXX: This test presumes the current working dir is the base dir of the source checkout. + final IOFileFilter filter = FileFileFilter.FILE; + + assertFiltering(filter, new File("src/"), false); + assertFiltering(filter, new File("src/java/"), false); + + assertFiltering(filter, new File("pom.xml"), true); + + assertFiltering(filter, new File("imaginary"), false); + assertFiltering(filter, new File("imaginary/"), false); + + assertFiltering(filter, new File("LICENSE.txt"), true); + } + + @Test + public void testPrefix() throws Exception { + IOFileFilter filter = new PrefixFileFilter(new String[] { "foo", "bar" }); + final File testFile = new File( "test" ); + final File fredFile = new File( "fred" ); + + assertFiltering(filter, new File("foo.test"), true); + assertFiltering(filter, new File("FOO.test"), false); //case-sensitive + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("bar"), true); + assertFiltering(filter, new File("food/"), true); + + filter = FileFilterUtils.prefixFileFilter( "bar" ); + assertFiltering(filter, new File("barred\\"), true); + assertFiltering(filter, new File("test"), false); + assertFiltering(filter, new File("fo_o.test"), false); + assertFiltering(filter, new File("abar.exe"), false); + + filter = new PrefixFileFilter("tes"); + assertFiltering(filter, new File("test"), true); + assertFiltering(filter, new File("fred"), false); + + assertTrue( filter.accept( testFile.getParentFile(), testFile.getName() ) ); + assertTrue( !filter.accept( fredFile.getParentFile(), fredFile.getName() ) ); + + final List prefixes = Arrays.asList("foo", "fre"); + final IOFileFilter listFilter = new PrefixFileFilter( prefixes ); + + assertTrue( !listFilter.accept( testFile.getParentFile(), testFile.getName() ) ); + assertTrue( listFilter.accept( fredFile.getParentFile(), fredFile.getName() ) ); + + + try { + new PrefixFileFilter((String) null); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new PrefixFileFilter((String[]) null); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new PrefixFileFilter((List) null); + fail(); + } catch (final IllegalArgumentException ignore) { + } + } + + @Test + public void testPrefixCaseInsensitive() throws Exception { + + IOFileFilter filter = new PrefixFileFilter(new String[] { "foo", "bar" }, IOCase.INSENSITIVE); + assertFiltering(filter, new File("foo.test1"), true); + assertFiltering(filter, new File("bar.test1"), true); + assertFiltering(filter, new File("FOO.test1"), true); //case-sensitive + assertFiltering(filter, new File("BAR.test1"), true); //case-sensitive + + filter = new PrefixFileFilter("bar", IOCase.INSENSITIVE); + assertFiltering(filter, new File("foo.test2"), false); + assertFiltering(filter, new File("bar.test2"), true); + assertFiltering(filter, new File("FOO.test2"), false); //case-sensitive + assertFiltering(filter, new File("BAR.test2"), true); //case-sensitive + + final List prefixes = Arrays.asList("foo", "bar"); + filter = new PrefixFileFilter(prefixes, IOCase.INSENSITIVE); + assertFiltering(filter, new File("foo.test3"), true); + assertFiltering(filter, new File("bar.test3"), true); + assertFiltering(filter, new File("FOO.test3"), true); //case-sensitive + assertFiltering(filter, new File("BAR.test3"), true); //case-sensitive + + try { + new PrefixFileFilter((String) null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new PrefixFileFilter((String[]) null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new PrefixFileFilter((List) null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + // FileFilterUtils.prefixFileFilter(String, IOCase) tests + filter = FileFilterUtils.prefixFileFilter("bar", IOCase.INSENSITIVE); + assertFiltering(filter, new File("foo.test2"), false); + assertFiltering(filter, new File("bar.test2"), true); + assertFiltering(filter, new File("FOO.test2"), false); //case-sensitive + assertFiltering(filter, new File("BAR.test2"), true); //case-sensitive + + try { + FileFilterUtils.prefixFileFilter(null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + } + } + + @Test + public void testNameFilter() throws Exception { + IOFileFilter filter = new NameFileFilter(new String[] { "foo", "bar" }); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("bar"), true); + assertFiltering(filter, new File("fred"), false); + + filter = new NameFileFilter(new String[] { "foo", "bar" }, IOCase.SENSITIVE); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("bar"), true); + assertFiltering(filter, new File("FOO"), false); + assertFiltering(filter, new File("BAR"), false); + + filter = new NameFileFilter(new String[] { "foo", "bar" }, IOCase.INSENSITIVE); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("bar"), true); + assertFiltering(filter, new File("FOO"), true); + assertFiltering(filter, new File("BAR"), true); + + filter = new NameFileFilter(new String[] { "foo", "bar" }, IOCase.SYSTEM); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("bar"), true); + assertFiltering(filter, new File("FOO"), WINDOWS); + assertFiltering(filter, new File("BAR"), WINDOWS); + + filter = new NameFileFilter(new String[]{"foo", "bar"}, null); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("bar"), true); + assertFiltering(filter, new File("FOO"), false); + assertFiltering(filter, new File("BAR"), false); + + // repeat for a List + final java.util.ArrayList list = new java.util.ArrayList(); + list.add("foo"); + list.add("bar"); + filter = new NameFileFilter(list); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("bar"), true); + assertFiltering(filter, new File("fred"), false); + + filter = new NameFileFilter("foo"); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("FOO"), false); //case-sensitive + assertFiltering(filter, new File("barfoo"), false); + assertFiltering(filter, new File("foobar"), false); + assertFiltering(filter, new File("fred"), false); + + // FileFilterUtils.nameFileFilter(String, IOCase) tests + filter = FileFilterUtils.nameFileFilter("foo", IOCase.INSENSITIVE); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, new File("FOO"), true); //case-insensitive + assertFiltering(filter, new File("barfoo"), false); + assertFiltering(filter, new File("foobar"), false); + assertFiltering(filter, new File("fred"), false); + } + + @Test + public void testNameFilterNullArgument() throws Exception { + final String test = null; + try { + new NameFileFilter(test); + fail( "constructing a NameFileFilter with a null String argument should fail."); + } catch( final IllegalArgumentException ignore ) { + } + + try { + FileFilterUtils.nameFileFilter(test, IOCase.INSENSITIVE); + fail( "constructing a NameFileFilter with a null String argument should fail."); + } catch( final IllegalArgumentException ignore ) { + } + } + + @Test(expected = IllegalArgumentException.class) + public void testNameFilterNullArrayArgument() throws Exception { + new NameFileFilter((String[]) null); + fail( "constructing a NameFileFilter with a null String[] argument should fail."); + } + + @Test(expected = IllegalArgumentException.class) + public void testNameFilterNullListArgument() throws Exception { + final List test = null; + new NameFileFilter(test); + fail("constructing a NameFileFilter with a null List argument should fail."); + } + + @Test + public void testTrue() throws Exception { + final IOFileFilter filter = FileFilterUtils.trueFileFilter(); + assertFiltering(filter, new File("foo.test"), true); + assertFiltering(filter, new File("foo"), true); + assertFiltering(filter, null, true); + assertSame(TrueFileFilter.TRUE, TrueFileFilter.INSTANCE); + } + + @Test + public void testFalse() throws Exception { + final IOFileFilter filter = FileFilterUtils.falseFileFilter(); + assertFiltering(filter, new File("foo.test"), false); + assertFiltering(filter, new File("foo"), false); + assertFiltering(filter, null, false); + assertSame(FalseFileFilter.FALSE, FalseFileFilter.INSTANCE); + } + + @Test(expected = IllegalArgumentException.class) + public void testNot() throws Exception { + final IOFileFilter filter = FileFilterUtils.notFileFilter(FileFilterUtils.trueFileFilter()); + assertFiltering(filter, new File("foo.test"), false); + assertFiltering(filter, new File("foo"), false); + assertFiltering(filter, null, false); + new NotFileFilter(null); + } + + @Test + public void testAnd() throws Exception { + final IOFileFilter trueFilter = TrueFileFilter.INSTANCE; + final IOFileFilter falseFilter = FalseFileFilter.INSTANCE; + assertFiltering(new AndFileFilter(trueFilter, trueFilter), new File("foo.test"), true); + assertFiltering(new AndFileFilter(trueFilter, falseFilter), new File("foo.test"), false); + assertFiltering(new AndFileFilter(falseFilter, trueFilter), new File("foo.test"), false); + assertFiltering(new AndFileFilter(falseFilter, falseFilter), new File("foo.test"), false); + + final List filters = new ArrayList(); + assertFiltering( new AndFileFilter( filters ), new File( "test" ), false ); + assertFiltering( new AndFileFilter(), new File( "test" ), false ); + + try { + new AndFileFilter(falseFilter, null); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + try { + new AndFileFilter(null, falseFilter); + fail(); + } catch (final IllegalArgumentException ignore) { + } + + final AndFileFilter f = new AndFileFilter(null); + assertTrue(f.getFileFilters().isEmpty()); + + assertNotNull(f.toString()); // TODO better tests + } + + @Test + public void testOr() throws Exception { + final IOFileFilter trueFilter = TrueFileFilter.INSTANCE; + final IOFileFilter falseFilter = FalseFileFilter.INSTANCE; + final File testFile = new File( "foo.test" ); + assertFiltering(new OrFileFilter(trueFilter, trueFilter), testFile, true); + assertFiltering(new OrFileFilter(trueFilter, falseFilter), testFile, true); + assertFiltering(new OrFileFilter(falseFilter, trueFilter), testFile, true); + assertFiltering(new OrFileFilter(falseFilter, falseFilter), testFile, false); + assertFiltering(new OrFileFilter(), testFile, false); + + final List filters = new ArrayList(); + filters.add( trueFilter ); + filters.add( falseFilter ); + + final OrFileFilter orFilter = new OrFileFilter( filters ); + + assertFiltering(orFilter, testFile, true); + assertEquals( orFilter.getFileFilters(), filters ); + orFilter.removeFileFilter( trueFilter ); + assertFiltering(orFilter, testFile, false); + orFilter.setFileFilters( filters ); + assertFiltering(orFilter, testFile, true); + + assertTrue( orFilter.accept( testFile.getParentFile(), testFile.getName() ) ); + orFilter.removeFileFilter( trueFilter ); + assertTrue( !orFilter.accept( testFile.getParentFile(), testFile.getName() ) ); + + try { + new OrFileFilter(falseFilter, null); + fail(); + } catch (final IllegalArgumentException ex) { + } + + final OrFileFilter f = new OrFileFilter(null); + assertTrue(f.getFileFilters().isEmpty()); + } + + @Test + public void testFileFilterUtils_and() throws Exception { + final IOFileFilter trueFilter = TrueFileFilter.INSTANCE; + final IOFileFilter falseFilter = FalseFileFilter.INSTANCE; + assertFiltering(FileFilterUtils.and(trueFilter, trueFilter, trueFilter), new File("foo.test"), true); + assertFiltering(FileFilterUtils.and(trueFilter, falseFilter, trueFilter), new File("foo.test"), false); + assertFiltering(FileFilterUtils.and(falseFilter, trueFilter), new File("foo.test"), false); + assertFiltering(FileFilterUtils.and(falseFilter, falseFilter), new File("foo.test"), false); + } + + @Test + public void testFileFilterUtils_or() throws Exception { + final IOFileFilter trueFilter = TrueFileFilter.INSTANCE; + final IOFileFilter falseFilter = FalseFileFilter.INSTANCE; + final File testFile = new File( "foo.test" ); + assertFiltering(FileFilterUtils.or(trueFilter, trueFilter), testFile, true); + assertFiltering(FileFilterUtils.or(trueFilter, trueFilter, falseFilter), testFile, true); + assertFiltering(FileFilterUtils.or(falseFilter, trueFilter), testFile, true); + assertFiltering(FileFilterUtils.or(falseFilter, falseFilter, falseFilter), testFile, false); + } + + @SuppressWarnings("deprecation") + @Test + public void testDeprecatedWildcard() throws Exception { + IOFileFilter filter = new WildcardFilter("*.txt"); + final List patternList = Arrays.asList("*.txt", "*.xml", "*.gif"); + final IOFileFilter listFilter = new WildcardFilter( patternList ); + final File txtFile = new File( "test.txt" ); + final File bmpFile = new File( "test.bmp" ); + final File dir = new File( "src/java" ); + + assertFiltering(filter, new File("log.txt"), true); +// assertFiltering(filter, new File("log.txt.bak"), false); + + filter = new WildcardFilter("log?.txt"); + assertFiltering(filter, new File("log1.txt"), true); + assertFiltering(filter, new File("log12.txt"), false); + + filter = new WildcardFilter("open??.????04"); + assertFiltering(filter, new File("openAB.102504"), true); + assertFiltering(filter, new File("openA.102504"), false); + assertFiltering(filter, new File("openXY.123103"), false); +// assertFiltering(filter, new File("openAB.102504.old"), false); + + filter = new WildcardFilter(new String[] {"*.java", "*.class"}); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("Test.class"), true); + assertFiltering(filter, new File("Test.jsp"), false); + + assertFiltering(listFilter, new File("Test.txt"), true); + assertFiltering(listFilter, new File("Test.xml"), true); + assertFiltering(listFilter, new File("Test.gif"), true); + assertFiltering(listFilter, new File("Test.bmp"), false); + + assertTrue( listFilter.accept( txtFile ) ); + assertTrue( !listFilter.accept( bmpFile ) ); + assertTrue( !listFilter.accept( dir ) ); + + assertTrue( listFilter.accept( txtFile.getParentFile(), txtFile.getName() ) ); + assertTrue( !listFilter.accept( bmpFile.getParentFile(), bmpFile.getName() ) ); + assertTrue( !listFilter.accept( dir.getParentFile(), dir.getName() ) ); + + try { + new WildcardFilter((String) null); + fail(); + } catch (final IllegalArgumentException ex) { + // expected + } + + try { + new WildcardFilter((String[]) null); + fail(); + } catch (final IllegalArgumentException ex) { + // expected + } + + try { + new WildcardFilter((List) null); + fail(); + } catch (final IllegalArgumentException ex) { + // expected + } + } + + @Test + public void testWildcard() throws Exception { + IOFileFilter filter = new WildcardFileFilter("*.txt"); + assertFiltering(filter, new File("log.txt"), true); + assertFiltering(filter, new File("log.TXT"), false); + + filter = new WildcardFileFilter("*.txt", IOCase.SENSITIVE); + assertFiltering(filter, new File("log.txt"), true); + assertFiltering(filter, new File("log.TXT"), false); + + filter = new WildcardFileFilter("*.txt", IOCase.INSENSITIVE); + assertFiltering(filter, new File("log.txt"), true); + assertFiltering(filter, new File("log.TXT"), true); + + filter = new WildcardFileFilter("*.txt", IOCase.SYSTEM); + assertFiltering(filter, new File("log.txt"), true); + assertFiltering(filter, new File("log.TXT"), WINDOWS); + + filter = new WildcardFileFilter("*.txt", null); + assertFiltering(filter, new File("log.txt"), true); + assertFiltering(filter, new File("log.TXT"), false); + + filter = new WildcardFileFilter(new String[] {"*.java", "*.class"}); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("Test.class"), true); + assertFiltering(filter, new File("Test.jsp"), false); + + filter = new WildcardFileFilter(new String[] {"*.java", "*.class"}, IOCase.SENSITIVE); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("Test.JAVA"), false); + + filter = new WildcardFileFilter(new String[] {"*.java", "*.class"}, IOCase.INSENSITIVE); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("Test.JAVA"), true); + + filter = new WildcardFileFilter(new String[] {"*.java", "*.class"}, IOCase.SYSTEM); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("Test.JAVA"), WINDOWS); + + filter = new WildcardFileFilter(new String[]{"*.java", "*.class"}, null); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("Test.JAVA"), false); + + final List patternList = Arrays.asList("*.txt", "*.xml", "*.gif"); + final IOFileFilter listFilter = new WildcardFileFilter( patternList ); + assertFiltering(listFilter, new File("Test.txt"), true); + assertFiltering(listFilter, new File("Test.xml"), true); + assertFiltering(listFilter, new File("Test.gif"), true); + assertFiltering(listFilter, new File("Test.bmp"), false); + + final File txtFile = new File( "test.txt" ); + final File bmpFile = new File( "test.bmp" ); + final File dir = new File( "src/java" ); + assertTrue( listFilter.accept( txtFile ) ); + assertTrue( !listFilter.accept( bmpFile ) ); + assertTrue( !listFilter.accept( dir ) ); + + assertTrue( listFilter.accept( txtFile.getParentFile(), txtFile.getName() ) ); + assertTrue( !listFilter.accept( bmpFile.getParentFile(), bmpFile.getName() ) ); + assertTrue( !listFilter.accept( dir.getParentFile(), dir.getName() ) ); + + try { + new WildcardFileFilter((String) null); + fail(); + } catch (final IllegalArgumentException ignore) {} + try { + new WildcardFileFilter((String[]) null); + fail(); + } catch (final IllegalArgumentException ignore) {} + try { + new WildcardFileFilter((List) null); + fail(); + } catch (final IllegalArgumentException ignore) {} + } + + @Test + public void testDelegateFileFilter() throws Exception { + final OrFileFilter orFilter = new OrFileFilter(); + final File testFile = new File( "test.txt" ); + + IOFileFilter filter = new DelegateFileFilter((FileFilter) orFilter); + assertFiltering( filter, testFile, false ); + assertNotNull(filter.toString()); // TODO better test + + filter = new DelegateFileFilter((FilenameFilter) orFilter); + assertFiltering( filter, testFile, false ); + assertNotNull(filter.toString()); // TODO better test + + try { + new DelegateFileFilter((FileFilter) null); + fail(); + } catch( final IllegalArgumentException ignore ) { + } + + try { + new DelegateFileFilter((FilenameFilter) null); + fail(); + } catch( final IllegalArgumentException ignore ) { + } + + } + + @Test + public void testMakeCVSAware() throws Exception { + final IOFileFilter filter1 = FileFilterUtils.makeCVSAware(null); + final IOFileFilter filter2 = FileFilterUtils.makeCVSAware(FileFilterUtils + .nameFileFilter("test-file1.txt")); + + File file = new File(getTestDirectory(), "CVS"); + file.mkdirs(); + assertFiltering(filter1, file, false); + assertFiltering(filter2, file, false); + FileUtils.deleteDirectory(file); + + file = new File(getTestDirectory(), "test-file1.txt"); + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output2 = + new BufferedOutputStream(new FileOutputStream(file)); + try { + TestUtils.generateTestData(output2, (long) 0); + } finally { + IOUtils.closeQuietly(output2); + } + assertFiltering(filter1, file, true); + assertFiltering(filter2, file, true); + + file = new File(getTestDirectory(), "test-file2.log"); + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(file)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + assertFiltering(filter1, file, true); + assertFiltering(filter2, file, false); + + file = new File(getTestDirectory(), "CVS"); + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(file)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + assertFiltering(filter1, file, true); + assertFiltering(filter2, file, false); + } + + @Test + public void testMakeSVNAware() throws Exception { + final IOFileFilter filter1 = FileFilterUtils.makeSVNAware(null); + final IOFileFilter filter2 = FileFilterUtils.makeSVNAware(FileFilterUtils + .nameFileFilter("test-file1.txt")); + + File file = new File(getTestDirectory(), SVN_DIR_NAME); + file.mkdirs(); + assertFiltering(filter1, file, false); + assertFiltering(filter2, file, false); + FileUtils.deleteDirectory(file); + + file = new File(getTestDirectory(), "test-file1.txt"); + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output2 = + new BufferedOutputStream(new FileOutputStream(file)); + try { + TestUtils.generateTestData(output2, (long) 0); + } finally { + IOUtils.closeQuietly(output2); + } + assertFiltering(filter1, file, true); + assertFiltering(filter2, file, true); + + file = new File(getTestDirectory(), "test-file2.log"); + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(file)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + assertFiltering(filter1, file, true); + assertFiltering(filter2, file, false); + + file = new File(getTestDirectory(), SVN_DIR_NAME); + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(file)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + assertFiltering(filter1, file, true); + assertFiltering(filter2, file, false); + } + + @Test + public void testAgeFilter() throws Exception { + final File oldFile = new File(getTestDirectory(), "old.txt"); + final File reference = new File(getTestDirectory(), "reference.txt"); + final File newFile = new File(getTestDirectory(), "new.txt"); + + if (!oldFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + oldFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(oldFile)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + + do { + try { + TestUtils.sleep(1000); + } catch(final InterruptedException ie) { + // ignore + } + if (!reference.getParentFile().exists()) { + throw new IOException("Cannot create file " + reference + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(reference)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + } while( oldFile.lastModified() == reference.lastModified() ); + + final Date date = new Date(); + final long now = date.getTime(); + + do { + try { + TestUtils.sleep(1000); + } catch(final InterruptedException ie) { + // ignore + } + if (!newFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + newFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(newFile)); + try { + TestUtils.generateTestData(output, (long) 0); + } finally { + IOUtils.closeQuietly(output); + } + } while( reference.lastModified() == newFile.lastModified() ); + + final IOFileFilter filter1 = FileFilterUtils.ageFileFilter(now); + final IOFileFilter filter2 = FileFilterUtils.ageFileFilter(now, true); + final IOFileFilter filter3 = FileFilterUtils.ageFileFilter(now, false); + final IOFileFilter filter4 = FileFilterUtils.ageFileFilter(date); + final IOFileFilter filter5 = FileFilterUtils.ageFileFilter(date, true); + final IOFileFilter filter6 = FileFilterUtils.ageFileFilter(date, false); + final IOFileFilter filter7 = FileFilterUtils.ageFileFilter(reference); + final IOFileFilter filter8 = FileFilterUtils.ageFileFilter(reference, true); + final IOFileFilter filter9 = FileFilterUtils.ageFileFilter(reference, false); + + assertFiltering(filter1, oldFile, true); + assertFiltering(filter2, oldFile, true); + assertFiltering(filter3, oldFile, false); + assertFiltering(filter4, oldFile, true); + assertFiltering(filter5, oldFile, true); + assertFiltering(filter6, oldFile, false); + assertFiltering(filter7, oldFile, true); + assertFiltering(filter8, oldFile, true); + assertFiltering(filter9, oldFile, false); + assertFiltering(filter1, newFile, false); + assertFiltering(filter2, newFile, false); + assertFiltering(filter3, newFile, true); + assertFiltering(filter4, newFile, false); + assertFiltering(filter5, newFile, false); + assertFiltering(filter6, newFile, true); + assertFiltering(filter7, newFile, false); + assertFiltering(filter8, newFile, false); + assertFiltering(filter9, newFile, true); + } + + @Test + public void testSizeFilter() throws Exception { + final File smallFile = new File(getTestDirectory(), "small.txt"); + if (!smallFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + smallFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(smallFile)); + try { + TestUtils.generateTestData(output1, (long) 32); + } finally { + IOUtils.closeQuietly(output1); + } + final File largeFile = new File(getTestDirectory(), "large.txt"); + if (!largeFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + largeFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(largeFile)); + try { + TestUtils.generateTestData(output, (long) 128); + } finally { + IOUtils.closeQuietly(output); + } + final IOFileFilter filter1 = FileFilterUtils.sizeFileFilter(64); + final IOFileFilter filter2 = FileFilterUtils.sizeFileFilter(64, true); + final IOFileFilter filter3 = FileFilterUtils.sizeFileFilter(64, false); + + assertFiltering(filter1, smallFile, false); + assertFiltering(filter2, smallFile, false); + assertFiltering(filter3, smallFile, true); + assertFiltering(filter1, largeFile, true); + assertFiltering(filter2, largeFile, true); + assertFiltering(filter3, largeFile, false); + + // size range tests + final IOFileFilter filter4 = FileFilterUtils.sizeRangeFileFilter(33, 127); + final IOFileFilter filter5 = FileFilterUtils.sizeRangeFileFilter(32, 127); + final IOFileFilter filter6 = FileFilterUtils.sizeRangeFileFilter(33, 128); + final IOFileFilter filter7 = FileFilterUtils.sizeRangeFileFilter(31, 129); + final IOFileFilter filter8 = FileFilterUtils.sizeRangeFileFilter(128, 128); + + assertFiltering(filter4, smallFile, false); + assertFiltering(filter4, largeFile, false); + assertFiltering(filter5, smallFile, true); + assertFiltering(filter5, largeFile, false); + assertFiltering(filter6, smallFile, false); + assertFiltering(filter6, largeFile, true); + assertFiltering(filter7, smallFile, true); + assertFiltering(filter7, largeFile, true); + assertFiltering(filter8, largeFile, true); + + try { + FileFilterUtils.sizeFileFilter(-1); + fail(); + } catch (final IllegalArgumentException ex) { + // expected + } + } + + @Test + public void testHidden() throws Exception { + final File hiddenDir = new File(SVN_DIR_NAME); + if (hiddenDir.exists()) { + assertFiltering(HiddenFileFilter.HIDDEN, hiddenDir, hiddenDir.isHidden()); + assertFiltering(HiddenFileFilter.VISIBLE, hiddenDir, !hiddenDir.isHidden()); + } + assertFiltering(HiddenFileFilter.HIDDEN, getTestDirectory(), false); + assertFiltering(HiddenFileFilter.VISIBLE, getTestDirectory(), true); + } + + @Test + public void testCanRead() throws Exception { + final File readOnlyFile = new File(getTestDirectory(), "read-only-file1.txt"); + if (!readOnlyFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + readOnlyFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(readOnlyFile)); + try { + TestUtils.generateTestData(output, (long) 32); + } finally { + IOUtils.closeQuietly(output); + } + readOnlyFile.setReadOnly(); + assertFiltering(CanReadFileFilter.CAN_READ, readOnlyFile, true); + assertFiltering(CanReadFileFilter.CANNOT_READ, readOnlyFile, false); + assertFiltering(CanReadFileFilter.READ_ONLY, readOnlyFile, true); + readOnlyFile.delete(); + } + + @Test + public void testCanWrite() throws Exception { + final File readOnlyFile = new File(getTestDirectory(), "read-only-file2.txt"); + if (!readOnlyFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + readOnlyFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(readOnlyFile)); + try { + TestUtils.generateTestData(output, (long) 32); + } finally { + IOUtils.closeQuietly(output); + } + readOnlyFile.setReadOnly(); + assertFiltering(CanWriteFileFilter.CAN_WRITE, getTestDirectory(), true); + assertFiltering(CanWriteFileFilter.CANNOT_WRITE, getTestDirectory(), false); + assertFiltering(CanWriteFileFilter.CAN_WRITE, readOnlyFile, false); + assertFiltering(CanWriteFileFilter.CANNOT_WRITE, readOnlyFile, true); + readOnlyFile.delete(); + } + + @Test + public void testEmpty() throws Exception { + + // Empty Dir + final File emptyDir = new File(getTestDirectory(), "empty-dir"); + emptyDir.mkdirs(); + assertFiltering(EmptyFileFilter.EMPTY, emptyDir, true); + assertFiltering(EmptyFileFilter.NOT_EMPTY, emptyDir, false); + + // Empty File + final File emptyFile = new File(emptyDir, "empty-file.txt"); + if (!emptyFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + emptyFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(emptyFile)); + try { + TestUtils.generateTestData(output1, (long) 0); + } finally { + IOUtils.closeQuietly(output1); + } + assertFiltering(EmptyFileFilter.EMPTY, emptyFile, true); + assertFiltering(EmptyFileFilter.NOT_EMPTY, emptyFile, false); + + // Not Empty Dir + assertFiltering(EmptyFileFilter.EMPTY, emptyDir, false); + assertFiltering(EmptyFileFilter.NOT_EMPTY, emptyDir, true); + + // Not Empty File + final File notEmptyFile = new File(emptyDir, "not-empty-file.txt"); + if (!notEmptyFile.getParentFile().exists()) { + throw new IOException("Cannot create file " + notEmptyFile + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(notEmptyFile)); + try { + TestUtils.generateTestData(output, (long) 32); + } finally { + IOUtils.closeQuietly(output); + } + assertFiltering(EmptyFileFilter.EMPTY, notEmptyFile, false); + assertFiltering(EmptyFileFilter.NOT_EMPTY, notEmptyFile, true); + FileUtils.forceDelete(emptyDir); + } + + //----------------------------------------------------------------------- + @Test + public void testMakeDirectoryOnly() throws Exception { + assertSame(DirectoryFileFilter.DIRECTORY, FileFilterUtils.makeDirectoryOnly(null)); + + final IOFileFilter filter = FileFilterUtils.makeDirectoryOnly( + FileFilterUtils.nameFileFilter("B")); + + final File fileA = new File(getTestDirectory(), "A"); + final File fileB = new File(getTestDirectory(), "B"); + + fileA.mkdirs(); + fileB.mkdirs(); + + assertFiltering(filter, fileA, false); + assertFiltering(filter, fileB, true); + + FileUtils.deleteDirectory(fileA); + FileUtils.deleteDirectory(fileB); + + if (!fileA.getParentFile().exists()) { + throw new IOException("Cannot create file " + fileA + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(fileA)); + try { + TestUtils.generateTestData(output1, (long) 32); + } finally { + IOUtils.closeQuietly(output1); + } + if (!fileB.getParentFile().exists()) { + throw new IOException("Cannot create file " + fileB + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(fileB)); + try { + TestUtils.generateTestData(output, (long) 32); + } finally { + IOUtils.closeQuietly(output); + } + + assertFiltering(filter, fileA, false); + assertFiltering(filter, fileB, false); + + fileA.delete(); + fileB.delete(); + } + + //----------------------------------------------------------------------- + @Test + public void testMakeFileOnly() throws Exception { + assertSame(FileFileFilter.FILE, FileFilterUtils.makeFileOnly(null)); + + final IOFileFilter filter = FileFilterUtils.makeFileOnly( + FileFilterUtils.nameFileFilter("B")); + + final File fileA = new File(getTestDirectory(), "A"); + final File fileB = new File(getTestDirectory(), "B"); + + fileA.mkdirs(); + fileB.mkdirs(); + + assertFiltering(filter, fileA, false); + assertFiltering(filter, fileB, false); + + FileUtils.deleteDirectory(fileA); + FileUtils.deleteDirectory(fileB); + + if (!fileA.getParentFile().exists()) { + throw new IOException("Cannot create file " + fileA + + " as the parent directory does not exist"); + } + final BufferedOutputStream output1 = + new BufferedOutputStream(new FileOutputStream(fileA)); + try { + TestUtils.generateTestData(output1, (long) 32); + } finally { + IOUtils.closeQuietly(output1); + } + if (!fileB.getParentFile().exists()) { + throw new IOException("Cannot create file " + fileB + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(fileB)); + try { + TestUtils.generateTestData(output, (long) 32); + } finally { + IOUtils.closeQuietly(output); + } + + assertFiltering(filter, fileA, false); + assertFiltering(filter, fileB, true); + + fileA.delete(); + fileB.delete(); + } + + //----------------------------------------------------------------------- + + @SuppressWarnings("deprecation") // unavoidable until Java 7 + @Test + public void testMagicNumberFileFilterBytes() throws Exception { + final byte[] classFileMagicNumber = + new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE}; + final String xmlFileContent = "\n" + + "text"; + + final File classFileA = new File(getTestDirectory(), "A.class"); + final File xmlFileB = new File(getTestDirectory(), "B.xml"); + final File emptyFile = new File(getTestDirectory(), "C.xml"); + final File dir = new File(getTestDirectory(), "D"); + dir.mkdirs(); + + final OutputStream classFileAStream = FileUtils.openOutputStream(classFileA); + IOUtils.write(classFileMagicNumber, classFileAStream); + TestUtils.generateTestData(classFileAStream, (long) 32); + classFileAStream.close(); + + FileUtils.write(xmlFileB, xmlFileContent, Charsets.UTF_8); + FileUtils.touch(emptyFile); + + IOFileFilter filter = new MagicNumberFileFilter(classFileMagicNumber); + + assertFiltering(filter, classFileA, true); + assertFiltering(filter, xmlFileB, false); + assertFiltering(filter, emptyFile, false); + assertFiltering(filter, dir, false); + + + filter = FileFilterUtils.magicNumberFileFilter(classFileMagicNumber); + + assertFiltering(filter, classFileA, true); + assertFiltering(filter, xmlFileB, false); + assertFiltering(filter, emptyFile, false); + assertFiltering(filter, dir, false); + } + + @Test + public void testMagicNumberFileFilterBytesOffset() throws Exception { + final byte[] tarMagicNumber = new byte[] {0x75, 0x73, 0x74, 0x61, 0x72}; + final long tarMagicNumberOffset = 257; + + final File tarFileA = new File(getTestDirectory(), "A.tar"); + final File randomFileB = new File(getTestDirectory(), "B.txt"); + final File dir = new File(getTestDirectory(), "D"); + dir.mkdirs(); + + final OutputStream tarFileAStream = FileUtils.openOutputStream(tarFileA); + TestUtils.generateTestData(tarFileAStream, tarMagicNumberOffset); + IOUtils.write(tarMagicNumber, tarFileAStream); + tarFileAStream.close(); + + if (!randomFileB.getParentFile().exists()) { + throw new IOException("Cannot create file " + randomFileB + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(randomFileB)); + try { + TestUtils.generateTestData(output, 2 * tarMagicNumberOffset); + } finally { + IOUtils.closeQuietly(output); + } + + IOFileFilter filter = + new MagicNumberFileFilter(tarMagicNumber, tarMagicNumberOffset); + + assertFiltering(filter, tarFileA, true); + assertFiltering(filter, randomFileB, false); + assertFiltering(filter, dir, false); + + filter = FileFilterUtils.magicNumberFileFilter(tarMagicNumber, + tarMagicNumberOffset); + + assertFiltering(filter, tarFileA, true); + assertFiltering(filter, randomFileB, false); + assertFiltering(filter, dir, false); + } + + @SuppressWarnings("deprecation") // unavoidable until Java 7 + @Test + public void testMagicNumberFileFilterString() throws Exception { + final byte[] classFileMagicNumber = + new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE}; + final String xmlFileContent = "\n" + + "text"; + final String xmlMagicNumber = " fileList = Arrays.asList(fileA, fileB); + + final IOFileFilter filter = FileFilterUtils.nameFileFilter("A"); + + final File[] filtered = FileFilterUtils.filter(filter, fileList); + + assertEquals(1, filtered.length); + assertEquals(fileA, filtered[0]); + } + + /* + * Test method for {@link FileFilterUtils#filter(IOFileFilter, File...)} + * that tests {@code null} parameters and {@code null} elements + * in the provided list. + */ + @Test + public void testFilterArrayNullParameters() throws Exception { + final File fileA = TestUtils.newFile(getTestDirectory(), "A"); + final File fileB = TestUtils.newFile(getTestDirectory(), "B"); + try { + FileFilterUtils.filter(null, fileA, fileB); + fail(); + } catch (final IllegalArgumentException iae) { + // Test passes, exception thrown for null filter + } + + final IOFileFilter filter = FileFilterUtils.trueFileFilter(); + try { + FileFilterUtils.filter(filter, fileA, null); + fail(); + } catch (final IllegalArgumentException iae) { + // Test passes, exception thrown for list containing null + } + + final File[] filtered = FileFilterUtils.filter(filter, (File[])null); + assertEquals(0, filtered.length); + } + + /* + * Test method for {@link FileFilterUtils#filterList(IOFileFilter, java.lang.Iterable)} + * that tests that the method properly filters files from the list. + */ + @Test + public void testFilterList() throws Exception { + final File fileA = TestUtils.newFile(getTestDirectory(), "A"); + final File fileB = TestUtils.newFile(getTestDirectory(), "B"); + final List fileList = Arrays.asList(fileA, fileB); + + final IOFileFilter filter = FileFilterUtils.nameFileFilter("A"); + + final List filteredList = FileFilterUtils.filterList(filter, fileList); + + assertTrue(filteredList.contains(fileA)); + assertFalse(filteredList.contains(fileB)); + } + + /* + * Test method for {@link FileFilterUtils#filterList(IOFileFilter, File...)} + * that tests that the method properly filters files from the list. + */ + @Test + public void testFilterList_fromArray() throws Exception { + final File fileA = TestUtils.newFile(getTestDirectory(), "A"); + final File fileB = TestUtils.newFile(getTestDirectory(), "B"); + + final IOFileFilter filter = FileFilterUtils.nameFileFilter("A"); + + final List filteredList = FileFilterUtils.filterList(filter, fileA, fileB); + + assertTrue(filteredList.contains(fileA)); + assertFalse(filteredList.contains(fileB)); + } + + /* + * Test method for {@link FileFilterUtils#filterList(IOFileFilter, java.lang.Iterable)} + * that tests {@code null} parameters and {@code null} elements + * in the provided list. + */ + @Test + public void testFilterListNullParameters() { + try { + FileFilterUtils.filterList(null, Collections.emptyList()); + fail(); + } catch (final IllegalArgumentException iae) { + // Test passes, exception thrown for null filter + } + + final IOFileFilter filter = FileFilterUtils.trueFileFilter(); + try { + FileFilterUtils.filterList(filter, Arrays.asList((File) null)); + fail(); + } catch (final IllegalArgumentException iae) { + // Test passes, exception thrown for list containing null + } + + final List filteredList = FileFilterUtils.filterList(filter, (List)null); + assertEquals(0, filteredList.size()); + } + + /* + * Test method for {@link FileFilterUtils#filterSet(IOFileFilter, java.lang.Iterable)} + * that tests that the method properly filters files from the set. + */ + @Test + public void testFilterSet() throws Exception { + final File fileA = TestUtils.newFile(getTestDirectory(), "A"); + final File fileB = TestUtils.newFile(getTestDirectory(), "B"); + final Set fileList = new HashSet(Arrays.asList(fileA, fileB)); + + final IOFileFilter filter = FileFilterUtils.nameFileFilter("A"); + + final Set filteredSet = FileFilterUtils.filterSet(filter, fileList); + + assertTrue(filteredSet.contains(fileA)); + assertFalse(filteredSet.contains(fileB)); + } + + /* + * Test method for {@link FileFilterUtils#filterSet(IOFileFilter, File...)} + * that tests that the method properly filters files from the set. + */ + @Test + public void testFilterSet_fromArray() throws Exception { + final File fileA = TestUtils.newFile(getTestDirectory(), "A"); + final File fileB = TestUtils.newFile(getTestDirectory(), "B"); + + final IOFileFilter filter = FileFilterUtils.nameFileFilter("A"); + + final Set filteredSet = FileFilterUtils.filterSet(filter, fileA, fileB); + + assertTrue(filteredSet.contains(fileA)); + assertFalse(filteredSet.contains(fileB)); + } + + /* + * Test method for {@link FileFilterUtils#filterSet(IOFileFilter, java.lang.Iterable)} + * that tests {@code null} parameters and {@code null} elements + * in the provided set. + */ + @Test + public void testFilterSetNullParameters() { + try { + FileFilterUtils.filterSet(null, Collections.emptySet()); + fail(); + } catch (final IllegalArgumentException iae) { + // Test passes, exception thrown for null filter + } + + final IOFileFilter filter = FileFilterUtils.trueFileFilter(); + try { + FileFilterUtils.filterSet(filter, new HashSet(Arrays.asList((File) null))); + fail(); + } catch (final IllegalArgumentException iae) { + // Test passes, exception thrown for set containing null + } + + final Set filteredSet = FileFilterUtils.filterSet(filter, (Set)null); + assertEquals(0, filteredSet.size()); + } + + @Test + public void testEnsureTestCoverage() { + assertNotNull(new FileFilterUtils()); // dummy for test coverage + } + + @Test + public void testNullFilters() { + try { + FileFilterUtils.toList((IOFileFilter) null); + fail("Expected IllegalArgumentException"); + } catch (final IllegalArgumentException ignore) { + // expected + } + try { + FileFilterUtils.toList(new IOFileFilter[]{null}); + fail("Expected IllegalArgumentException"); + } catch (final IllegalArgumentException ignore) { + // expected + } + } + + @Test + public void testDelegation() { // TODO improve these tests + assertNotNull(FileFilterUtils.asFileFilter((FileFilter) FalseFileFilter.INSTANCE)); + assertNotNull(FileFilterUtils.asFileFilter((FilenameFilter) FalseFileFilter.INSTANCE).toString()); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/IOFileFilterAbstractTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/IOFileFilterAbstractTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..042ff20475d42da468255c0c960440176b9b9cda --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/IOFileFilterAbstractTestCase.java" @@ -0,0 +1,154 @@ +/* + * 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 junit.framework.TestCase; + +import static org.junit.Assert.assertEquals; + +public abstract class IOFileFilterAbstractTestCase { + + public static void assertFileFiltering(final int testNumber, final IOFileFilter filter, final File file, final boolean expected) + throws Exception { + assertEquals( + "test " + testNumber + " Filter(File) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file)); + } + + public static void assertFilenameFiltering(final int testNumber, final IOFileFilter filter, final File file, final boolean expected) + throws Exception { + // Assumes file has parent and is not passed as null + assertEquals( + "test " + testNumber + " Filter(File, String) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file.getParentFile(), file.getName())); + } + + public static void assertFiltering(final int testNumber, final IOFileFilter filter, final File file, final boolean expected) + throws Exception { + // Note. This only tests the (File, String) version if the parent of + // the File passed in is not null + assertEquals( + "test " + testNumber + " Filter(File) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file)); + + if (file != null && file.getParentFile() != null) { + assertEquals( + "test " + testNumber + " Filter(File, String) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file.getParentFile(), file.getName())); + } else if (file == null) { + assertEquals( + "test " + testNumber + " Filter(File, String) " + filter.getClass().getName() + " not " + expected + " for null", + expected, filter.accept(file)); + } + } + + public static void assertTrueFiltersInvoked(final int testNumber, final TesterTrueFileFilter[] filters, final boolean[] invoked) { + for (int i = 1; i < filters.length; i++) { + assertEquals("test " + testNumber + " filter " + i + " invoked", invoked[i - 1], filters[i].isInvoked()); + } + } + + public static void assertFalseFiltersInvoked(final int testNumber, final TesterFalseFileFilter[] filters, final boolean[] invoked) { + for (int i = 1; i < filters.length; i++) { + assertEquals("test " + testNumber + " filter " + i + " invoked", invoked[i - 1], filters[i].isInvoked()); + } + } + + public static File determineWorkingDirectoryPath(final String key, final String defaultPath) { + // Look for a system property to specify the working directory + final String workingPathName = System.getProperty(key, defaultPath); + return new File(workingPathName); + } + + public static void resetFalseFilters(final TesterFalseFileFilter[] filters) { + for (final TesterFalseFileFilter filter : filters) { + if (filter != null) { + filter.reset(); + } + } + } + + public static void resetTrueFilters(final TesterTrueFileFilter[] filters) { + for (final TesterTrueFileFilter filter : filters) { + if (filter != null) { + filter.reset(); + } + } + } + + class TesterTrueFileFilter extends TrueFileFilter { + + private static final long serialVersionUID = 1828930358172422914L; + private boolean invoked; + + @Override + public boolean accept(final File file) { + setInvoked(true); + return super.accept(file); + } + + @Override + public boolean accept(final File file, final String str) { + setInvoked(true); + return super.accept(file, str); + } + + public boolean isInvoked() { + return this.invoked; + } + + public void setInvoked(final boolean invoked) { + this.invoked = invoked; + } + + public void reset() { + setInvoked(false); + } + } + + class TesterFalseFileFilter extends FalseFileFilter { + + private static final long serialVersionUID = -3603047664010401872L; + private boolean invoked; + + @Override + public boolean accept(final File file) { + setInvoked(true); + return super.accept(file); + } + + @Override + public boolean accept(final File file, final String str) { + setInvoked(true); + return super.accept(file, str); + } + + public boolean isInvoked() { + return this.invoked; + } + + public void setInvoked(final boolean invoked) { + this.invoked = invoked; + } + + public void reset() { + setInvoked(false); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..7ea5bcd7e17534f2215ecaa592c414b6bdc42f5c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/OrFileFilterTestCase.java" @@ -0,0 +1,294 @@ +/* + * 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 org.junit.Before; + +import java.util.ArrayList; +import java.util.List; + +public class OrFileFilterTestCase extends ConditionalFileFilterAbstractTestCase { + + private static final String DEFAULT_WORKING_PATH = "./OrFileFilterTestCase/"; + private static final String WORKING_PATH_NAME_PROPERTY_KEY = OrFileFilterTestCase.class.getName() + ".workingDirectory"; + + private List> testFilters; + private List testTrueResults; + private List testFalseResults; + private List testFileResults; + private List testFilenameResults; + + @Override + protected IOFileFilter buildFilterUsingAdd(final List filters) { + final OrFileFilter filter = new OrFileFilter(); + for (IOFileFilter filter1 : filters) { + filter.addFileFilter(filter1); + } + return filter; + } + + @Override + protected IOFileFilter buildFilterUsingConstructor(final List filters) { + return new OrFileFilter(filters); + } + + @Override + protected ConditionalFileFilter getConditionalFileFilter() { + return new OrFileFilter(); + } + + @Override + protected String getDefaultWorkingPath() { + return DEFAULT_WORKING_PATH; + } + + @Override + protected List getFalseResults() { + return this.testFalseResults; + } + + @Override + protected List getFileResults() { + return this.testFileResults; + } + + @Override + protected List getFilenameResults() { + return this.testFilenameResults; + } + + @Override + protected List> getTestFilters() { + return this.testFilters; + } + + @Override + protected List getTrueResults() { + return this.testTrueResults; + } + + @Override + protected String getWorkingPathNamePropertyKey() { + return WORKING_PATH_NAME_PROPERTY_KEY; + } + + @Before + public void setUpTestFilters() { + // filters + //tests + this.testFilters = new ArrayList>(); + this.testTrueResults = new ArrayList(); + this.testFalseResults = new ArrayList(); + this.testFileResults = new ArrayList(); + this.testFilenameResults = new ArrayList(); + + // test 0 - add empty elements + { + testFilters.add(0, null); + testTrueResults.add(0, null); + testFalseResults.add(0, null); + testFileResults.add(0, null); + testFilenameResults.add(0, null); + } + + // test 1 - Test conditional or with all filters returning true + { + // test 1 filters + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + // test 1 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 1 false results + final boolean[] falseResults = new boolean[] {false, false, false}; + + testFilters.add(1, filters); + testTrueResults.add(1, trueResults); + testFalseResults.add(1, falseResults); + testFileResults.add(1, Boolean.TRUE); + testFilenameResults.add(1, Boolean.TRUE); + } + + // test 2 - Test conditional or with first filter returning false + { + // test 2 filters + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 2 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 2 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(2, filters); + testTrueResults.add(2, trueResults); + testFalseResults.add(2, falseResults); + testFileResults.add(2, Boolean.TRUE); + testFilenameResults.add(2, Boolean.TRUE); + } + + // test 3 - Test conditional or with second filter returning false + { + // test 3 filters + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(falseFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 3 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 3 false results + final boolean[] falseResults = new boolean[] {false, false, false}; + + testFilters.add(3, filters); + testTrueResults.add(3, trueResults); + testFalseResults.add(3, falseResults); + testFileResults.add(3, Boolean.TRUE); + testFilenameResults.add(3, Boolean.TRUE); + } + + // test 4 - Test conditional or with third filter returning false + { + // test 4 filters + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(falseFilters[1]); + filters.add(trueFilters[3]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 4 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 4 false results + final boolean[] falseResults = new boolean[] {false, false, false}; + + testFilters.add(4, filters); + testTrueResults.add(4, trueResults); + testFalseResults.add(4, falseResults); + testFileResults.add(4, Boolean.TRUE); + testFilenameResults.add(4, Boolean.TRUE); + } + + // test 5 - Test conditional or with first and third filters returning false + { + // test 5 filters + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(trueFilters[1]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + // test 5 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 5 false results + final boolean[] falseResults = new boolean[] {true, false, false}; + + testFilters.add(5, filters); + testTrueResults.add(5, trueResults); + testFalseResults.add(5, falseResults); + testFileResults.add(5, Boolean.TRUE); + testFilenameResults.add(5, Boolean.TRUE); + } + + // test 6 - Test conditional or with second and third filters returning false + { + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(falseFilters[1]); + filters.add(falseFilters[2]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[3]); + // test 6 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 6 false results + final boolean[] falseResults = new boolean[] {false, false, false}; + + testFilters.add(6, filters); + testTrueResults.add(6, trueResults); + testFalseResults.add(6, falseResults); + testFileResults.add(6, Boolean.TRUE); + testFilenameResults.add(6, Boolean.TRUE); + } + + // test 7 - Test conditional or with first and second filters returning false + { + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(falseFilters[2]); + filters.add(trueFilters[1]); + filters.add(falseFilters[3]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + // test 7 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 7 false results + final boolean[] falseResults = new boolean[] {true, true, false}; + + testFilters.add(7, filters); + testTrueResults.add(7, trueResults); + testFalseResults.add(7, falseResults); + testFileResults.add(7, Boolean.TRUE); + testFilenameResults.add(7, Boolean.TRUE); + } + + // test 8 - Test conditional or with fourth filter returning false + { + final List filters = new ArrayList(); + filters.add(trueFilters[1]); + filters.add(trueFilters[2]); + filters.add(trueFilters[3]); + filters.add(falseFilters[1]); + // test 8 true results + final boolean[] trueResults = new boolean[] {true, false, false}; + // test 8 false results + final boolean[] falseResults = new boolean[] {false, false, false}; + + testFilters.add(8, filters); + testTrueResults.add(8, trueResults); + testFalseResults.add(8, falseResults); + testFileResults.add(8, Boolean.TRUE); + testFilenameResults.add(8, Boolean.TRUE); + } + + // test 9 - Test conditional or with all filters returning false + { + final List filters = new ArrayList(); + filters.add(falseFilters[1]); + filters.add(falseFilters[2]); + filters.add(falseFilters[3]); + // test 9 true results + final boolean[] trueResults = new boolean[] {false, false, false}; + // test 9 false results + final boolean[] falseResults = new boolean[] {true, true, true}; + + testFilters.add(9, filters); + testTrueResults.add(9, trueResults); + testFalseResults.add(9, falseResults); + testFileResults.add(9, Boolean.FALSE); + testFilenameResults.add(9, Boolean.FALSE); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..25381dc5b7d0bae40c3f602de8eac28df23504d0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/filefilter/RegexFileFilterTestCase.java" @@ -0,0 +1,121 @@ +/* + * 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.util.regex.Pattern; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOCase; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * Used to test RegexFileFilterUtils. + */ +public class RegexFileFilterTestCase extends FileBasedTestCase { + + @Before + public void setUp() { + getTestDirectory().mkdirs(); + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(getTestDirectory()); + } + + public void assertFiltering(final IOFileFilter filter, final File file, final boolean expected) throws Exception { + // Note. This only tests the (File, String) version if the parent of + // the File passed in is not null + assertEquals( + "Filter(File) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file)); + + if (file != null && file.getParentFile() != null) { + assertEquals( + "Filter(File, String) " + filter.getClass().getName() + " not " + expected + " for " + file, + expected, filter.accept(file.getParentFile(), file.getName())); + } else if (file == null) { + assertEquals( + "Filter(File, String) " + filter.getClass().getName() + " not " + expected + " for null", + expected, filter.accept(file)); + } + } + + @Test + public void testRegex() throws Exception { + IOFileFilter filter = new RegexFileFilter("^.*[tT]est(-\\d+)?\\.java$"); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("test-10.java"), true); + assertFiltering(filter, new File("test-.java"), false); + + filter = new RegexFileFilter("^[Tt]est.java$"); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("test.java"), true); + assertFiltering(filter, new File("tEST.java"), false); + + filter = new RegexFileFilter(Pattern.compile("^test.java$", Pattern.CASE_INSENSITIVE)); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("test.java"), true); + assertFiltering(filter, new File("tEST.java"), true); + + filter = new RegexFileFilter("^test.java$", Pattern.CASE_INSENSITIVE); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("test.java"), true); + assertFiltering(filter, new File("tEST.java"), true); + + filter = new RegexFileFilter("^test.java$", IOCase.INSENSITIVE); + assertFiltering(filter, new File("Test.java"), true); + assertFiltering(filter, new File("test.java"), true); + assertFiltering(filter, new File("tEST.java"), true); + + try { + new RegexFileFilter((String)null); + fail(); + } catch (final IllegalArgumentException ignore) { + // expected + } + + try { + new RegexFileFilter(null, Pattern.CASE_INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + // expected + } + + try { + new RegexFileFilter(null, IOCase.INSENSITIVE); + fail(); + } catch (final IllegalArgumentException ignore) { + // expected + } + + try { + new RegexFileFilter((java.util.regex.Pattern)null); + fail(); + } catch (final IllegalArgumentException ignore) { + // expected + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..935c8862c16fc28cbe0279d233397e0d50c61a4b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java" @@ -0,0 +1,103 @@ +/* + * 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.input; + +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * JUnit Test Case for {@link AutoCloseInputStream}. + */ +public class AutoCloseInputStreamTest { + + private byte[] data; + + private InputStream stream; + + private boolean closed; + + @Before + public void setUp() { + data = new byte[] { 'x', 'y', 'z' }; + stream = new AutoCloseInputStream(new ByteArrayInputStream(data) { + @Override + public void close() { + closed = true; + } + }); + closed = false; + } + + @Test + public void testClose() throws IOException { + stream.close(); + assertTrue("closed", closed); + assertEquals("read()", -1, stream.read()); + } + + + @Test + public void testRead() throws IOException { + for (final byte element : data) { + assertEquals("read()", element, stream.read()); + assertFalse("closed", closed); + } + assertEquals("read()", -1, stream.read()); + assertTrue("closed", closed); + } + + @Test + public void testReadBuffer() throws IOException { + final byte[] b = new byte[data.length * 2]; + int total = 0; + for (int n = 0; n != -1; n = stream.read(b)) { + assertFalse("closed", closed); + for (int i = 0; i < n; i++) { + assertEquals("read(b)", data[total + i], b[i]); + } + total += n; + } + assertEquals("read(b)", data.length, total); + assertTrue("closed", closed); + assertEquals("read(b)", -1, stream.read(b)); + } + + @Test + public void testReadBufferOffsetLength() throws IOException { + final byte[] b = new byte[data.length * 2]; + int total = 0; + for (int n = 0; n != -1; n = stream.read(b, total, b.length - total)) { + assertFalse("closed", closed); + total += n; + } + assertEquals("read(b, off, len)", data.length, total); + for (int i = 0; i < data.length; i++) { + assertEquals("read(b, off, len)", data[i], b[i]); + } + assertTrue("closed", closed); + assertEquals("read(b, off, len)", -1, stream.read(b, 0, b.length)); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..b187a69ae5622814d2a2c776c21ff21963f6efdb --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java" @@ -0,0 +1,773 @@ +/* + * 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.input; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.nio.charset.Charset; + +import org.apache.commons.io.ByteOrderMark; +import org.apache.commons.io.Charsets; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +/** + * Test case for {@link BOMInputStream}. + * + * @version $Id: BOMInputStreamTest.java 1721094 2015-12-21 05:51:18Z krosenvold $ + */ +@SuppressWarnings("ResultOfMethodCallIgnored") +public class BOMInputStreamTest { + //---------------------------------------------------------------------------- + // Support code + //---------------------------------------------------------------------------- + + /** + * A mock InputStream that expects close() to be called. + */ + private static class ExpectCloseInputStream extends InputStream { + private boolean _closeCalled; + + public void assertCloseCalled() { + assertTrue(_closeCalled); + } + + @Override + public void close() throws IOException { + _closeCalled = true; + } + + @Override + public int read() throws IOException { + return -1; + } + } + + private void assertData(final byte[] expected, final byte[] actual, final int len) + throws Exception { + assertEquals("length", expected.length, len); + for (int ii = 0; ii < expected.length; ii++) { + assertEquals("byte " + ii, expected[ii], actual[ii]); + } + } + + /** + * Creates the underlying data stream, with or without BOM. + */ + private InputStream createUtf16BeDataStream(final byte[] baseData, final boolean addBOM) { + byte[] data = baseData; + if (addBOM) { + data = new byte[baseData.length + 2]; + data[0] = (byte) 0xFE; + data[1] = (byte) 0xFF; + System.arraycopy(baseData, 0, data, 2, baseData.length); + } + return new ByteArrayInputStream(data); + } + + /** + * Creates the underlying data stream, with or without BOM. + */ + private InputStream createUtf16LeDataStream(final byte[] baseData, final boolean addBOM) { + byte[] data = baseData; + if (addBOM) { + data = new byte[baseData.length + 2]; + data[0] = (byte) 0xFF; + data[1] = (byte) 0xFE; + System.arraycopy(baseData, 0, data, 2, baseData.length); + } + return new ByteArrayInputStream(data); + } + + /** + * Creates the underlying data stream, with or without BOM. + */ + private InputStream createUtf32BeDataStream(final byte[] baseData, final boolean addBOM) { + byte[] data = baseData; + if (addBOM) { + data = new byte[baseData.length + 4]; + data[0] = 0; + data[1] = 0; + data[2] = (byte) 0xFE; + data[3] = (byte) 0xFF; + System.arraycopy(baseData, 0, data, 4, baseData.length); + } + return new ByteArrayInputStream(data); + } + + /** + * Creates the underlying data stream, with or without BOM. + */ + private InputStream createUtf32LeDataStream(final byte[] baseData, final boolean addBOM) { + byte[] data = baseData; + if (addBOM) { + data = new byte[baseData.length + 4]; + data[0] = (byte) 0xFF; + data[1] = (byte) 0xFE; + data[2] = 0; + data[3] = 0; + System.arraycopy(baseData, 0, data, 4, baseData.length); + } + return new ByteArrayInputStream(data); + } + + /** + * Creates the underlying data stream, with or without BOM. + */ + private InputStream createUtf8DataStream(final byte[] baseData, final boolean addBOM) { + byte[] data = baseData; + if (addBOM) { + data = new byte[baseData.length + 3]; + data[0] = (byte) 0xEF; + data[1] = (byte) 0xBB; + data[2] = (byte) 0xBF; + System.arraycopy(baseData, 0, data, 3, baseData.length); + } + return new ByteArrayInputStream(data); + } + + //---------------------------------------------------------------------------- + // Test cases + //---------------------------------------------------------------------------- + + private void parseXml(final InputStream in) throws SAXException, IOException, ParserConfigurationException { + final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(in)); + assertNotNull(doc); + assertEquals("X", doc.getFirstChild().getNodeName()); + } + + private void parseXml(final Reader in) throws SAXException, IOException, ParserConfigurationException { + final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(in)); + assertNotNull(doc); + assertEquals("X", doc.getFirstChild().getNodeName()); + } + + private void readBOMInputStreamTwice(final String resource) throws Exception { + final InputStream inputStream = this.getClass().getResourceAsStream(resource); + Assert.assertNotNull(inputStream); + final BOMInputStream bomInputStream = new BOMInputStream(inputStream); + bomInputStream.mark(1000000); + + this.readFile(bomInputStream); + bomInputStream.reset(); + this.readFile(bomInputStream); + inputStream.close(); + bomInputStream.close(); + } + + private void readFile(final BOMInputStream bomInputStream) throws Exception { + int bytes; + final byte[] bytesFromStream = new byte[100]; + do { + bytes = bomInputStream.read(bytesFromStream); + } while (bytes > 0); + } + + @Test + public void testAvailableWithBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + assertEquals(7, in.available()); + in.close(); + } + + @Test + public void testAvailableWithoutBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + assertEquals(4, in.available()); + in.close(); + } + + @Test + // this is here for coverage + public void testClose() throws Exception { + final ExpectCloseInputStream del = new ExpectCloseInputStream(); + final InputStream in = new BOMInputStream(del); + + in.close(); + del.assertCloseCalled(); + del.close(); + } + + @Test + public void testEmptyBufferWithBOM() throws Exception { + final byte[] data = new byte[] {}; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + final byte[] buf = new byte[1024]; + assertEquals(-1, in.read(buf)); + in.close(); + } + + @Test + public void testEmptyBufferWithoutBOM() throws Exception { + final byte[] data = new byte[] {}; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + final byte[] buf = new byte[1024]; + assertEquals(-1, in.read(buf)); + in.close(); + } + + @Test + public void testGetBOMFirstThenRead() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + assertEquals("getBOM", ByteOrderMark.UTF_8, in.getBOM()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertEquals('A', in.read()); + assertEquals('B', in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + in.close(); + } + + @Test + public void testGetBOMFirstThenReadInclude() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), true); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertEquals("getBOM", ByteOrderMark.UTF_8, in.getBOM()); + assertEquals(0xEF, in.read()); + assertEquals(0xBB, in.read()); + assertEquals(0xBF, in.read()); + assertEquals('A', in.read()); + assertEquals('B', in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + in.close(); + } + + @Test + public void testLargeBufferWithBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + final byte[] buf = new byte[1024]; + assertData(data, buf, in.read(buf)); + in.close(); + } + + @Test + public void testLargeBufferWithoutBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + final byte[] buf = new byte[1024]; + assertData(data, buf, in.read(buf)); + in.close(); + } + + @Test + public void testLeadingNonBOMBufferedRead() throws Exception { + final byte[] data = new byte[] { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + final byte[] buf = new byte[1024]; + assertData(data, buf, in.read(buf)); + in.close(); + } + + @Test + public void testLeadingNonBOMSingleRead() throws Exception { + final byte[] data = new byte[] { (byte) 0xEF, (byte) 0xAB, (byte) 0xCD }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + assertEquals(0xEF, in.read()); + assertEquals(0xAB, in.read()); + assertEquals(0xCD, in.read()); + assertEquals(-1, in.read()); + in.close(); + } + + @Test + public void testMarkResetAfterReadWithBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + assertTrue(in.markSupported()); + + in.read(); + in.mark(10); + + in.read(); + in.read(); + in.reset(); + assertEquals('B', in.read()); + in.close(); + } + + @Test + public void testMarkResetAfterReadWithoutBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + assertTrue(in.markSupported()); + + in.read(); + in.mark(10); + + in.read(); + in.read(); + in.reset(); + assertEquals('B', in.read()); + in.close(); + } + + @Test + public void testMarkResetBeforeReadWithBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + assertTrue(in.markSupported()); + + in.mark(10); + + in.read(); + in.read(); + in.reset(); + assertEquals('A', in.read()); + in.close(); + } + + @Test + public void testMarkResetBeforeReadWithoutBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + assertTrue(in.markSupported()); + + in.mark(10); + + in.read(); + in.read(); + in.reset(); + assertEquals('A', in.read()); + in.close(); + } + + @Test + public void testNoBoms() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + try { + (new BOMInputStream(createUtf8DataStream(data, true), false, (ByteOrderMark[])null)).close(); + fail("Null BOMs, expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected + } + try { + (new BOMInputStream(createUtf8DataStream(data, true), false, new ByteOrderMark[0])).close(); + fail("Null BOMs, expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected + } + } + + + + + + @Test + public void testReadEmpty() throws Exception { + final byte[] data = new byte[] {}; + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + assertEquals(-1, in.read()); + assertFalse("hasBOM()", in.hasBOM()); + assertFalse("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertNull("getBOM", in.getBOM()); + in.close(); + } + + @Test + public void testReadSmall() throws Exception { + final byte[] data = new byte[] { 'A', 'B' }; + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + assertEquals('A', in.read()); + assertEquals('B', in.read()); + assertEquals(-1, in.read()); + assertFalse("hasBOM()", in.hasBOM()); + assertFalse("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertNull("getBOM", in.getBOM()); + in.close(); + } + + @Test + public void testReadTwiceWithBOM() throws Exception { + this.readBOMInputStreamTwice("/org/apache/commons/io/testfileBOM.xml"); + } + + @Test + public void testReadTwiceWithoutBOM() throws Exception { + this.readBOMInputStreamTwice("/org/apache/commons/io/testfileNoBOM.xml"); + } + + @Test + public void testReadWithBOMInclude() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), true); + assertEquals(0xEF, in.read()); + assertEquals(0xBB, in.read()); + assertEquals(0xBF, in.read()); + assertEquals('A', in.read()); + assertEquals('B', in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertEquals("getBOM", ByteOrderMark.UTF_8, in.getBOM()); + in.close(); + } + + @Test + public void testReadWithBOMUtf16Be() throws Exception { + @SuppressWarnings("deprecation") // unavoidable until Java 7 + final byte[] data = "ABC".getBytes(Charsets.UTF_16BE); + final BOMInputStream in = new BOMInputStream(createUtf16BeDataStream(data, true), ByteOrderMark.UTF_16BE); + assertEquals(0, in.read()); + assertEquals('A', in.read()); + assertEquals(0, in.read()); + assertEquals('B', in.read()); + assertEquals(0, in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-16BE)", in.hasBOM(ByteOrderMark.UTF_16BE)); + assertEquals("getBOM", ByteOrderMark.UTF_16BE, in.getBOM()); + try { + in.hasBOM(ByteOrderMark.UTF_16LE); + fail("Expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected - not configured for UTF-16LE + } + in.close(); + } + + @Test + public void testReadWithBOMUtf16Le() throws Exception { + @SuppressWarnings("deprecation") // unavoidable until Java 7 + final byte[] data = "ABC".getBytes(Charsets.UTF_16LE); + final BOMInputStream in = new BOMInputStream(createUtf16LeDataStream(data, true), ByteOrderMark.UTF_16LE); + assertEquals('A', in.read()); + assertEquals(0, in.read()); + assertEquals('B', in.read()); + assertEquals(0, in.read()); + assertEquals('C', in.read()); + assertEquals(0, in.read()); + assertEquals(-1, in.read()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-16LE)", in.hasBOM(ByteOrderMark.UTF_16LE)); + assertEquals("getBOM", ByteOrderMark.UTF_16LE, in.getBOM()); + try { + in.hasBOM(ByteOrderMark.UTF_16BE); + fail("Expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected - not configured for UTF-16BE + } + in.close(); + } + + @Test + public void testReadWithBOMUtf32Be() throws Exception { + Assume.assumeTrue(Charset.isSupported("UTF_32BE")); + final byte[] data = "ABC".getBytes("UTF_32BE"); + final BOMInputStream in = new BOMInputStream(createUtf32BeDataStream(data, true), ByteOrderMark.UTF_32BE); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals('A', in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals('B', in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-32BE)", in.hasBOM(ByteOrderMark.UTF_32BE)); + assertEquals("getBOM", ByteOrderMark.UTF_32BE, in.getBOM()); + try { + in.hasBOM(ByteOrderMark.UTF_32LE); + fail("Expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected - not configured for UTF-32LE + } + in.close(); + } + + @Test + public void testReadWithBOMUtf32Le() throws Exception { + Assume.assumeTrue(Charset.isSupported("UTF_32LE")); + final byte[] data = "ABC".getBytes("UTF_32LE"); + final BOMInputStream in = new BOMInputStream(createUtf32LeDataStream(data, true), ByteOrderMark.UTF_32LE); + assertEquals('A', in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals('B', in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals('C', in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals(0, in.read()); + assertEquals(-1, in.read()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-32LE)", in.hasBOM(ByteOrderMark.UTF_32LE)); + assertEquals("getBOM", ByteOrderMark.UTF_32LE, in.getBOM()); + try { + in.hasBOM(ByteOrderMark.UTF_32BE); + fail("Expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected - not configured for UTF-32BE + } + in.close(); + } + + @Test + public void testReadWithBOMUtf8() throws Exception { + @SuppressWarnings("deprecation") // unavoidable until Java 7 + final byte[] data = "ABC".getBytes(Charsets.UTF_8); + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), ByteOrderMark.UTF_8); + assertEquals('A', in.read()); + assertEquals('B', in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertEquals("getBOM", ByteOrderMark.UTF_8, in.getBOM()); + try { + in.hasBOM(ByteOrderMark.UTF_16BE); + fail("Expected IllegalArgumentException"); + } catch (final IllegalArgumentException e) { + // expected - not configured for UTF-16BE + } + in.close(); + } + + @Test + public void testReadWithMultipleBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, true), + ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_8); + assertEquals('A', in.read()); + assertEquals('B', in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + assertTrue("hasBOM()", in.hasBOM()); + assertTrue("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertFalse("hasBOM(UTF-16BE)", in.hasBOM(ByteOrderMark.UTF_16BE)); + assertEquals("getBOM", ByteOrderMark.UTF_8, in.getBOM()); + in.close(); + } + + @Test + public void testReadWithoutBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final BOMInputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + assertEquals('A', in.read()); + assertEquals('B', in.read()); + assertEquals('C', in.read()); + assertEquals(-1, in.read()); + assertFalse("hasBOM()", in.hasBOM()); + assertFalse("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8)); + assertNull("getBOM", in.getBOM()); + in.close(); + } + + @Test + public void testReadXmlWithBOMUcs2() throws Exception { + Assume.assumeFalse("This test does not pass on some IBM VMs xml parsers", System.getProperty("java.vendor").contains("IBM")); + + // UCS-2 is BE. + Assume.assumeTrue(Charset.isSupported("ISO-10646-UCS-2")); + final byte[] data = "".getBytes("ISO-10646-UCS-2"); + parseXml(new BOMInputStream(createUtf16BeDataStream(data, true), ByteOrderMark.UTF_16BE)); + parseXml(createUtf16BeDataStream(data, true)); + } + + @Test + public void testReadXmlWithBOMUcs4() throws Exception { + // UCS-4 is BE or LE? + // Hm: ISO-10646-UCS-4 is not supported on Oracle 1.6.0_31 + Assume.assumeTrue(Charset.isSupported("ISO-10646-UCS-4")); + final byte[] data = "".getBytes("ISO-10646-UCS-4"); + // XML parser does not know what to do with UTF-32 + parseXml(new BOMInputStream(createUtf32BeDataStream(data, true), ByteOrderMark.UTF_32BE)); + // XML parser does not know what to do with UTF-32 + Assume.assumeTrue("JVM and SAX need to support UTF_32LE for this", jvmAndSaxBothSupportCharset("UTF_32LE")); + parseXml(createUtf32BeDataStream(data, true)); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testReadXmlWithBOMUtf16Be() throws Exception { + final byte[] data = "".getBytes(Charsets.UTF_16BE); + parseXml(new BOMInputStream(createUtf16BeDataStream(data, true), ByteOrderMark.UTF_16BE)); + parseXml(createUtf16BeDataStream(data, true)); + } + + @Test + @SuppressWarnings("deprecation") // unavoidable until Java 7 + public void testReadXmlWithBOMUtf16Le() throws Exception { + final byte[] data = "".getBytes(Charsets.UTF_16LE); + parseXml(new BOMInputStream(createUtf16LeDataStream(data, true), ByteOrderMark.UTF_16LE)); + parseXml(createUtf16LeDataStream(data, true)); + } + + @Test + public void testReadXmlWithBOMUtf32Be() throws Exception { + Assume.assumeTrue("JVM and SAX need to support UTF_32BE for this", jvmAndSaxBothSupportCharset("UTF_32BE")); + final byte[] data = "".getBytes("UTF_32BE"); + parseXml(new BOMInputStream(createUtf32BeDataStream(data, true), ByteOrderMark.UTF_32BE)); + // XML parser does not know what to do with UTF-32, so we warp the input stream with a XmlStreamReader + parseXml(new XmlStreamReader(createUtf32BeDataStream(data, true))); + } + + @Test + public void testReadXmlWithBOMUtf32Le() throws Exception { + Assume.assumeTrue("JVM and SAX need to support UTF_32LE for this", jvmAndSaxBothSupportCharset("UTF_32LE")); + final byte[] data = "".getBytes("UTF_32LE"); + parseXml(new BOMInputStream(createUtf32LeDataStream(data, true), ByteOrderMark.UTF_32LE)); + // XML parser does not know what to do with UTF-32, so we warp the input stream with a XmlStreamReader + parseXml(new XmlStreamReader(createUtf32LeDataStream(data, true))); + } + + @Test + public void testReadXmlWithBOMUtf8() throws Exception { + @SuppressWarnings("deprecation") // unavoidable until Java 7 + final byte[] data = "".getBytes(Charsets.UTF_8); + parseXml(new BOMInputStream(createUtf8DataStream(data, true))); + parseXml(createUtf8DataStream(data, true)); + } + + @Test + public void testReadXmlWithoutBOMUtf32Be() throws Exception { + Assume.assumeTrue("JVM and SAX need to support UTF_32BE for this", jvmAndSaxBothSupportCharset("UTF_32BE")); + final byte[] data = "".getBytes("UTF_32BE"); + parseXml(new BOMInputStream(createUtf32BeDataStream(data, false))); + parseXml(createUtf32BeDataStream(data, false)); + } + + @Test + public void testReadXmlWithoutBOMUtf32Le() throws Exception { + Assume.assumeTrue("JVM and SAX need to support UTF_32LE for this", jvmAndSaxBothSupportCharset("UTF_32LE")); + final byte[] data = "".getBytes("UTF_32LE"); + parseXml(new BOMInputStream(createUtf32LeDataStream(data, false))); + parseXml(createUtf32BeDataStream(data, false)); + } + + @Test + public void testSkipWithBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + in.skip(2L); + assertEquals('C', in.read()); + in.close(); + } + + @Test + public void testSkipWithoutBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C', 'D' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + in.skip(2L); + assertEquals('C', in.read()); + in.close(); + } + + + @Test + public void skipReturnValueWithBom() throws IOException { + byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33}; + BOMInputStream is1 = new BOMInputStream(createUtf8DataStream(baseData, true)); + assertEquals(2, is1.skip(2)); + assertEquals((byte) 0x33, is1.read()); + is1.close(); + } + + @Test + public void skipReturnValueWithoutBom() throws IOException { + byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33}; + BOMInputStream is2 = new BOMInputStream(createUtf8DataStream(baseData, false)); + assertEquals(2, is2.skip(2)); // IO-428 + assertEquals((byte) 0x33, is2.read()); + is2.close(); + } + + @Test + public void testSmallBufferWithBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, true)); + final byte[] buf = new byte[1024]; + assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2)); + assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2)); + in.close(); + } + + @Test + public void testSmallBufferWithoutBOM() throws Exception { + final byte[] data = new byte[] { 'A', 'B', 'C' }; + final InputStream in = new BOMInputStream(createUtf8DataStream(data, false)); + final byte[] buf = new byte[1024]; + assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2)); + assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2)); + in.close(); + } + + @Test + // make sure that our support code works as expected + public void testSupportCode() throws Exception { + final InputStream in = createUtf8DataStream(new byte[] { 'A', 'B' }, true); + final byte[] buf = new byte[1024]; + final int len = in.read(buf); + assertEquals(5, len); + assertEquals(0xEF, buf[0] & 0xFF); + assertEquals(0xBB, buf[1] & 0xFF); + assertEquals(0xBF, buf[2] & 0xFF); + assertEquals('A', buf[3] & 0xFF); + assertEquals('B', buf[4] & 0xFF); + + assertData( + new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF, 'A', 'B' }, + buf, len); + } + + private boolean jvmAndSaxBothSupportCharset(String charSetName) throws ParserConfigurationException, SAXException, IOException { + return Charset.isSupported(charSetName) && doesSaxSupportCharacterSet(charSetName); + } + + private boolean doesSaxSupportCharacterSet(String charSetName) throws ParserConfigurationException, SAXException, IOException { + final byte[] data = ("").getBytes(charSetName); + final DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + try { + final InputSource is = new InputSource(new ByteArrayInputStream(data)); + is.setEncoding(charSetName); + documentBuilder.parse(is); + } catch (SAXParseException e) { + if (e.getMessage().contains(charSetName)) return false; + } + return true; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..c4b596c4d0ae3a12e842b9c79db3e6013475b24a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java" @@ -0,0 +1,90 @@ +/* + * 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.input; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import java.io.ByteArrayInputStream; + +import static org.junit.Assert.assertEquals; + +/** + * Tests for {@link BoundedInputStream}. + * + * @version $Id: BoundedInputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class BoundedInputStreamTest { + + @Test + public void testReadSingle() throws Exception { + BoundedInputStream bounded; + final byte[] helloWorld = "Hello World".getBytes(); + final byte[] hello = "Hello".getBytes(); + + // limit = length + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length); + for (int i = 0; i < helloWorld.length; i++) { + assertEquals("limit = length byte[" + i + "]", helloWorld[i], bounded.read()); + } + assertEquals("limit = length end", -1, bounded.read()); + + // limit > length + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length + 1); + for (int i = 0; i < helloWorld.length; i++) { + assertEquals("limit > length byte[" + i + "]", helloWorld[i], bounded.read()); + } + assertEquals("limit > length end", -1, bounded.read()); + + // limit < length + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), hello.length); + for (int i = 0; i < hello.length; i++) { + assertEquals("limit < length byte[" + i + "]", hello[i], bounded.read()); + } + assertEquals("limit < length end", -1, bounded.read()); + } + + @Test + public void testReadArray() throws Exception { + + BoundedInputStream bounded; + final byte[] helloWorld = "Hello World".getBytes(); + final byte[] hello = "Hello".getBytes(); + + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld)); + compare("limit = -1", helloWorld, IOUtils.toByteArray(bounded)); + + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), 0); + compare("limit = 0", new byte[0], IOUtils.toByteArray(bounded)); + + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length); + compare("limit = length", helloWorld, IOUtils.toByteArray(bounded)); + + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length + 1); + compare("limit > length", helloWorld, IOUtils.toByteArray(bounded)); + + bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length - 6); + compare("limit < length", hello, IOUtils.toByteArray(bounded)); + } + + private void compare(final String msg, final byte[] expected, final byte[] actual) { + assertEquals(msg + " length", expected.length, actual.length); + for (int i = 0; i < expected.length; i++) { + assertEquals(msg + " byte[" + i + "]", expected[i], actual[i]); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..2f61cccfac1336bc47186e9b36dc8044254c95ba --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BoundedReaderTest.java" @@ -0,0 +1,184 @@ +/* + * 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.input; + +import org.junit.Test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.io.StringReader; +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class BoundedReaderTest +{ + private final Reader sr = new BufferedReader( new StringReader( "01234567890" ) ); + + private final Reader shortReader = new BufferedReader( new StringReader( "01" ) ); + + @Test + public void readTillEnd() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.read(); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void shortReader() throws IOException { + BoundedReader mr = new BoundedReader( shortReader, 3 ); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void readMulti() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + char[] cbuf = new char[4]; + for ( int i = 0; i < cbuf.length; i++ ) + { + cbuf[i] = 'X'; + } + final int read = mr.read( cbuf, 0, 4 ); + assertEquals( 3, read ); + assertEquals( '0', cbuf[0] ); + assertEquals( '1', cbuf[1] ); + assertEquals( '2', cbuf[2] ); + assertEquals( 'X', cbuf[3] ); + mr.close(); + } + + @Test + public void readMultiWithOffset() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + char[] cbuf = new char[4]; + for ( int i = 0; i < cbuf.length; i++ ) { + cbuf[i] = 'X'; + } + final int read = mr.read( cbuf, 1, 2 ); + assertEquals( 2, read ); + assertEquals( 'X', cbuf[0] ); + assertEquals( '0', cbuf[1] ); + assertEquals( '1', cbuf[2] ); + assertEquals( 'X', cbuf[3] ); + mr.close(); + } + + @Test + public void markReset() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.mark( 3 ); + mr.read(); + mr.read(); + mr.read(); + mr.reset(); + mr.read(); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + + @Test + public void markResetWithMarkOutsideBoundedReaderMax() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.mark( 4 ); + mr.read(); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void markResetWithMarkOutsideBoundedReaderMaxAndInitialOffset() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.read(); + mr.mark( 3 ); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void markResetFromOffset1() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.mark( 3 ); + mr.read(); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.reset(); + mr.mark( 1 ); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void markResetMarkMore() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.mark( 4 ); + mr.read(); + mr.read(); + mr.read(); + mr.reset(); + mr.read(); + mr.read(); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void skipTest() throws IOException { + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.skip( 2 ); + mr.read(); + assertEquals( -1, mr.read() ); + mr.close(); + } + + @Test + public void closeTest() throws IOException { + final AtomicBoolean closed = new AtomicBoolean( false ); + final Reader sr = new BufferedReader( new StringReader( "01234567890" ) ) { + @Override + public void close() + throws IOException + { + closed.set( true ); + super.close(); + } + }; + + BoundedReader mr = new BoundedReader( sr, 3 ); + mr.close(); + assertTrue( closed.get() ); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..3b35d0ce86e1542151ae2d33a242896373f2bae4 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java" @@ -0,0 +1,108 @@ +/* + * 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.input; + +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link BrokenInputStream}. + */ +@SuppressWarnings("ResultOfMethodCallIgnored") +public class BrokenInputStreamTest { + + private IOException exception; + + private InputStream stream; + + @Before + public void setUp() { + exception = new IOException("test exception"); + stream = new BrokenInputStream(exception); + } + + @Test + public void testRead() { + try { + stream.read(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + + try { + stream.read(new byte[1]); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + + try { + stream.read(new byte[1], 0, 1); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + + @Test + public void testAvailable() { + try { + stream.available(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + + @Test + public void testSkip() { + try { + stream.skip(1); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + + @Test + public void testReset() { + try { + stream.reset(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + + @Test + public void testClose() { + try { + stream.close(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..bdfcae443d6a465d729950e265bbf3076c56aa33 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java" @@ -0,0 +1,453 @@ +/* + * 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.input; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.Random; +import java.util.Set; + +import org.apache.commons.io.Charsets; +import org.junit.Ignore; +import org.junit.Test; + +public class CharSequenceInputStreamTest { + + private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + private static final String LARGE_TEST_STRING; + + private static final String TEST_STRING = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre"; + + static { + final StringBuilder buffer = new StringBuilder(); + for (int i = 0; i < 100; i++) { + buffer.append(TEST_STRING); + } + LARGE_TEST_STRING = buffer.toString(); + } + + private final Random random = new Random(); + + private Set getRequiredCharsetNames() { + return Charsets.requiredCharsets().keySet(); + } + + private void testBufferedRead(final String testString, final String charsetName) throws IOException { + final byte[] expected = testString.getBytes(charsetName); + final InputStream in = new CharSequenceInputStream(testString, charsetName, 512); + try { + final byte[] buffer = new byte[128]; + int offset = 0; + while (true) { + int bufferOffset = random.nextInt(64); + final int bufferLength = random.nextInt(64); + int read = in.read(buffer, bufferOffset, bufferLength); + if (read == -1) { + assertEquals("EOF: offset should equal length for charset " + charsetName, expected.length, offset); + break; + } else { + assertTrue("Read " + read + " <= " + bufferLength, read <= bufferLength); + while (read > 0) { + assertTrue("offset for " + charsetName +" " + offset + " < " + expected.length, offset < expected.length); + assertEquals("bytes should agree for " + charsetName, expected[offset], buffer[bufferOffset]); + offset++; + bufferOffset++; + read--; + } + } + } + } finally { + in.close(); + } + } + +// Unfortunately checking canEncode does not seem to work for all charsets: +// testBufferedRead_AvailableCharset(org.apache.commons.io.input.CharSequenceInputStreamTest) Time elapsed: 0.682 sec <<< ERROR! +// java.lang.UnsupportedOperationException: null +// at java.nio.CharBuffer.array(CharBuffer.java:940) +// at sun.nio.cs.ext.COMPOUND_TEXT_Encoder.encodeLoop(COMPOUND_TEXT_Encoder.java:75) +// at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544) +// at org.apache.commons.io.input.CharSequenceInputStream.fillBuffer(CharSequenceInputStream.java:111) + @Test + public void testBufferedRead_AvailableCharset() throws IOException { + for (final String csName : Charset.availableCharsets().keySet()) { + // prevent java.lang.UnsupportedOperationException at sun.nio.cs.ext.ISO2022_CN.newEncoder. + if (isAvailabilityTestableForCharset(csName)) { + testBufferedRead(TEST_STRING, csName); + } + } + } + + @Test + public void testBufferedRead_RequiredCharset() throws IOException { + for (final String csName : getRequiredCharsetNames()) { + testBufferedRead(TEST_STRING, csName); + } + } + + @Test + public void testBufferedRead_UTF8() throws IOException { + testBufferedRead(TEST_STRING, "UTF-8"); + } + + private void testCharsetMismatchInfiniteLoop(final String csName) throws IOException { + // Input is UTF-8 bytes: 0xE0 0xB2 0xA0 + final char[] inputChars = new char[] { (char) 0xE0, (char) 0xB2, (char) 0xA0 }; + final Charset charset = Charset.forName(csName); // infinite loop for US-ASCII, UTF-8 OK + final InputStream stream = new CharSequenceInputStream(new String(inputChars), charset, 512); + try { + while (stream.read() != -1) { + } + } finally { + stream.close(); + } + } + + @Test + public void testCharsetMismatchInfiniteLoop_RequiredCharsets() throws IOException { + for (final String csName : getRequiredCharsetNames()) { + testCharsetMismatchInfiniteLoop(csName); + } + } + + // Test is broken if readFirst > 0 + // This is because the initial read fills the buffer from the CharSequence + // so data1 gets the first buffer full; data2 will get the next buffer full + private void testIO_356(final int bufferSize, final int dataSize, final int readFirst, final String csName) throws Exception { + final CharSequenceInputStream is = new CharSequenceInputStream(ALPHABET, csName, bufferSize); + + for (int i = 0; i < readFirst; i++) { + final int ch = is.read(); + assertFalse(ch == -1); + } + + is.mark(dataSize); + + final byte[] data1 = new byte[dataSize]; + final int readCount1 = is.read(data1); + assertEquals(dataSize, readCount1); + + is.reset(); // should allow data to be re-read + + final byte[] data2 = new byte[dataSize]; + final int readCount2 = is.read(data2); + assertEquals(dataSize, readCount2); + + is.close(); + + // data buffers should be identical + assertArrayEquals("bufferSize=" + bufferSize + " dataSize=" + dataSize, data1, data2); + } + + @Test + public void testIO_356_B10_D10_S0_UTF16() throws Exception { + testIO_356(10, 10, 0, "UTF-16"); + } + + @Test + public void testIO_356_B10_D10_S0_UTF8() throws Exception { + testIO_356(10, 10, 0, "UTF-8"); + } + + @Test + public void testIO_356_B10_D10_S1_UTF8() throws Exception { + testIO_356(10, 10, 1, "UTF-8"); + } + + @Test + public void testIO_356_B10_D10_S2_UTF8() throws Exception { + testIO_356(10, 10, 2, "UTF-8"); + } + + @Test + public void testIO_356_B10_D13_S0_UTF8() throws Exception { + testIO_356(10, 13, 0, "UTF-8"); + } + + @Test + public void testIO_356_B10_D13_S1_UTF8() throws Exception { + testIO_356(10, 13, 1, "UTF-8"); + } + + @Test + public void testIO_356_B10_D20_S0_UTF8() throws Exception { + testIO_356(10, 20, 0, "UTF-8"); + } + + private void testIO_356_Loop(final String csName, final int maxBytesPerChar) throws Exception { + for (int bufferSize = maxBytesPerChar; bufferSize <= 10; bufferSize++) { + for (int dataSize = 1; dataSize <= 20; dataSize++) { + testIO_356(bufferSize, dataSize, 0, csName); + } + } + } + + @Test + public void testIO_356_Loop_UTF16() throws Exception { + testIO_356_Loop("UTF-16", 4); + } + + @Test + public void testIO_356_Loop_UTF8() throws Exception { + testIO_356_Loop("UTF-8", 4); + } + + @Test + public void testLargeBufferedRead_RequiredCharsets() throws IOException { + for (final String csName : getRequiredCharsetNames()) { + testBufferedRead(LARGE_TEST_STRING, csName); + } + } + + @Test + public void testLargeBufferedRead_UTF8() throws IOException { + testBufferedRead(LARGE_TEST_STRING, "UTF-8"); + } + + @Test + public void testLargeSingleByteRead_RequiredCharsets() throws IOException { + for (final String csName : getRequiredCharsetNames()) { + testSingleByteRead(LARGE_TEST_STRING, csName); + } + } + + @Test + public void testLargeSingleByteRead_UTF8() throws IOException { + testSingleByteRead(LARGE_TEST_STRING, "UTF-8"); + } + + // This test is broken for charsets that don't create a single byte for each char + private void testMarkReset(final String csName) throws Exception { + final InputStream r = new CharSequenceInputStream("test", csName); + try { + assertEquals(2, r.skip(2)); + r.mark(0); + assertEquals(csName, 's', r.read()); + assertEquals(csName, 't', r.read()); + assertEquals(csName, -1, r.read()); + r.reset(); + assertEquals(csName, 's', r.read()); + assertEquals(csName, 't', r.read()); + assertEquals(csName, -1, r.read()); + r.reset(); + r.reset(); + } finally { + r.close(); + } + } + + @Test + @Ignore // Test broken for charsets that create multiple bytes for a single char + public void testMarkReset_RequiredCharsets() throws Exception { + for (final String csName : getRequiredCharsetNames()) { + testMarkReset(csName); + } + } + + @Test + public void testMarkReset_USASCII() throws Exception { + testMarkReset("US-ASCII"); + } + + @Test + public void testMarkReset_UTF8() throws Exception { + testMarkReset("UTF-8"); + } + + @Test + public void testMarkSupported() throws Exception { + final InputStream r = new CharSequenceInputStream("test", "UTF-8"); + try { + assertTrue(r.markSupported()); + } finally { + r.close(); + } + } + + private void testReadZero(final String csName) throws Exception { + final InputStream r = new CharSequenceInputStream("test", csName); + try { + final byte[] bytes = new byte[30]; + assertEquals(0, r.read(bytes, 0, 0)); + } finally { + r.close(); + } + } + + @Test + public void testReadZero_EmptyString() throws Exception { + final InputStream r = new CharSequenceInputStream("", "UTF-8"); + try { + final byte[] bytes = new byte[30]; + assertEquals(0, r.read(bytes, 0, 0)); + } finally { + r.close(); + } + } + + @Test + public void testReadZero_RequiredCharsets() throws Exception { + for (final String csName : getRequiredCharsetNames()) { + testReadZero(csName); + } + } + + private void testSingleByteRead(final String testString, final String charsetName) throws IOException { + final byte[] bytes = testString.getBytes(charsetName); + final InputStream in = new CharSequenceInputStream(testString, charsetName, 512); + try { + for (final byte b : bytes) { + final int read = in.read(); + assertTrue("read " + read + " >=0 ", read >= 0); + assertTrue("read " + read + " <= 255", read <= 255); + assertEquals("Should agree with input", b, (byte) read); + } + assertEquals(-1, in.read()); + } finally { + in.close(); + } + } + + @Test + public void testSingleByteRead_RequiredCharsets() throws IOException { + for (final String csName : getRequiredCharsetNames()) { + testSingleByteRead(TEST_STRING, csName); + } + } + + @Test + public void testSingleByteRead_UTF16() throws IOException { + testSingleByteRead(TEST_STRING, "UTF-16"); + } + + @Test + public void testSingleByteRead_UTF8() throws IOException { + testSingleByteRead(TEST_STRING, "UTF-8"); + } + + // This is broken for charsets that don't map each char to a byte + private void testSkip(final String csName) throws Exception { + final InputStream r = new CharSequenceInputStream("test", csName); + try { + assertEquals(1, r.skip(1)); + assertEquals(2, r.skip(2)); + assertEquals(csName, 't', r.read()); + r.skip(100); + assertEquals(csName, -1, r.read()); + } finally { + r.close(); + } + } + + @Test + @Ignore // test is broken for charsets that generate multiple bytes per char. + public void testSkip_RequiredCharsets() throws Exception { + for (final String csName : getRequiredCharsetNames()) { + testSkip(csName); + } + } + + @Test + public void testSkip_USASCII() throws Exception { + testSkip("US-ASCII"); + } + + @Test + public void testSkip_UTF8() throws Exception { + testSkip("UTF-8"); + } + + private int checkAvail(InputStream is, int min) throws Exception { + int available = is.available(); + assertTrue("avail should be >= " + min + ", but was " + available, available >= min); + return available; + } + + private void testAvailableSkip(final String csName) throws Exception { + final String input = "test"; + final InputStream r = new CharSequenceInputStream(input, csName); + try { + int available = checkAvail(r, input.length()); + assertEquals(available - 1, r.skip(available-1)); // skip all but one + available = checkAvail(r, 1); + assertEquals(1, r.skip(1)); + available = checkAvail(r, 0); + } finally { + r.close(); + } + } + + private void testAvailableRead(final String csName) throws Exception { + final String input = "test"; + final InputStream r = new CharSequenceInputStream(input, csName); + try { + int available = checkAvail(r, input.length()); + byte buff[] = new byte[available]; + assertEquals(available - 1, r.skip(available-1)); // skip all but one + available = checkAvail(r, 1); + buff = new byte[available]; + assertEquals(available, r.read(buff, 0, available)); + } finally { + r.close(); + } + } + + @Test + public void testAvailable() throws Exception { + for (final String csName : Charset.availableCharsets().keySet()) { + // prevent java.lang.UnsupportedOperationException at sun.nio.cs.ext.ISO2022_CN.newEncoder. + // also try and avoid the following Effor on Continuum +// java.lang.UnsupportedOperationException: null +// at java.nio.CharBuffer.array(CharBuffer.java:940) +// at sun.nio.cs.ext.COMPOUND_TEXT_Encoder.encodeLoop(COMPOUND_TEXT_Encoder.java:75) +// at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544) +// at org.apache.commons.io.input.CharSequenceInputStream.fillBuffer(CharSequenceInputStream.java:120) +// at org.apache.commons.io.input.CharSequenceInputStream.read(CharSequenceInputStream.java:151) +// at org.apache.commons.io.input.CharSequenceInputStreamTest.testAvailableRead(CharSequenceInputStreamTest.java:412) +// at org.apache.commons.io.input.CharSequenceInputStreamTest.testAvailable(CharSequenceInputStreamTest.java:424) + + try { + if (isAvailabilityTestableForCharset(csName)) { + testAvailableSkip(csName); + testAvailableRead(csName); + } + } catch (UnsupportedOperationException e){ + fail("Operation not supported for " + csName); + } + } + } + + private boolean isAvailabilityTestableForCharset(final String csName) { + return Charset.forName(csName).canEncode() + && !"COMPOUND_TEXT".equalsIgnoreCase(csName) && !"x-COMPOUND_TEXT".equalsIgnoreCase(csName) + && !isOddBallLegacyCharsetThatDoesNotSupportFrenchCharacters(csName); + } + + private boolean isOddBallLegacyCharsetThatDoesNotSupportFrenchCharacters(String csName) { + return "x-IBM1388".equalsIgnoreCase(csName) || + "ISO-2022-CN".equalsIgnoreCase(csName) || + "ISO-2022-JP".equalsIgnoreCase(csName) || + "Shift_JIS".equalsIgnoreCase(csName); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..db87bbf0b7b560c199a8d811117afd0d2902c613 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java" @@ -0,0 +1,130 @@ +/* + * 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.input; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.io.Reader; + +import org.junit.Test; + +/** + * Test case for {@link CharSequenceReader}. + * + * @version $Id: CharSequenceReaderTest.java 1680650 2015-05-20 18:36:40Z britter $ + */ +public class CharSequenceReaderTest { + private static final char NONE = (new char[1])[0]; + + @Test + public void testClose() throws IOException { + final Reader reader = new CharSequenceReader("FooBar"); + checkRead(reader, "Foo"); + reader.close(); + checkRead(reader, "Foo"); + } + + @Test + public void testMarkSupported() throws Exception { + final Reader reader = new CharSequenceReader("FooBar"); + assertTrue(reader.markSupported()); + reader.close(); + } + + @Test + public void testMark() throws IOException { + final Reader reader = new CharSequenceReader("FooBar"); + checkRead(reader, "Foo"); + reader.mark(0); + checkRead(reader, "Bar"); + reader.reset(); + checkRead(reader, "Bar"); + reader.close(); + checkRead(reader, "Foo"); + reader.reset(); + checkRead(reader, "Foo"); + } + + @Test + public void testSkip() throws IOException { + final Reader reader = new CharSequenceReader("FooBar"); + assertEquals(3, reader.skip(3)); + checkRead(reader, "Bar"); + assertEquals(-1, reader.skip(3)); + reader.reset(); + assertEquals(2, reader.skip(2)); + assertEquals(4, reader.skip(10)); + assertEquals(-1, reader.skip(1)); + reader.close(); + assertEquals(6, reader.skip(20)); + assertEquals(-1, reader.read()); + } + + @Test + public void testRead() throws IOException { + final Reader reader = new CharSequenceReader("Foo"); + assertEquals('F', reader.read()); + assertEquals('o', reader.read()); + assertEquals('o', reader.read()); + assertEquals(-1, reader.read()); + assertEquals(-1, reader.read()); + reader.close(); + } + + @Test + public void testReadCharArray() throws IOException { + final Reader reader = new CharSequenceReader("FooBar"); + char[] chars = new char[2]; + assertEquals(2, reader.read(chars)); + checkArray(new char[] {'F', 'o'}, chars); + chars = new char[3]; + assertEquals(3, reader.read(chars)); + checkArray(new char[] {'o', 'B', 'a'}, chars); + chars = new char[3]; + assertEquals(1, reader.read(chars)); + checkArray(new char[] {'r', NONE, NONE}, chars); + assertEquals(-1, reader.read(chars)); + reader.close(); + } + + @Test + public void testReadCharArrayPortion() throws IOException { + final char[] chars = new char[10]; + final Reader reader = new CharSequenceReader("FooBar"); + assertEquals(3, reader.read(chars, 3, 3)); + checkArray(new char[] {NONE, NONE, NONE, 'F', 'o', 'o'}, chars); + assertEquals(3, reader.read(chars, 0, 3)); + checkArray(new char[] {'B', 'a', 'r', 'F', 'o', 'o', NONE}, chars); + assertEquals(-1, reader.read(chars)); + reader.close(); + } + + private void checkRead(final Reader reader, final String expected) throws IOException { + for (int i = 0; i < expected.length(); i++) { + assertEquals("Read[" + i + "] of '" + expected + "'", + expected.charAt(i), (char)reader.read()); + } + } + + private void checkArray(final char[] expected, final char[] actual) { + for (int i = 0; i < expected.length; i++) { + assertEquals("Compare[" +i + "]", expected[i], actual[i]); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..e913a74c72dc15d0a2b7a2ef8716f48fb67da2ff --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ClassLoaderObjectInputStreamTest.java" @@ -0,0 +1,187 @@ +/* + * 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.input; + +import java.io.*; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Tests the CountingInputStream. + * + * @version $Id: ClassLoaderObjectInputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class ClassLoaderObjectInputStreamTest { + + /* Note: This test case tests the simplest functionality of + * ObjectInputStream. IF we really wanted to test ClassLoaderObjectInputStream + * we would probably need to create a transient Class Loader. -TO + */ + + + @org.junit.Test + public void testExpected() throws Exception { + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + final Object input = Boolean.FALSE; + oos.writeObject(input); + + final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); + final ClassLoaderObjectInputStream clois = + new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais); + final Object result = clois.readObject(); + + assertEquals(input, result); + clois.close(); + } + + @org.junit.Test + public void testLong() throws Exception { + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + final Object input = (long) 123; + oos.writeObject(input); + + final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); + final ClassLoaderObjectInputStream clois = + new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais); + final Object result = clois.readObject(); + + assertEquals(input, result); + clois.close(); + } + + @org.junit.Test + public void testPrimitiveLong() throws Exception { + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + final long input = 12345L; + oos.writeLong(input); + oos.close(); + + final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); + final ClassLoaderObjectInputStream clois = + new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais); + final long result = clois.readLong(); + + assertEquals(input, result); + clois.close(); + } + + private static enum E {A, B, C} + + private static class Test implements Serializable { + private static final long serialVersionUID = 1L; + private int i; + + private Object o; + + private E e; + + Test(int i, Object o) { + this.i = i; + this.e = E.A; + this.o = o; + } + + @Override + public boolean equals(Object other) { + if (other instanceof Test) { + Test tother = (Test) other; + return (this.i == tother.i) + & (this.e == tother.e) + & equalObject(tother.o); + } else { + return false; + } + } + + private boolean equalObject(Object other) { + if (this.o == null) { + return other == null; + } + return o.equals(other); + } + + @Override + public int hashCode() { + return super.hashCode(); + } + } + + @org.junit.Test + public void testObject1() throws Exception { + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + final Object input = new Test(123, null); + oos.writeObject(input); + oos.close(); + + final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); + final ClassLoaderObjectInputStream clois = + new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais); + final Object result = clois.readObject(); + + assertEquals(input, result); + clois.close(); + } + + @org.junit.Test + public void testObject2() throws Exception { + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + final Object input = new Test(123, 0); + oos.writeObject(input); + oos.close(); + + final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); + final ClassLoaderObjectInputStream clois = + new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais); + final Object result = clois.readObject(); + + assertEquals(input, result); + clois.close(); + } + + @org.junit.Test + public void testResolveProxyClass() throws Exception { + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(Boolean.FALSE); + final InputStream bais = new ByteArrayInputStream(baos.toByteArray()); + + final ClassLoaderObjectInputStream clois = + new ClassLoaderObjectInputStream(getClass().getClassLoader(), bais); + final String[] interfaces = new String[]{Comparable.class.getName()}; + final Class result = clois.resolveProxyClass(interfaces); + assertTrue("Assignable", Comparable.class.isAssignableFrom(result)); + clois.close(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CloseShieldInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CloseShieldInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..55e56fd4066c327fc953535b7dafdacd53a18daf --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CloseShieldInputStreamTest.java" @@ -0,0 +1,63 @@ +/* + * 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.input; + +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +/** + * JUnit Test Case for {@link CloseShieldInputStream}. + */ +public class CloseShieldInputStreamTest { + + private byte[] data; + + private InputStream original; + + private InputStream shielded; + + private boolean closed; + + @Before + public void setUp() { + data = new byte[] { 'x', 'y', 'z' }; + original = new ByteArrayInputStream(data) { + @Override + public void close() { + closed = true; + } + }; + shielded = new CloseShieldInputStream(original); + closed = false; + } + + @Test + public void testClose() throws IOException { + shielded.close(); + assertFalse("closed", closed); + assertEquals("read()", -1, shielded.read()); + assertEquals("read()", data[0], original.read()); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ClosedInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ClosedInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..b10ebd704afd8ef914ac28a5bea0c0b002a57bef --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ClosedInputStreamTest.java" @@ -0,0 +1,35 @@ +/* + * 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.input; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * JUnit Test Case for {@link ClosedInputStream}. + */ +public class ClosedInputStreamTest { + + @Test + public void testRead() throws Exception { + final ClosedInputStream cis = new ClosedInputStream(); + assertEquals("read()", -1, cis.read()); + cis.close(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..6e5c1a5e0f139d485e880e6c81ec111c51670926 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java" @@ -0,0 +1,220 @@ +/* + * 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.input; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.output.NullOutputStream; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.OutputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * Tests the CountingInputStream. + * + * @version $Id: CountingInputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class CountingInputStreamTest { + + @Test + public void testCounting() throws Exception { + final String text = "A piece of text"; + final byte[] bytes = text.getBytes(); + final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + final CountingInputStream cis = new CountingInputStream(bais); + + // have to declare this larger as we're going to read + // off the end of the stream and input stream seems + // to do bounds checking + final byte[] result = new byte[21]; + + final byte[] ba = new byte[5]; + int found = cis.read(ba); + System.arraycopy(ba, 0, result, 0, 5); + assertEquals( found, cis.getCount() ); + + final int value = cis.read(); + found++; + result[5] = (byte)value; + assertEquals( found, cis.getCount() ); + + found += cis.read(result, 6, 5); + assertEquals( found, cis.getCount() ); + + found += cis.read(result, 11, 10); // off the end + assertEquals( found, cis.getCount() ); + + // trim to get rid of the 6 empty values + final String textResult = new String(result).trim(); + assertEquals(textResult, text); + cis.close(); + } + + + /* + * Test for files > 2GB in size - see issue IO-84 + */ + @Test + public void testLargeFiles_IO84() throws Exception { + final long size = (long)Integer.MAX_VALUE + (long)1; + final NullInputStream mock = new NullInputStream(size); + final CountingInputStream cis = new CountingInputStream(mock); + final OutputStream out = new NullOutputStream(); + + // Test integer methods + IOUtils.copyLarge(cis, out); + try { + cis.getCount(); + fail("Expected getCount() to throw an ArithmeticException"); + } catch (final ArithmeticException ae) { + // expected result + } + try { + cis.resetCount(); + fail("Expected resetCount() to throw an ArithmeticException"); + } catch (final ArithmeticException ae) { + // expected result + } + + mock.close(); + + // Test long methods + IOUtils.copyLarge(cis, out); + assertEquals("getByteCount()", size, cis.getByteCount()); + assertEquals("resetByteCount()", size, cis.resetByteCount()); + } + + @Test + public void testResetting() throws Exception { + final String text = "A piece of text"; + final byte[] bytes = text.getBytes(); + final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + final CountingInputStream cis = new CountingInputStream(bais); + + final byte[] result = new byte[bytes.length]; + + int found = cis.read(result, 0, 5); + assertEquals( found, cis.getCount() ); + + final int count = cis.resetCount(); + found = cis.read(result, 6, 5); + assertEquals( found, count ); + cis.close(); + } + + @Test + public void testZeroLength1() throws Exception { + final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); + final CountingInputStream cis = new CountingInputStream(bais); + + final int found = cis.read(); + assertEquals(-1, found); + assertEquals(0, cis.getCount()); + cis.close(); + } + + @Test + public void testZeroLength2() throws Exception { + final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); + final CountingInputStream cis = new CountingInputStream(bais); + + final byte[] result = new byte[10]; + + final int found = cis.read(result); + assertEquals(-1, found); + assertEquals(0, cis.getCount()); + cis.close(); + } + + @Test + public void testZeroLength3() throws Exception { + final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]); + final CountingInputStream cis = new CountingInputStream(bais); + + final byte[] result = new byte[10]; + + final int found = cis.read(result, 0, 5); + assertEquals(-1, found); + assertEquals(0, cis.getCount()); + cis.close(); + } + + @Test + public void testEOF1() throws Exception { + final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[2]); + final CountingInputStream cis = new CountingInputStream(bais); + + int found = cis.read(); + assertEquals(0, found); + assertEquals(1, cis.getCount()); + found = cis.read(); + assertEquals(0, found); + assertEquals(2, cis.getCount()); + found = cis.read(); + assertEquals(-1, found); + assertEquals(2, cis.getCount()); + cis.close(); + } + + @Test + public void testEOF2() throws Exception { + final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[2]); + final CountingInputStream cis = new CountingInputStream(bais); + + final byte[] result = new byte[10]; + + final int found = cis.read(result); + assertEquals(2, found); + assertEquals(2, cis.getCount()); + cis.close(); + } + + @Test + public void testEOF3() throws Exception { + final ByteArrayInputStream bais = new ByteArrayInputStream(new byte[2]); + final CountingInputStream cis = new CountingInputStream(bais); + + final byte[] result = new byte[10]; + + final int found = cis.read(result, 0, 5); + assertEquals(2, found); + assertEquals(2, cis.getCount()); + cis.close(); + } + + @Test + public void testSkipping() throws IOException { + final String text = "Hello World!"; + final byte[] bytes = text.getBytes(); + final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + final CountingInputStream cis = new CountingInputStream(bais); + + assertEquals(6,cis.skip(6)); + assertEquals(6,cis.getCount()); + final byte[] result = new byte[6]; + cis.read(result); + + assertEquals("World!",new String(result)); + assertEquals(12,cis.getCount()); + cis.close(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..fd6081e0fa925f504d69931934f25bc8d46b9b4a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java" @@ -0,0 +1,238 @@ +/* + * 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.input; + +import org.junit.Test; + +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link NullInputStream}. + * + * @version $Id: NullInputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class NullInputStreamTest { + + @Test + public void testRead() throws Exception { + final int size = 5; + final InputStream input = new TestNullInputStream(size); + for (int i = 0; i < size; i++) { + assertEquals("Check Size [" + i + "]", size - i, input.available()); + assertEquals("Check Value [" + i + "]", i, input.read()); + } + assertEquals("Available after contents all read", 0, input.available()); + + // Check availbale is zero after End of file + assertEquals("End of File", -1, input.read()); + assertEquals("Available after End of File", 0, input.available()); + + // Test reading after the end of file + try { + final int result = input.read(); + fail("Should have thrown an IOException, byte=[" + result + "]"); + } catch (final IOException e) { + assertEquals("Read after end of file", e.getMessage()); + } + + // Close - should reset + input.close(); + assertEquals("Available after close", size, input.available()); + } + + @Test + public void testReadByteArray() throws Exception { + final byte[] bytes = new byte[10]; + final InputStream input = new TestNullInputStream(15); + + // Read into array + final int count1 = input.read(bytes); + assertEquals("Read 1", bytes.length, count1); + for (int i = 0; i < count1; i++) { + assertEquals("Check Bytes 1", i, bytes[i]); + } + + // Read into array + final int count2 = input.read(bytes); + assertEquals("Read 2", 5, count2); + for (int i = 0; i < count2; i++) { + assertEquals("Check Bytes 2", count1 + i, bytes[i]); + } + + // End of File + final int count3 = input.read(bytes); + assertEquals("Read 3 (EOF)", -1, count3); + + // Test reading after the end of file + try { + final int count4 = input.read(bytes); + fail("Should have thrown an IOException, byte=[" + count4 + "]"); + } catch (final IOException e) { + assertEquals("Read after end of file", e.getMessage()); + } + + // reset by closing + input.close(); + + // Read into array using offset & length + final int offset = 2; + final int lth = 4; + final int count5 = input.read(bytes, offset, lth); + assertEquals("Read 5", lth, count5); + for (int i = offset; i < lth; i++) { + assertEquals("Check Bytes 2", i, bytes[i]); + } + } + + @Test + public void testEOFException() throws Exception { + final InputStream input = new TestNullInputStream(2, false, true); + assertEquals("Read 1", 0, input.read()); + assertEquals("Read 2", 1, input.read()); + try { + final int result = input.read(); + fail("Should have thrown an EOFException, byte=[" + result + "]"); + } catch (final EOFException e) { + // expected + } + input.close(); + } + + @Test + public void testMarkAndReset() throws Exception { + int position = 0; + final int readlimit = 10; + final InputStream input = new TestNullInputStream(100, true, false); + + assertTrue("Mark Should be Supported", input.markSupported()); + + // No Mark + try { + input.reset(); + fail("Read limit exceeded, expected IOException "); + } catch (final IOException e) { + assertEquals("No Mark IOException message", + "No position has been marked", + e.getMessage()); + } + + for (; position < 3; position++) { + assertEquals("Read Before Mark [" + position +"]", position, input.read()); + } + + // Mark + input.mark(readlimit); + + // Read further + for (int i = 0; i < 3; i++) { + assertEquals("Read After Mark [" + i +"]", position + i, input.read()); + } + + // Reset + input.reset(); + + // Read From marked position + for (int i = 0; i < readlimit + 1; i++) { + assertEquals("Read After Reset [" + i +"]", position + i, input.read()); + } + + // Reset after read limit passed + try { + input.reset(); + fail("Read limit exceeded, expected IOException "); + } catch (final IOException e) { + assertEquals("Read limit IOException message", + "Marked position [" + position + + "] is no longer valid - passed the read limit [" + + readlimit + "]", + e.getMessage()); + } + input.close(); + } + + @Test + public void testMarkNotSupported() throws Exception { + final InputStream input = new TestNullInputStream(100, false, true); + assertFalse("Mark Should NOT be Supported", input.markSupported()); + + try { + input.mark(5); + fail("mark() should throw UnsupportedOperationException"); + } catch (final UnsupportedOperationException e) { + assertEquals("mark() error message", "Mark not supported", e.getMessage()); + } + + try { + input.reset(); + fail("reset() should throw UnsupportedOperationException"); + } catch (final UnsupportedOperationException e) { + assertEquals("reset() error message", "Mark not supported", e.getMessage()); + } + input.close(); + } + + @Test + public void testSkip() throws Exception { + final InputStream input = new TestNullInputStream(10, true, false); + assertEquals("Read 1", 0, input.read()); + assertEquals("Read 2", 1, input.read()); + assertEquals("Skip 1", 5, input.skip(5)); + assertEquals("Read 3", 7, input.read()); + assertEquals("Skip 2", 2, input.skip(5)); // only 2 left to skip + assertEquals("Skip 3 (EOF)", -1, input.skip(5)); // End of file + try { + input.skip(5); // + fail("Expected IOException for skipping after end of file"); + } catch (final IOException e) { + assertEquals("Skip after EOF IOException message", + "Skip after end of file", + e.getMessage()); + } + input.close(); + } + + + // ------------- Test NullInputStream implementation ------------- + + private static final class TestNullInputStream extends NullInputStream { + public TestNullInputStream(final int size) { + super(size); + } + public TestNullInputStream(final int size, final boolean markSupported, final boolean throwEofException) { + super(size, markSupported, throwEofException); + } + @Override + protected int processByte() { + return (int)getPosition() - 1; + } + @Override + protected void processBytes(final byte[] bytes, final int offset, final int length) { + final int startPos = (int)getPosition() - length; + for (int i = offset; i < length; i++) { + bytes[i] = (byte)(startPos + i); + } + } + + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/NullReaderTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/NullReaderTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..080c632b19727ffe4147705f2c1250e77c0303d0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/NullReaderTest.java" @@ -0,0 +1,235 @@ +/* + * 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.input; + +import org.junit.Test; + +import java.io.EOFException; +import java.io.IOException; +import java.io.Reader; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link NullReader}. + * + * @version $Id: NullReaderTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class NullReaderTest { + + @Test + public void testRead() throws Exception { + final int size = 5; + final TestNullReader reader = new TestNullReader(size); + for (int i = 0; i < size; i++) { + assertEquals("Check Value [" + i + "]", i, reader.read()); + } + + // Check End of File + assertEquals("End of File", -1, reader.read()); + + // Test reading after the end of file + try { + final int result = reader.read(); + fail("Should have thrown an IOException, value=[" + result + "]"); + } catch (final IOException e) { + assertEquals("Read after end of file", e.getMessage()); + } + + // Close - should reset + reader.close(); + assertEquals("Available after close", 0, reader.getPosition()); + } + + @Test + public void testReadCharArray() throws Exception { + final char[] chars = new char[10]; + final Reader reader = new TestNullReader(15); + + // Read into array + final int count1 = reader.read(chars); + assertEquals("Read 1", chars.length, count1); + for (int i = 0; i < count1; i++) { + assertEquals("Check Chars 1", i, chars[i]); + } + + // Read into array + final int count2 = reader.read(chars); + assertEquals("Read 2", 5, count2); + for (int i = 0; i < count2; i++) { + assertEquals("Check Chars 2", count1 + i, chars[i]); + } + + // End of File + final int count3 = reader.read(chars); + assertEquals("Read 3 (EOF)", -1, count3); + + // Test reading after the end of file + try { + final int count4 = reader.read(chars); + fail("Should have thrown an IOException, value=[" + count4 + "]"); + } catch (final IOException e) { + assertEquals("Read after end of file", e.getMessage()); + } + + // reset by closing + reader.close(); + + // Read into array using offset & length + final int offset = 2; + final int lth = 4; + final int count5 = reader.read(chars, offset, lth); + assertEquals("Read 5", lth, count5); + for (int i = offset; i < lth; i++) { + assertEquals("Check Chars 3", i, chars[i]); + } + } + + @Test + public void testEOFException() throws Exception { + final Reader reader = new TestNullReader(2, false, true); + assertEquals("Read 1", 0, reader.read()); + assertEquals("Read 2", 1, reader.read()); + try { + final int result = reader.read(); + fail("Should have thrown an EOFException, value=[" + result + "]"); + } catch (final EOFException e) { + // expected + } + reader.close(); + } + + @Test + public void testMarkAndReset() throws Exception { + int position = 0; + final int readlimit = 10; + final Reader reader = new TestNullReader(100, true, false); + + assertTrue("Mark Should be Supported", reader.markSupported()); + + // No Mark + try { + reader.reset(); + fail("Read limit exceeded, expected IOException "); + } catch (final IOException e) { + assertEquals("No Mark IOException message", + "No position has been marked", + e.getMessage()); + } + + for (; position < 3; position++) { + assertEquals("Read Before Mark [" + position +"]", position, reader.read()); + } + + // Mark + reader.mark(readlimit); + + // Read further + for (int i = 0; i < 3; i++) { + assertEquals("Read After Mark [" + i +"]", position + i, reader.read()); + } + + // Reset + reader.reset(); + + // Read From marked position + for (int i = 0; i < readlimit + 1; i++) { + assertEquals("Read After Reset [" + i +"]", position + i, reader.read()); + } + + // Reset after read limit passed + try { + reader.reset(); + fail("Read limit exceeded, expected IOException "); + } catch (final IOException e) { + assertEquals("Read limit IOException message", + "Marked position [" + position + + "] is no longer valid - passed the read limit [" + + readlimit + "]", + e.getMessage()); + } + reader.close(); + } + + @Test + public void testMarkNotSupported() throws Exception { + final Reader reader = new TestNullReader(100, false, true); + assertFalse("Mark Should NOT be Supported", reader.markSupported()); + + try { + reader.mark(5); + fail("mark() should throw UnsupportedOperationException"); + } catch (final UnsupportedOperationException e) { + assertEquals("mark() error message", "Mark not supported", e.getMessage()); + } + + try { + reader.reset(); + fail("reset() should throw UnsupportedOperationException"); + } catch (final UnsupportedOperationException e) { + assertEquals("reset() error message", "Mark not supported", e.getMessage()); + } + reader.close(); + } + + @Test + public void testSkip() throws Exception { + final Reader reader = new TestNullReader(10, true, false); + assertEquals("Read 1", 0, reader.read()); + assertEquals("Read 2", 1, reader.read()); + assertEquals("Skip 1", 5, reader.skip(5)); + assertEquals("Read 3", 7, reader.read()); + assertEquals("Skip 2", 2, reader.skip(5)); // only 2 left to skip + assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); // End of file + try { + reader.skip(5); // + fail("Expected IOException for skipping after end of file"); + } catch (final IOException e) { + assertEquals("Skip after EOF IOException message", + "Skip after end of file", + e.getMessage()); + } + reader.close(); + } + + + // ------------- Test NullReader implementation ------------- + + private static final class TestNullReader extends NullReader { + public TestNullReader(final int size) { + super(size); + } + public TestNullReader(final int size, final boolean markSupported, final boolean throwEofException) { + super(size, markSupported, throwEofException); + } + @Override + protected int processChar() { + return (int)getPosition() - 1; + } + @Override + protected void processChars(final char[] chars, final int offset, final int length) { + final int startPos = (int)getPosition() - length; + for (int i = offset; i < length; i++) { + chars[i] = (char)(startPos + i); + } + } + + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..68ca2ddaecd40f2829e23c4a0056b58b2bbd8a5e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java" @@ -0,0 +1,87 @@ +/* + * 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.input; + +import org.junit.Test; + +import java.io.IOException; +import java.io.Reader; +import java.nio.CharBuffer; + +import static org.junit.Assert.fail; + +/** + * Test {@link ProxyReader}. + * + * @version $Id: ProxyReaderTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class ProxyReaderTest { + + @Test + public void testNullCharArray() throws Exception { + + final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0)); + + try { + proxy.read((char[])null); + } catch(final Exception e) { + fail("Writing null String threw " + e); + } + + try { + proxy.read(null, 0, 0); + } catch(final Exception e) { + fail("Writing null String threw " + e); + } + proxy.close(); + } + + @Test + public void testNullCharBuffer() throws Exception { + + final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0)); + + try { + proxy.read((CharBuffer)null); + } catch(final Exception e) { + fail("Writing null String threw " + e); + } + proxy.close(); + } + + /** ProxyReader implementation */ + private static class ProxyReaderImpl extends ProxyReader { + ProxyReaderImpl(final Reader proxy) { + super(proxy); + } + } + + /** Custom NullReader implementation */ + private static class CustomNullReader extends NullReader { + CustomNullReader(final int len) { + super(len); + } + @Override + public int read(final char[] chars) throws IOException { + return chars == null ? 0 : super.read(chars); + } + @Override + public int read(final CharBuffer target) throws IOException { + return target == null ? 0 : super.read(target); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..efe3bb46ec0a76c0645380808d46baddf223b448 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java" @@ -0,0 +1,151 @@ +/* + * 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.input; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.CharArrayReader; +import java.io.IOException; +import java.io.StringReader; +import java.nio.charset.Charset; +import java.util.Random; + +import org.junit.Test; + +public class ReaderInputStreamTest { + private static final String TEST_STRING = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre"; + private static final String LARGE_TEST_STRING; + + static { + final StringBuilder buffer = new StringBuilder(); + for (int i=0; i<100; i++) { + buffer.append(TEST_STRING); + } + LARGE_TEST_STRING = buffer.toString(); + } + + private final Random random = new Random(); + + private void testWithSingleByteRead(final String testString, final String charsetName) throws IOException { + final byte[] bytes = testString.getBytes(charsetName); + final ReaderInputStream in = new ReaderInputStream(new StringReader(testString), charsetName); + for (final byte b : bytes) { + final int read = in.read(); + assertTrue(read >= 0); + assertTrue(read <= 255); + assertEquals(b, (byte)read); + } + assertEquals(-1, in.read()); + in.close(); + } + + private void testWithBufferedRead(final String testString, final String charsetName) throws IOException { + final byte[] expected = testString.getBytes(charsetName); + final ReaderInputStream in = new ReaderInputStream(new StringReader(testString), charsetName); + final byte[] buffer = new byte[128]; + int offset = 0; + while (true) { + int bufferOffset = random.nextInt(64); + final int bufferLength = random.nextInt(64); + int read = in.read(buffer, bufferOffset, bufferLength); + if (read == -1) { + assertEquals(offset, expected.length); + break; + } else { + assertTrue(read <= bufferLength); + while (read > 0) { + assertTrue(offset < expected.length); + assertEquals(expected[offset], buffer[bufferOffset]); + offset++; + bufferOffset++; + read--; + } + } + } + in.close(); + } + + @Test + public void testUTF8WithSingleByteRead() throws IOException { + testWithSingleByteRead(TEST_STRING, "UTF-8"); + } + + @Test + public void testLargeUTF8WithSingleByteRead() throws IOException { + testWithSingleByteRead(LARGE_TEST_STRING, "UTF-8"); + } + + @Test + public void testUTF8WithBufferedRead() throws IOException { + testWithBufferedRead(TEST_STRING, "UTF-8"); + } + + @Test + public void testLargeUTF8WithBufferedRead() throws IOException { + testWithBufferedRead(LARGE_TEST_STRING, "UTF-8"); + } + + @Test + public void testUTF16WithSingleByteRead() throws IOException { + testWithSingleByteRead(TEST_STRING, "UTF-16"); + } + + @SuppressWarnings("deprecation") + @Test + public void testReadZero() throws Exception { + final String inStr = "test"; + final ReaderInputStream r = new ReaderInputStream(new StringReader(inStr)); + final byte[] bytes = new byte[30]; + assertEquals(0, r.read(bytes, 0, 0)); + assertEquals(inStr.length(), r.read(bytes, 0, inStr.length()+1)); + // Should always return 0 for length == 0 + assertEquals(0, r.read(bytes, 0, 0)); + r.close(); + } + + @SuppressWarnings("deprecation") + @Test + public void testReadZeroEmptyString() throws Exception { + final ReaderInputStream r = new ReaderInputStream(new StringReader("")); + final byte[] bytes = new byte[30]; + // Should always return 0 for length == 0 + assertEquals(0, r.read(bytes, 0, 0)); + assertEquals(-1, r.read(bytes, 0, 1)); + assertEquals(0, r.read(bytes, 0, 0)); + assertEquals(-1, r.read(bytes, 0, 1)); + r.close(); + } + + /* + * Tests https://issues.apache.org/jira/browse/IO-277 + */ + @Test + public void testCharsetMismatchInfiniteLoop() throws IOException { + // Input is UTF-8 bytes: 0xE0 0xB2 0xA0 + final char[] inputChars = new char[] { (char) 0xE0, (char) 0xB2, (char) 0xA0 }; + // Charset charset = Charset.forName("UTF-8"); // works + final Charset charset = Charset.forName("ASCII"); // infinite loop + final ReaderInputStream stream = new ReaderInputStream(new CharArrayReader(inputChars), charset); + try { + while (stream.read() != -1) { + } + } finally { + stream.close(); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java" new file mode 100644 index 0000000000000000000000000000000000000000..93d6fc43d8ef419e514afd2a0ac9e689faa1601a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamBlockSize.java" @@ -0,0 +1,236 @@ +/* + * 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.input; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.Collection; + +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class ReversedLinesFileReaderTestParamBlockSize { + + private static final String UTF_8 = "UTF-8"; + private static final String ISO_8859_1 = "ISO-8859-1"; + + @SuppressWarnings("boxing") + // small and uneven block sizes are not used in reality but are good to show that the algorithm is solid + @Parameters(name = "BlockSize={0}") + public static Collection blockSizes() { + return Arrays.asList(new Integer[][]{{1}, {3}, {8}, {256}, {4096}}); + } + + private ReversedLinesFileReader reversedLinesFileReader; + private final int testParamBlockSize; + + public ReversedLinesFileReaderTestParamBlockSize(final Integer testWithBlockSize) { + testParamBlockSize = testWithBlockSize; + } + + // Strings are escaped in constants to avoid java source encoding issues (source file enc is UTF-8): + + // "A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²®" + private static final String TEST_LINE = "A Test Line. Special chars: \u00C4\u00E4\u00DC\u00FC\u00D6\u00F6\u00DF \u00C3\u00E1\u00E9\u00ED\u00EF\u00E7\u00F1\u00C2 \u00A9\u00B5\u00A5\u00A3\u00B1\u00B2\u00AE"; + // Hiragana letters: ����� + private static final String TEST_LINE_SHIFT_JIS1 = "Hiragana letters: \u3041\u3042\u3043\u3044\u3045"; + // Kanji letters: 明輸�京 + private static final String TEST_LINE_SHIFT_JIS2 = "Kanji letters: \u660E\u8F38\u5B50\u4EAC"; + // windows-31j characters + private static final String TEST_LINE_WINDOWS_31J_1 = "\u3041\u3042\u3043\u3044\u3045"; + private static final String TEST_LINE_WINDOWS_31J_2 = "\u660E\u8F38\u5B50\u4EAC"; + // gbk characters (Simplified Chinese) + private static final String TEST_LINE_GBK_1 = "\u660E\u8F38\u5B50\u4EAC"; + private static final String TEST_LINE_GBK_2 = "\u7B80\u4F53\u4E2D\u6587"; + // x-windows-949 characters (Korean) + private static final String TEST_LINE_X_WINDOWS_949_1 = "\uD55C\uAD6D\uC5B4"; + private static final String TEST_LINE_X_WINDOWS_949_2 = "\uB300\uD55C\uBBFC\uAD6D"; + // x-windows-950 characters (Traditional Chinese) + private static final String TEST_LINE_X_WINDOWS_950_1 = "\u660E\u8F38\u5B50\u4EAC"; + private static final String TEST_LINE_X_WINDOWS_950_2 = "\u7E41\u9AD4\u4E2D\u6587"; + + + @After + public void closeReader() { + try { + reversedLinesFileReader.close(); + } catch (final Exception e) { + // ignore + } + } + + @Test + public void testIsoFileDefaults() throws URISyntaxException, IOException { + final File testFileIso = new File(this.getClass().getResource("/test-file-iso8859-1.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, ISO_8859_1); + assertFileWithShrinkingTestLines(reversedLinesFileReader); + } + + @Test + public void testUTF8FileWindowsBreaks() throws URISyntaxException, IOException { + final File testFileIso = new File(this.getClass().getResource("/test-file-utf8-win-linebr.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8); + assertFileWithShrinkingTestLines(reversedLinesFileReader); + } + + @Test + public void testUTF8FileCRBreaks() throws URISyntaxException, IOException { + final File testFileIso = new File(this.getClass().getResource("/test-file-utf8-cr-only.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8); + assertFileWithShrinkingTestLines(reversedLinesFileReader); + } + + @Test + public void testUTF8File() throws URISyntaxException, IOException { + final File testFileIso = new File(this.getClass().getResource("/test-file-utf8.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, UTF_8); + assertFileWithShrinkingTestLines(reversedLinesFileReader); + } + + @Test + public void testEmptyFile() throws URISyntaxException, IOException { + final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileEmpty, testParamBlockSize, UTF_8); + assertNull(reversedLinesFileReader.readLine()); + } + + @Test + public void testUTF16BEFile() throws URISyntaxException, IOException { + final File testFileUTF16BE = new File(this.getClass().getResource("/test-file-utf16be.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileUTF16BE, testParamBlockSize, "UTF-16BE"); + assertFileWithShrinkingTestLines(reversedLinesFileReader); + } + + @Test + public void testUTF16LEFile() throws URISyntaxException, IOException { + final File testFileUTF16LE = new File(this.getClass().getResource("/test-file-utf16le.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileUTF16LE, testParamBlockSize, "UTF-16LE"); + assertFileWithShrinkingTestLines(reversedLinesFileReader); + } + + @Test + public void testShiftJISFile() throws URISyntaxException, IOException { + final File testFileShiftJIS = new File(this.getClass().getResource("/test-file-shiftjis.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileShiftJIS, testParamBlockSize, "Shift_JIS"); + assertEqualsAndNoLineBreaks(TEST_LINE_SHIFT_JIS2, reversedLinesFileReader.readLine()); + assertEqualsAndNoLineBreaks(TEST_LINE_SHIFT_JIS1, reversedLinesFileReader.readLine()); + } + + @Test + public void testWindows31jFile() throws URISyntaxException, IOException { + final File testFileWindows31J = new File(this.getClass().getResource("/test-file-windows-31j.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileWindows31J, testParamBlockSize, "windows-31j"); + assertEqualsAndNoLineBreaks(TEST_LINE_WINDOWS_31J_2, reversedLinesFileReader.readLine()); + assertEqualsAndNoLineBreaks(TEST_LINE_WINDOWS_31J_1, reversedLinesFileReader.readLine()); + } + + @Test + public void testGBK() throws URISyntaxException, IOException { + final File testFileGBK = new File(this.getClass().getResource("/test-file-gbk.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileGBK, testParamBlockSize, "GBK"); + assertEqualsAndNoLineBreaks(TEST_LINE_GBK_2, reversedLinesFileReader.readLine()); + assertEqualsAndNoLineBreaks(TEST_LINE_GBK_1, reversedLinesFileReader.readLine()); + } + + @Test + public void testxWindows949File() throws URISyntaxException, IOException { + final File testFilexWindows949 = new File(this.getClass().getResource("/test-file-x-windows-949.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFilexWindows949, testParamBlockSize, "x-windows-949"); + assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_949_2, reversedLinesFileReader.readLine()); + assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_949_1, reversedLinesFileReader.readLine()); + } + + @Test + public void testxWindows950File() throws URISyntaxException, IOException { + final File testFilexWindows950 = new File(this.getClass().getResource("/test-file-x-windows-950.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFilexWindows950, testParamBlockSize, "x-windows-950"); + assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_950_2, reversedLinesFileReader.readLine()); + assertEqualsAndNoLineBreaks(TEST_LINE_X_WINDOWS_950_1, reversedLinesFileReader.readLine()); + } + + @Test // this test is run 3x for same block size as we want to test with 10 + public void testFileSizeIsExactMultipleOfBlockSize() throws URISyntaxException, IOException { + final int blockSize = 10; + final File testFile20Bytes = new File(this.getClass().getResource("/test-file-20byteslength.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize, ISO_8859_1); + final String testLine = "123456789"; + assertEqualsAndNoLineBreaks(testLine, reversedLinesFileReader.readLine()); + assertEqualsAndNoLineBreaks(testLine, reversedLinesFileReader.readLine()); + } + + @Test + public void testUTF8FileWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines() throws URISyntaxException, IOException { + final File testFileUtf8 = new File(this.getClass().getResource("/test-file-utf8-win-linebr.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileUtf8, testParamBlockSize, UTF_8); + assertFileWithShrinkingTestLines(reversedLinesFileReader); + } + + @Test + public void testIsoFileManyWindowsBreaksSmallBlockSize2VerifyBlockSpanningNewLines() throws URISyntaxException, IOException { + final File testFileIso = new File(this.getClass().getResource("/test-file-iso8859-1-shortlines-win-linebr.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, testParamBlockSize, ISO_8859_1); + + for (int i = 3; i > 0; i--) { + for (int j = 1; j <= 3; j++) { + assertEqualsAndNoLineBreaks("", reversedLinesFileReader.readLine()); + } + assertEqualsAndNoLineBreaks("" + i, reversedLinesFileReader.readLine()); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void testUnsupportedEncodingUTF16() throws URISyntaxException, IOException { + final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); + new ReversedLinesFileReader(testFileEmpty, testParamBlockSize, "UTF-16").close(); + } + + @Test(expected = UnsupportedEncodingException.class) + public void testUnsupportedEncodingBig5() throws URISyntaxException, IOException { + final File testFileEncodingBig5 = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); + new ReversedLinesFileReader(testFileEncodingBig5, testParamBlockSize, "Big5").close(); + } + + private void assertFileWithShrinkingTestLines(final ReversedLinesFileReader reversedLinesFileReader) throws IOException { + String line = null; + int lineCount = 0; + while ((line = reversedLinesFileReader.readLine()) != null) { + lineCount++; + assertEqualsAndNoLineBreaks("Line " + lineCount + " is not matching", TEST_LINE.substring(0, lineCount), line); + } + } + + static void assertEqualsAndNoLineBreaks(final String msg, final String expected, final String actual) { + if (actual != null) { + assertFalse("Line contains \\n: line=" + actual, actual.contains("\n")); + assertFalse("Line contains \\r: line=" + actual, actual.contains("\r")); + } + assertEquals(msg, expected, actual); + } + + static void assertEqualsAndNoLineBreaks(final String expected, final String actual) { + assertEqualsAndNoLineBreaks(null, expected, actual); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java" new file mode 100644 index 0000000000000000000000000000000000000000..6950c47b6d9f9d03d1d7c3792fde0f04d1472ba1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestParamFile.java" @@ -0,0 +1,118 @@ +/* + * 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.input; + + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Stack; + +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * Test checks symmetric behaviour with BufferedReader + */ +@RunWith(Parameterized.class) +public class ReversedLinesFileReaderTestParamFile { + + @Parameters(name = "{0}, charset={1}") + public static Collection blockSizes() { + return Arrays.asList(new Object[][]{ + {"test-file-20byteslength.bin", "ISO_8859_1", null}, + {"test-file-iso8859-1-shortlines-win-linebr.bin", "ISO_8859_1", null}, + {"test-file-iso8859-1.bin", "ISO_8859_1", null}, + {"test-file-shiftjis.bin", "Shift_JIS", null}, + {"test-file-utf16be.bin", "UTF-16BE", null}, + {"test-file-utf16le.bin", "UTF-16LE", null}, + {"test-file-utf8-cr-only.bin", "UTF-8", null}, + {"test-file-utf8-win-linebr.bin", "UTF-8", null}, + {"test-file-utf8-win-linebr.bin", "UTF-8", 1}, + {"test-file-utf8-win-linebr.bin", "UTF-8", 2}, + {"test-file-utf8-win-linebr.bin", "UTF-8", 3}, + {"test-file-utf8-win-linebr.bin", "UTF-8", 4}, + {"test-file-utf8.bin", "UTF-8", null}, + {"test-file-windows-31j.bin", "windows-31j", null}, + {"test-file-gbk.bin", "gbk", null}, + {"test-file-x-windows-949.bin", "x-windows-949", null}, + {"test-file-x-windows-950.bin", "x-windows-950", null}, + }); + } + + private ReversedLinesFileReader reversedLinesFileReader; + private BufferedReader bufferedReader; + + private final String fileName; + private final String encoding; + private final int buffSize; + + public ReversedLinesFileReaderTestParamFile(final String fileName, final String encoding, final Integer buffsize) { + this.fileName = fileName; + this.encoding = encoding; + this.buffSize = buffsize == null ? 4096 : buffsize; + } + + @Test + public void testDataIntegrityWithBufferedReader() throws URISyntaxException, IOException { + final File testFileIso = new File(this.getClass().getResource("/" + fileName).toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFileIso, buffSize, encoding); + + final Stack lineStack = new Stack(); + + bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(testFileIso), encoding)); + String line = null; + + // read all lines in normal order + while ((line = bufferedReader.readLine()) != null) { + lineStack.push(line); + } + + // read in reverse order and compare with lines from stack + while ((line = reversedLinesFileReader.readLine()) != null) { + final String lineFromBufferedReader = lineStack.pop(); + assertEquals(lineFromBufferedReader, line); + } + + } + + @After + public void closeReader() { + try { + bufferedReader.close(); + } catch (final Exception e) { + // ignore + } + try { + reversedLinesFileReader.close(); + } catch (final Exception e) { + // ignore + } + } + + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java" new file mode 100644 index 0000000000000000000000000000000000000000..1ee222c5b58fdb24322d8b7b6ebffc637812a4e8 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java" @@ -0,0 +1,67 @@ +/* + * 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.input; + +import static org.apache.commons.io.input.ReversedLinesFileReaderTestParamBlockSize.assertEqualsAndNoLineBreaks; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URISyntaxException; + +import org.junit.After; +import org.junit.Test; + + +public class ReversedLinesFileReaderTestSimple { + + private ReversedLinesFileReader reversedLinesFileReader; + + @After + public void closeReader() { + try { + reversedLinesFileReader.close(); + } catch(final Exception e) { + // ignore + } + } + + @Test + public void testFileSizeIsExactMultipleOfBlockSize() throws URISyntaxException, IOException { + final int blockSize = 10; + final File testFile20Bytes = new File(this.getClass().getResource("/test-file-20byteslength.bin").toURI()); + reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize, "ISO-8859-1"); + final String testLine = "123456789"; + assertEqualsAndNoLineBreaks(testLine, reversedLinesFileReader.readLine()); + assertEqualsAndNoLineBreaks(testLine, reversedLinesFileReader.readLine()); + } + + @Test(expected=UnsupportedEncodingException.class) + public void testUnsupportedEncodingUTF16() throws URISyntaxException, IOException { + final File testFileEmpty = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); + new ReversedLinesFileReader(testFileEmpty, 4096, "UTF-16").close(); + } + + @Test(expected=UnsupportedEncodingException.class) + public void testUnsupportedEncodingBig5() throws URISyntaxException, IOException { + final File testFileEncodingBig5 = new File(this.getClass().getResource("/test-file-empty.bin").toURI()); + new ReversedLinesFileReader(testFileEncodingBig5, 4096, "Big5").close(); + } + + + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..42e3ff2ee9c0afbb7768e8be9f57ea6a637a5265 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java" @@ -0,0 +1,151 @@ +/* + * 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.input; + + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + + +/** + * Test for the SwappedDataInputStream. This also + * effectively tests the underlying EndianUtils Stream methods. + * + * @version $Id: SwappedDataInputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ + +public class SwappedDataInputStreamTest { + + private SwappedDataInputStream sdis; + private byte[] bytes; + + @Before + public void setUp() { + bytes = new byte[] { + 0x01, + 0x02, + 0x03, + 0x04, + 0x05, + 0x06, + 0x07, + 0x08 + }; + final ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); + this.sdis = new SwappedDataInputStream( bais ); + } + + @After + public void tearDown() { + this.sdis = null; + } + + @Test + public void testReadBoolean() throws IOException { + bytes = new byte[] { + 0x00, + 0x01, + 0x02, + }; + final ByteArrayInputStream bais = new ByteArrayInputStream( bytes ); + final SwappedDataInputStream sdis = new SwappedDataInputStream( bais ); + assertEquals( false, sdis.readBoolean() ); + assertEquals( true, sdis.readBoolean() ); + assertEquals( true, sdis.readBoolean() ); + sdis.close(); + } + + @Test + public void testReadByte() throws IOException { + assertEquals( 0x01, this.sdis.readByte() ); + } + + @Test + public void testReadChar() throws IOException { + assertEquals( (char) 0x0201, this.sdis.readChar() ); + } + + @Test + public void testReadDouble() throws IOException { + assertEquals( Double.longBitsToDouble(0x0807060504030201L), this.sdis.readDouble(), 0 ); + } + + @Test + public void testReadFloat() throws IOException { + assertEquals( Float.intBitsToFloat(0x04030201), this.sdis.readFloat(), 0 ); + } + + @Test + public void testReadFully() throws IOException { + final byte[] bytesIn = new byte[8]; + this.sdis.readFully(bytesIn); + for( int i=0; i<8; i++) { + assertEquals( bytes[i], bytesIn[i] ); + } + } + + @Test + public void testReadInt() throws IOException { + assertEquals( 0x04030201, this.sdis.readInt() ); + } + + @Test(expected = UnsupportedOperationException.class) + public void testReadLine() throws IOException { + this.sdis.readLine(); + fail("readLine should be unsupported. "); + } + + @Test + public void testReadLong() throws IOException { + assertEquals( 0x0807060504030201L, this.sdis.readLong() ); + } + + @Test + public void testReadShort() throws IOException { + assertEquals( (short) 0x0201, this.sdis.readShort() ); + } + + @Test + public void testReadUnsignedByte() throws IOException { + assertEquals( 0x01, this.sdis.readUnsignedByte() ); + } + + @Test + public void testReadUnsignedShort() throws IOException { + assertEquals( (short) 0x0201, this.sdis.readUnsignedShort() ); + } + + @Test(expected = UnsupportedOperationException.class) + public void testReadUTF() throws IOException { + this.sdis.readUTF(); + fail("readUTF should be unsupported. "); + } + + @Test + public void testSkipBytes() throws IOException { + this.sdis.skipBytes(4); + assertEquals( 0x08070605, this.sdis.readInt() ); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..5238c1d91df9230a1c5eb2dcd0239f062acfba0d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java" @@ -0,0 +1,146 @@ +/* + * 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.input; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.UUID; + +import junit.framework.TestCase; + +import org.apache.commons.io.TaggedIOException; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link TaggedInputStream}. + */ +public class TaggedInputStreamTest { + + @Test + public void testEmptyStream() { + try { + final InputStream stream = new TaggedInputStream(new ClosedInputStream()); + assertEquals(0, stream.available()); + assertEquals(-1, stream.read()); + assertEquals(-1, stream.read(new byte[1])); + assertEquals(-1, stream.read(new byte[1], 0, 1)); + stream.close(); + } catch (final IOException e) { + fail("Unexpected exception thrown"); + } + } + + @Test + public void testNormalStream() { + try { + final InputStream stream = new TaggedInputStream( + new ByteArrayInputStream(new byte[] { 'a', 'b', 'c' })); + assertEquals(3, stream.available()); + assertEquals('a', stream.read()); + final byte[] buffer = new byte[1]; + assertEquals(1, stream.read(buffer)); + assertEquals('b', buffer[0]); + assertEquals(1, stream.read(buffer, 0, 1)); + assertEquals('c', buffer[0]); + assertEquals(-1, stream.read()); + stream.close(); + } catch (final IOException e) { + fail("Unexpected exception thrown"); + } + } + + @Test + public void testBrokenStream() { + final IOException exception = new IOException("test exception"); + final TaggedInputStream stream = + new TaggedInputStream(new BrokenInputStream(exception)); + + // Test the available() method + try { + stream.available(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertTrue(stream.isCauseOf(e)); + try { + stream.throwIfCauseOf(e); + fail("Expected exception not thrown."); + } catch (final IOException e2) { + assertEquals(exception, e2); + } + } + + // Test the read() method + try { + stream.read(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertTrue(stream.isCauseOf(e)); + try { + stream.throwIfCauseOf(e); + fail("Expected exception not thrown."); + } catch (final IOException e2) { + assertEquals(exception, e2); + } + } + + // Test the close() method + try { + stream.close(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertTrue(stream.isCauseOf(e)); + try { + stream.throwIfCauseOf(e); + fail("Expected exception not thrown."); + } catch (final IOException e2) { + assertEquals(exception, e2); + } + } + } + + @Test + public void testOtherException() throws Exception { + final IOException exception = new IOException("test exception"); + final InputStream closed = new ClosedInputStream(); + final TaggedInputStream stream = new TaggedInputStream(closed); + + assertFalse(stream.isCauseOf(exception)); + assertFalse(stream.isCauseOf( + new TaggedIOException(exception, UUID.randomUUID()))); + + try { + stream.throwIfCauseOf(exception); + } catch (final IOException e) { + fail("Unexpected exception thrown"); + } + + try { + stream.throwIfCauseOf( + new TaggedIOException(exception, UUID.randomUUID())); + } catch (final IOException e) { + fail("Unexpected exception thrown"); + } + stream.close(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TailerTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TailerTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..db09e75428e443afc8a67b2bc3f6dbc0b8b63553 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TailerTest.java" @@ -0,0 +1,504 @@ +/* + * 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.input; + +import java.io.*; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledThreadPoolExecutor; + +import org.apache.commons.io.Charsets; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.After; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Tests for {@link Tailer}. + * + * @version $Id: TailerTest.java 1721380 2015-12-22 12:13:05Z krosenvold $ + */ +public class TailerTest extends FileBasedTestCase { + + private Tailer tailer; + + @After + public void tearDown() throws Exception { + if (tailer != null) { + tailer.stop(); + TestUtils.sleep(1000); + } + FileUtils.deleteDirectory(getTestDirectory()); + TestUtils.sleep(1000); + } + + @Test + public void testLongFile() throws Exception { + final long delay = 50; + + final File file = new File(getTestDirectory(), "testLongFile.txt"); + createFile(file, 0); + final Writer writer = new FileWriter(file, true); + for (int i = 0; i < 100000; i++) { + writer.write("LineLineLineLineLineLineLineLineLineLine\n"); + } + writer.write("SBTOURIST\n"); + IOUtils.closeQuietly(writer); + + final TestTailerListener listener = new TestTailerListener(); + tailer = new Tailer(file, listener, delay, false); + + final long start = System.currentTimeMillis(); + + final Thread thread = new Thread(tailer); + thread.start(); + + List lines = listener.getLines(); + while (lines.isEmpty() || !lines.get(lines.size() - 1).equals("SBTOURIST")) { + lines = listener.getLines(); + } + System.out.println("Elapsed: " + (System.currentTimeMillis() - start)); + + listener.clear(); + } + + @Test + public void testBufferBreak() throws Exception { + final long delay = 50; + + final File file = new File(getTestDirectory(), "testBufferBreak.txt"); + createFile(file, 0); + writeString(file, "SBTOURIST\n"); + + final TestTailerListener listener = new TestTailerListener(); + tailer = new Tailer(file, listener, delay, false, 1); + + final Thread thread = new Thread(tailer); + thread.start(); + + List lines = listener.getLines(); + while (lines.isEmpty() || !lines.get(lines.size() - 1).equals("SBTOURIST")) { + lines = listener.getLines(); + } + + listener.clear(); + } + + @SuppressWarnings("deprecation") // unavoidable until Java 7 + @Test + public void testMultiByteBreak() throws Exception { + System.out.println("testMultiByteBreak() Default charset: "+Charset.defaultCharset().displayName()); + final long delay = 50; + final File origin = new File(this.getClass().getResource("/test-file-utf8.bin").toURI()); + final File file = new File(getTestDirectory(), "testMultiByteBreak.txt"); + createFile(file, 0); + final TestTailerListener listener = new TestTailerListener(); + final String osname = System.getProperty("os.name"); + final boolean isWindows = osname.startsWith("Windows"); + // Need to use UTF-8 to read & write the file otherwise it can be corrupted (depending on the default charset) + final Charset charsetUTF8 = Charsets.UTF_8; + tailer = new Tailer(file, charsetUTF8, listener, delay, false, isWindows, 4096); + final Thread thread = new Thread(tailer); + thread.start(); + + Writer out = new OutputStreamWriter(new FileOutputStream(file), charsetUTF8); + BufferedReader reader = null; + try{ + List lines = new ArrayList(); + reader = new BufferedReader(new InputStreamReader(new FileInputStream(origin), charsetUTF8)); + String line; + while((line = reader.readLine()) != null){ + out.write(line); + out.write("\n"); + lines.add(line); + } + out.close(); // ensure data is written + + final long testDelayMillis = delay * 10; + TestUtils.sleep(testDelayMillis); + List tailerlines = listener.getLines(); + assertEquals("line count",lines.size(),tailerlines.size()); + for(int i = 0,len = lines.size();i lines = listener.getLines(); + assertEquals("1 line count", 0, lines.size()); + + writeString(file, " one\n"); + TestUtils.sleep(delay * 2); + lines = listener.getLines(); + + assertEquals("1 line count", 1, lines.size()); + assertEquals("1 line 1", "Line one", lines.get(0)); + + listener.clear(); + } finally { + tailer.stop(); + TestUtils.sleep(delay * 2); + IOUtils.closeQuietly(writer); + } + } + + @Test + public void testTailer() throws Exception { + + // Create & start the Tailer + final long delayMillis = 50; + final File file = new File(getTestDirectory(), "tailer1-test.txt"); + createFile(file, 0); + final TestTailerListener listener = new TestTailerListener(); + final String osname = System.getProperty("os.name"); + final boolean isWindows = osname.startsWith("Windows"); + tailer = new Tailer(file, listener, delayMillis, false, isWindows); + final Thread thread = new Thread(tailer); + thread.start(); + + // Write some lines to the file + write(file, "Line one", "Line two"); + final long testDelayMillis = delayMillis * 10; + TestUtils.sleep(testDelayMillis); + List lines = listener.getLines(); + assertEquals("1 line count", 2, lines.size()); + assertEquals("1 line 1", "Line one", lines.get(0)); + assertEquals("1 line 2", "Line two", lines.get(1)); + listener.clear(); + + // Write another line to the file + write(file, "Line three"); + TestUtils.sleep(testDelayMillis); + lines = listener.getLines(); + assertEquals("2 line count", 1, lines.size()); + assertEquals("2 line 3", "Line three", lines.get(0)); + listener.clear(); + + // Check file does actually have all the lines + lines = FileUtils.readLines(file, "UTF-8"); + assertEquals("3 line count", 3, lines.size()); + assertEquals("3 line 1", "Line one", lines.get(0)); + assertEquals("3 line 2", "Line two", lines.get(1)); + assertEquals("3 line 3", "Line three", lines.get(2)); + + // Delete & re-create + file.delete(); + final boolean exists = file.exists(); + assertFalse("File should not exist", exists); + createFile(file, 0); + TestUtils.sleep(testDelayMillis); + + // Write another line + write(file, "Line four"); + TestUtils.sleep(testDelayMillis); + lines = listener.getLines(); + assertEquals("4 line count", 1, lines.size()); + assertEquals("4 line 3", "Line four", lines.get(0)); + listener.clear(); + + // Stop + thread.interrupt(); + TestUtils.sleep(testDelayMillis * 4); + write(file, "Line five"); + assertEquals("4 line count", 0, listener.getLines().size()); + assertNotNull("Missing InterruptedException", listener.exception); + assertTrue("Unexpected Exception: " + listener.exception, listener.exception instanceof InterruptedException); + assertEquals("Expected init to be called", 1 , listener.initialised); + assertEquals("fileNotFound should not be called", 0 , listener.notFound); + assertEquals("fileRotated should be be called", 1 , listener.rotated); + tailer.stop(); + tailer=null; + + } + + @Test + public void testTailerEndOfFileReached() throws Exception { + // Create & start the Tailer + final long delayMillis = 50; + final long testDelayMillis = delayMillis * 10; + final File file = new File(getTestDirectory(), "tailer-eof-test.txt"); + createFile(file, 0); + final TestTailerListener listener = new TestTailerListener(); + final String osname = System.getProperty("os.name"); + final boolean isWindows = osname.startsWith("Windows"); + tailer = new Tailer(file, listener, delayMillis, false, isWindows); + final Thread thread = new Thread(tailer); + thread.start(); + + // write a few lines + write(file, "line1", "line2", "line3"); + TestUtils.sleep(testDelayMillis); + + // write a few lines + write(file, "line4", "line5", "line6"); + TestUtils.sleep(testDelayMillis); + + // write a few lines + write(file, "line7", "line8", "line9"); + TestUtils.sleep(testDelayMillis); + + // May be > 3 times due to underlying OS behaviour wrt streams + assertTrue("end of file reached at least 3 times", listener.reachedEndOfFile >= 3); + } + + protected void createFile(final File file, final long size) + throws IOException { + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new FileOutputStream(file)); + try { + TestUtils.generateTestData(output, size); + } finally { + IOUtils.closeQuietly(output); + } + + // try to make sure file is found + // (to stop continuum occasionally failing) + RandomAccessFile reader = null; + try { + while (reader == null) { + try { + reader = new RandomAccessFile(file.getPath(), "r"); + } catch (final FileNotFoundException ignore) { + } + try { + TestUtils.sleep(200L); + } catch (final InterruptedException ignore) { + // ignore + } + } + } finally { + IOUtils.closeQuietly(reader); + } + } + + /** Append some lines to a file */ + private void write(final File file, final String... lines) throws Exception { + FileWriter writer = null; + try { + writer = new FileWriter(file, true); + for (final String line : lines) { + writer.write(line + "\n"); + } + } finally { + IOUtils.closeQuietly(writer); + } + } + + /** Append a string to a file */ + private void writeString(final File file, final String ... strings) throws Exception { + FileWriter writer = null; + try { + writer = new FileWriter(file, true); + for (final String string : strings) { + writer.write(string); + } + } finally { + IOUtils.closeQuietly(writer); + } + } + + + @Test + public void testStopWithNoFile() throws Exception { + final File file = new File(getTestDirectory(),"nosuchfile"); + assertFalse("nosuchfile should not exist", file.exists()); + final TestTailerListener listener = new TestTailerListener(); + final int delay = 100; + final int idle = 50; // allow time for thread to work + tailer = Tailer.create(file, listener, delay, false); + TestUtils.sleep(idle); + tailer.stop(); + tailer=null; + TestUtils.sleep(delay+idle); + assertNull("Should not generate Exception", listener.exception); + assertEquals("Expected init to be called", 1 , listener.initialised); + assertTrue("fileNotFound should be called", listener.notFound > 0); + assertEquals("fileRotated should be not be called", 0 , listener.rotated); + assertEquals("end of file never reached", 0, listener.reachedEndOfFile); + } + + /* + * Tests [IO-357][Tailer] InterruptedException while the thead is sleeping is silently ignored. + */ + @Test + public void testInterrupt() throws Exception { + final File file = new File(getTestDirectory(), "nosuchfile"); + assertFalse("nosuchfile should not exist", file.exists()); + final TestTailerListener listener = new TestTailerListener(); + // Use a long delay to try to make sure the test thread calls interrupt() while the tailer thread is sleeping. + final int delay = 1000; + final int idle = 50; // allow time for thread to work + Tailer tailer = new Tailer(file, listener, delay, false, 4096); + final Thread thread = new Thread(tailer); + thread.setDaemon(true); + thread.start(); + TestUtils.sleep(idle); + thread.interrupt(); + tailer = null; + TestUtils.sleep(delay + idle); + assertNotNull("Missing InterruptedException", listener.exception); + assertTrue("Unexpected Exception: " + listener.exception, listener.exception instanceof InterruptedException); + assertEquals("Expected init to be called", 1, listener.initialised); + assertTrue("fileNotFound should be called", listener.notFound > 0); + assertEquals("fileRotated should be not be called", 0, listener.rotated); + assertEquals("end of file never reached", 0, listener.reachedEndOfFile); + } + + @Test + public void testStopWithNoFileUsingExecutor() throws Exception { + final File file = new File(getTestDirectory(),"nosuchfile"); + assertFalse("nosuchfile should not exist", file.exists()); + final TestTailerListener listener = new TestTailerListener(); + final int delay = 100; + final int idle = 50; // allow time for thread to work + tailer = new Tailer(file, listener, delay, false); + final Executor exec = new ScheduledThreadPoolExecutor(1); + exec.execute(tailer); + TestUtils.sleep(idle); + tailer.stop(); + tailer=null; + TestUtils.sleep(delay+idle); + assertNull("Should not generate Exception", listener.exception); + assertEquals("Expected init to be called", 1 , listener.initialised); + assertTrue("fileNotFound should be called", listener.notFound > 0); + assertEquals("fileRotated should be not be called", 0 , listener.rotated); + assertEquals("end of file never reached", 0, listener.reachedEndOfFile); + } + + @Test + public void testIO335() throws Exception { // test CR behaviour + // Create & start the Tailer + final long delayMillis = 50; + final File file = new File(getTestDirectory(), "tailer-testio334.txt"); + createFile(file, 0); + final TestTailerListener listener = new TestTailerListener(); + tailer = new Tailer(file, listener, delayMillis, false); + final Thread thread = new Thread(tailer); + thread.start(); + + // Write some lines to the file + writeString(file, "CRLF\r\n", "LF\n", "CR\r", "CRCR\r\r", "trail"); + final long testDelayMillis = delayMillis * 10; + TestUtils.sleep(testDelayMillis); + final List lines = listener.getLines(); + assertEquals("line count", 4, lines.size()); + assertEquals("line 1", "CRLF", lines.get(0)); + assertEquals("line 2", "LF", lines.get(1)); + assertEquals("line 3", "CR", lines.get(2)); + assertEquals("line 4", "CRCR\r", lines.get(3)); + + // Stop + tailer.stop(); + tailer=null; + thread.interrupt(); + TestUtils.sleep(testDelayMillis); + } + + /** + * Test {@link TailerListener} implementation. + */ + private static class TestTailerListener extends TailerListenerAdapter { + + // Must be synchronised because it is written by one thread and read by another + private final List lines = Collections.synchronizedList(new ArrayList()); + + volatile Exception exception = null; + + volatile int notFound = 0; + + volatile int rotated = 0; + + volatile int initialised = 0; + + volatile int reachedEndOfFile = 0; + + public void handle(final String line) { + lines.add(line); + } + + public List getLines() { + return lines; + } + + public void clear() { + lines.clear(); + } + + public void handle(final Exception e) { + exception = e; + } + + public void init(final Tailer tailer) { + initialised++; // not atomic, but OK because only updated here. + } + + public void fileNotFound() { + notFound++; // not atomic, but OK because only updated here. + } + + public void fileRotated() { + rotated++; // not atomic, but OK because only updated here. + } + + public void endOfFileReached() { + reachedEndOfFile++; // not atomic, but OK because only updated here. + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TeeInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TeeInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..bd0da4918db37876280ddf25f1af7e21f729438b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/TeeInputStreamTest.java" @@ -0,0 +1,110 @@ +/* + * 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.input; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; + +import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * JUnit Test Case for {@link TeeInputStream}. + */ +public class TeeInputStreamTest { + + private final String ASCII = "US-ASCII"; + + private InputStream tee; + + private ByteArrayOutputStream output; + + @Before + public void setUp() throws Exception { + final InputStream input = new ByteArrayInputStream("abc".getBytes(ASCII)); + output = new ByteArrayOutputStream(); + tee = new TeeInputStream(input, output); + } + + @Test + public void testReadNothing() throws Exception { + assertEquals("", new String(output.toString(ASCII))); + } + + @Test + public void testReadOneByte() throws Exception { + assertEquals('a', tee.read()); + assertEquals("a", new String(output.toString(ASCII))); + } + + @Test + public void testReadEverything() throws Exception { + assertEquals('a', tee.read()); + assertEquals('b', tee.read()); + assertEquals('c', tee.read()); + assertEquals(-1, tee.read()); + assertEquals("abc", new String(output.toString(ASCII))); + } + + @Test + public void testReadToArray() throws Exception { + final byte[] buffer = new byte[8]; + assertEquals(3, tee.read(buffer)); + assertEquals('a', buffer[0]); + assertEquals('b', buffer[1]); + assertEquals('c', buffer[2]); + assertEquals(-1, tee.read(buffer)); + assertEquals("abc", new String(output.toString(ASCII))); + } + + @Test + public void testReadToArrayWithOffset() throws Exception { + final byte[] buffer = new byte[8]; + assertEquals(3, tee.read(buffer, 4, 4)); + assertEquals('a', buffer[4]); + assertEquals('b', buffer[5]); + assertEquals('c', buffer[6]); + assertEquals(-1, tee.read(buffer, 4, 4)); + assertEquals("abc", new String(output.toString(ASCII))); + } + + @Test + public void testSkip() throws Exception { + assertEquals('a', tee.read()); + assertEquals(1, tee.skip(1)); + assertEquals('c', tee.read()); + assertEquals(-1, tee.read()); + assertEquals("ac", new String(output.toString(ASCII))); + } + + @Test + public void testMarkReset() throws Exception { + assertEquals('a', tee.read()); + tee.mark(1); + assertEquals('b', tee.read()); + tee.reset(); + assertEquals('b', tee.read()); + assertEquals('c', tee.read()); + assertEquals(-1, tee.read()); + assertEquals("abbc", new String(output.toString(ASCII))); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..e3e0098c7e88fe949647a5230064d8e9fce1eeef --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/UnixLineEndingInputStreamTest.java" @@ -0,0 +1,88 @@ +/* + * 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.input; + +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + +public class UnixLineEndingInputStreamTest +{ + + @Test + public void simpleString() throws Exception { + assertEquals( "abc\n", roundtrip( "abc" ) ); + } + + @Test + public void inTheMiddleOfTheLine() throws Exception { + assertEquals( "a\nbc\n", roundtrip( "a\r\nbc" ) ); + } + + @Test + public void multipleBlankLines() throws Exception { + assertEquals( "a\n\nbc\n", roundtrip( "a\r\n\r\nbc" ) ); + } + + @Test + public void twoLinesAtEnd() throws Exception { + assertEquals( "a\n\n", roundtrip( "a\r\n\r\n" ) ); + } + + @Test + public void crOnlyEnsureAtEof() + throws Exception + { + assertEquals( "a\nb\n", roundtrip( "a\rb" ) ); + } + + @Test + public void crOnlyNotAtEof() + throws Exception + { + assertEquals( "a\nb", roundtrip( "a\rb", false ) ); + } + + @Test + public void crAtEnd() throws Exception { + assertEquals( "a\n", roundtrip( "a\r" ) ); + } + + + @Test + public void retainLineFeed() throws Exception { + assertEquals( "a\n\n", roundtrip( "a\r\n\r\n", false ) ); + assertEquals( "a", roundtrip( "a", false ) ); + } + + private String roundtrip( String msg ) throws IOException { + return roundtrip( msg, true ); + } + + private String roundtrip( String msg, boolean ensure ) throws IOException { + ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes( "UTF-8" ) ); + UnixLineEndingInputStream lf = new UnixLineEndingInputStream( baos, ensure ); + byte[] buf = new byte[100]; + final int read = lf.read( buf ); + lf.close(); + return new String( buf, 0, read, "UTF-8" ); + } + +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..52bd2197de01f8c0cfc4f6663f2ee891f3c81ff6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java" @@ -0,0 +1,77 @@ +/* + * 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.input; + +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + +public class WindowsLineEndingInputStreamTest { + @Test + public void simpleString() throws Exception { + assertEquals( "abc\r\n", roundtrip( "abc" ) ); + } + + @Test + public void inTheMiddleOfTheLine() throws Exception { + assertEquals( "a\r\nbc\r\n", roundtrip( "a\r\nbc" ) ); + } + + @Test + public void multipleBlankLines() throws Exception { + assertEquals( "a\r\n\r\nbc\r\n", roundtrip( "a\r\n\r\nbc" ) ); + } + + @Test + public void twoLinesAtEnd() throws Exception { + assertEquals( "a\r\n\r\n", roundtrip( "a\r\n\r\n" ) ); + } + + @Test + public void linuxLinefeeds() throws Exception { + final String roundtrip = roundtrip( "ab\nc", false ); + assertEquals( "ab\r\nc", roundtrip ); + } + + + @Test + public void malformed() throws Exception { + assertEquals( "a\rbc", roundtrip( "a\rbc", false ) ); + } + + @Test + public void retainLineFeed() throws Exception { + assertEquals( "a\r\n\r\n", roundtrip( "a\r\n\r\n", false ) ); + assertEquals( "a", roundtrip( "a", false ) ); + } + + private String roundtrip( String msg ) throws IOException { + return roundtrip( msg, true ); + } + + private String roundtrip( String msg, boolean ensure ) throws IOException { + ByteArrayInputStream baos = new ByteArrayInputStream( msg.getBytes( "UTF-8" ) ); + WindowsLineEndingInputStream lf = new WindowsLineEndingInputStream( baos, ensure ); + byte[] buf = new byte[100]; + final int read = lf.read( buf ); + lf.close(); + return new String( buf, 0, read, "UTF-8" ); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..4bd671314f8897fa9dde250d80bd2759da5fa117 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java" @@ -0,0 +1,462 @@ +/* + * 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.input; + +import static org.junit.Assert.*; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +public class XmlStreamReaderTest { + private static final String XML5 = "xml-prolog-encoding-spaced-single-quotes"; + private static final String XML4 = "xml-prolog-encoding-single-quotes"; + private static final String XML3 = "xml-prolog-encoding-double-quotes"; + private static final String XML2 = "xml-prolog"; + private static final String XML1 = "xml"; + + protected void _testRawNoBomValid(final String encoding) throws Exception { + InputStream is = getXmlStream("no-bom", XML1, encoding, encoding); + XmlStreamReader xmlReader = new XmlStreamReader(is, false); + assertEquals(xmlReader.getEncoding(), "UTF-8"); + xmlReader.close(); + + is = getXmlStream("no-bom", XML2, encoding, encoding); + xmlReader = new XmlStreamReader(is); + assertEquals(xmlReader.getEncoding(), "UTF-8"); + xmlReader.close(); + + is = getXmlStream("no-bom", XML3, encoding, encoding); + xmlReader = new XmlStreamReader(is); + assertEquals(xmlReader.getEncoding(), encoding); + xmlReader.close(); + + is = getXmlStream("no-bom", XML4, encoding, encoding); + xmlReader = new XmlStreamReader(is); + assertEquals(xmlReader.getEncoding(), encoding); + xmlReader.close(); + + is = getXmlStream("no-bom", XML5, encoding, encoding); + xmlReader = new XmlStreamReader(is); + assertEquals(xmlReader.getEncoding(), encoding); + xmlReader.close(); + } + + protected void _testRawNoBomInvalid(final String encoding) throws Exception { + final InputStream is = getXmlStream("no-bom", XML3, encoding, encoding); + try { + (new XmlStreamReader(is, false)).close();; + fail("It should have failed"); + } catch (final IOException ex) { + assertTrue(ex.getMessage().contains("Invalid encoding,")); + } + } + + @Test + public void testRawNoBomUsAscii() throws Exception { + _testRawNoBomValid("US-ASCII"); + } + + @Test + public void testRawNoBomUtf8() throws Exception { + _testRawNoBomValid("UTF-8"); + } + + @Test + public void testRawNoBomUtf16BE() throws Exception { + _testRawNoBomValid("UTF-16BE"); + } + + @Test + public void testRawNoBomUtf16LE() throws Exception { + _testRawNoBomValid("UTF-16LE"); + } + + @Test + public void testRawNoBomUtf32BE() throws Exception { + _testRawNoBomValid("UTF-32BE"); + } + + @Test + public void testRawNoBomUtf32LE() throws Exception { + _testRawNoBomValid("UTF-32LE"); + } + + @Test + public void testRawNoBomIso8859_1() throws Exception { + _testRawNoBomValid("ISO-8859-1"); + } + + @Test + public void testRawNoBomCp1047() throws Exception { + _testRawNoBomValid("CP1047"); + } + + protected void _testRawBomValid(final String encoding) throws Exception { + final InputStream is = getXmlStream(encoding + "-bom", XML3, encoding, + encoding); + final XmlStreamReader xmlReader = new XmlStreamReader(is, false); + if (!encoding.equals("UTF-16") && !encoding.equals("UTF-32")) { + assertEquals(xmlReader.getEncoding(), encoding); + } else { + assertEquals(xmlReader.getEncoding() + .substring(0, encoding.length()), encoding); + } + xmlReader.close(); + } + + protected void _testRawBomInvalid(final String bomEnc, final String streamEnc, + final String prologEnc) throws Exception { + final InputStream is = getXmlStream(bomEnc, XML3, streamEnc, prologEnc); + XmlStreamReader xmlReader = null; + try { + xmlReader = new XmlStreamReader(is, false); + final String foundEnc = xmlReader.getEncoding(); + fail("Expected IOException for BOM " + bomEnc + ", streamEnc " + + streamEnc + " and prologEnc " + prologEnc + ": found " + + foundEnc); + } catch (final IOException ex) { + assertTrue(ex.getMessage().contains("Invalid encoding,")); + } + if (xmlReader != null) { + xmlReader.close(); + } + } + + @Test + public void testRawBomUtf8() throws Exception { + _testRawBomValid("UTF-8"); + _testRawBomInvalid("UTF-8-bom", "US-ASCII", "US-ASCII"); + _testRawBomInvalid("UTF-8-bom", "ISO-8859-1", "ISO-8859-1"); + _testRawBomInvalid("UTF-8-bom", "UTF-8", "UTF-16"); + _testRawBomInvalid("UTF-8-bom", "UTF-8", "UTF-16BE"); + _testRawBomInvalid("UTF-8-bom", "UTF-8", "UTF-16LE"); + _testRawBomInvalid("UTF-16BE-bom", "UTF-16BE", "UTF-16LE"); + _testRawBomInvalid("UTF-16LE-bom", "UTF-16LE", "UTF-16BE"); + _testRawBomInvalid("UTF-16LE-bom", "UTF-16LE", "UTF-8"); + _testRawBomInvalid("UTF-32BE-bom", "UTF-32BE", "UTF-32LE"); + _testRawBomInvalid("UTF-32LE-bom", "UTF-32LE", "UTF-32BE"); + _testRawBomInvalid("UTF-32LE-bom", "UTF-32LE", "UTF-8"); + } + + @Test + public void testRawBomUtf16() throws Exception { + _testRawBomValid("UTF-16BE"); + _testRawBomValid("UTF-16LE"); + _testRawBomValid("UTF-16"); + + _testRawBomInvalid("UTF-16BE-bom", "UTF-16BE", "UTF-16LE"); + _testRawBomInvalid("UTF-16LE-bom", "UTF-16LE", "UTF-16BE"); + _testRawBomInvalid("UTF-16LE-bom", "UTF-16LE", "UTF-8"); + } + + @Test + public void testRawBomUtf32() throws Exception { + _testRawBomValid("UTF-32BE"); + _testRawBomValid("UTF-32LE"); + _testRawBomValid("UTF-32"); + + _testRawBomInvalid("UTF-32BE-bom", "UTF-32BE", "UTF-32LE"); + _testRawBomInvalid("UTF-32LE-bom", "UTF-32LE", "UTF-32BE"); + _testRawBomInvalid("UTF-32LE-bom", "UTF-32LE", "UTF-8"); + } + + + @Test + public void testHttp() throws Exception { + // niallp 2010-10-06 - remove following 2 tests - I reinstated + // checks for non-UTF-16 encodings (18 tests) and these failed + // _testHttpValid("application/xml", "no-bom", "US-ASCII", null); + // _testHttpValid("application/xml", "UTF-8-bom", "US-ASCII", null); + _testHttpValid("application/xml", "UTF-8-bom", "UTF-8", null); + _testHttpValid("application/xml", "UTF-8-bom", "UTF-8", "UTF-8"); + _testHttpValid("application/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", null); + _testHttpValid("application/xml;charset=\"UTF-8\"", "UTF-8-bom", "UTF-8", null); + _testHttpValid("application/xml;charset='UTF-8'", "UTF-8-bom", "UTF-8", null); + _testHttpValid("application/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", "UTF-8"); + _testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", null); + _testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16"); + _testHttpValid("application/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE"); + + _testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", null); + _testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16"); + _testHttpInvalid("application/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE"); + + _testHttpInvalid("application/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", null); + _testHttpInvalid("application/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32"); + _testHttpInvalid("application/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32BE"); + + _testHttpInvalid("application/xml", "UTF-8-bom", "US-ASCII", "US-ASCII"); + _testHttpInvalid("application/xml;charset=UTF-16", "UTF-16LE", "UTF-8", "UTF-8"); + _testHttpInvalid("application/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE"); + _testHttpInvalid("application/xml;charset=UTF-32", "UTF-32LE", "UTF-8", "UTF-8"); + _testHttpInvalid("application/xml;charset=UTF-32", "no-bom", "UTF-32BE", "UTF-32BE"); + + _testHttpValid("text/xml", "no-bom", "US-ASCII", null); + _testHttpValid("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", "UTF-8"); + _testHttpValid("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", null); + _testHttpValid("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", null); + _testHttpValid("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16"); + _testHttpValid("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE"); + _testHttpValid("text/xml;charset=UTF-32", "UTF-32BE-bom", "UTF-32BE", null); + _testHttpValid("text/xml;charset=UTF-32", "UTF-32BE-bom", "UTF-32BE", "UTF-32"); + _testHttpValid("text/xml;charset=UTF-32", "UTF-32BE-bom", "UTF-32BE", "UTF-32BE"); + _testHttpValid("text/xml", "UTF-8-bom", "US-ASCII", null); + + _testAlternateDefaultEncoding("application/xml", "UTF-8-bom", "UTF-8", null, null); + _testAlternateDefaultEncoding("application/xml", "no-bom", "US-ASCII", null, "US-ASCII"); + _testAlternateDefaultEncoding("application/xml", "UTF-8-bom", "UTF-8", null, "UTF-8"); + _testAlternateDefaultEncoding("text/xml", "no-bom", "US-ASCII", null, null); + _testAlternateDefaultEncoding("text/xml", "no-bom", "US-ASCII", null, "US-ASCII"); + _testAlternateDefaultEncoding("text/xml", "no-bom", "US-ASCII", null, "UTF-8"); + + _testHttpInvalid("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", null); + _testHttpInvalid("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16"); + _testHttpInvalid("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE"); + _testHttpInvalid("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE"); + _testHttpInvalid("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", null); + + _testHttpInvalid("text/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", null); + _testHttpInvalid("text/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32"); + _testHttpInvalid("text/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32BE"); + _testHttpInvalid("text/xml;charset=UTF-32", "no-bom", "UTF-32BE", "UTF-32BE"); + _testHttpInvalid("text/xml;charset=UTF-32", "no-bom", "UTF-32BE", null); + + _testHttpLenient("text/xml", "no-bom", "US-ASCII", null, "US-ASCII"); + _testHttpLenient("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", "UTF-8", "UTF-8"); + _testHttpLenient("text/xml;charset=UTF-8", "UTF-8-bom", "UTF-8", null, "UTF-8"); + _testHttpLenient("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", null, "UTF-16BE"); + _testHttpLenient("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16", "UTF-16"); + _testHttpLenient("text/xml;charset=UTF-16", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE", "UTF-16BE"); + _testHttpLenient("text/xml;charset=UTF-32", "UTF-32BE-bom", "UTF-32BE", null, "UTF-32BE"); + _testHttpLenient("text/xml;charset=UTF-32", "UTF-32BE-bom", "UTF-32BE", "UTF-32", "UTF-32"); + _testHttpLenient("text/xml;charset=UTF-32", "UTF-32BE-bom", "UTF-32BE", "UTF-32BE", "UTF-32BE"); + _testHttpLenient("text/xml", "UTF-8-bom", "US-ASCII", null, "US-ASCII"); + + _testHttpLenient("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", null, "UTF-16BE"); + _testHttpLenient("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16", "UTF-16"); + _testHttpLenient("text/xml;charset=UTF-16BE", "UTF-16BE-bom", "UTF-16BE", "UTF-16BE", "UTF-16BE"); + _testHttpLenient("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", "UTF-16BE", "UTF-16BE"); + _testHttpLenient("text/xml;charset=UTF-16", "no-bom", "UTF-16BE", null, "UTF-16"); + + _testHttpLenient("text/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", null, "UTF-32BE"); + _testHttpLenient("text/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32", "UTF-32"); + _testHttpLenient("text/xml;charset=UTF-32BE", "UTF-32BE-bom", "UTF-32BE", "UTF-32BE", "UTF-32BE"); + _testHttpLenient("text/xml;charset=UTF-32", "no-bom", "UTF-32BE", "UTF-32BE", "UTF-32BE"); + _testHttpLenient("text/xml;charset=UTF-32", "no-bom", "UTF-32BE", null, "UTF-32"); + + _testHttpLenient("text/html", "no-bom", "US-ASCII", "US-ASCII", "US-ASCII"); + _testHttpLenient("text/html", "no-bom", "US-ASCII", null, "US-ASCII"); + _testHttpLenient("text/html;charset=UTF-8", "no-bom", "US-ASCII", "UTF-8", "UTF-8"); + _testHttpLenient("text/html;charset=UTF-16BE", "no-bom", "US-ASCII", "UTF-8", "UTF-8"); + _testHttpLenient("text/html;charset=UTF-32BE", "no-bom", "US-ASCII", "UTF-8", "UTF-8"); + } + + @Test + public void testRawContent() throws Exception { + final String encoding = "UTF-8"; + final String xml = getXML("no-bom", XML3, encoding, encoding); + final ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(encoding)); + final XmlStreamReader xmlReader = new XmlStreamReader(is); + assertEquals("Check encoding", xmlReader.getEncoding(), encoding); + assertEquals("Check content", xml, IOUtils.toString(xmlReader)); + } + + @Test + public void testHttpContent() throws Exception { + final String encoding = "UTF-8"; + final String xml = getXML("no-bom", XML3, encoding, encoding); + final ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes(encoding)); + final XmlStreamReader xmlReader = new XmlStreamReader(is, encoding); + assertEquals("Check encoding", xmlReader.getEncoding(), encoding); + assertEquals("Check content", xml, IOUtils.toString(xmlReader)); + } + + public void _testAlternateDefaultEncoding(final String cT, final String bomEnc, + final String streamEnc, final String prologEnc, final String alternateEnc) + throws Exception { + final InputStream is = getXmlStream(bomEnc, prologEnc == null ? XML1 + : XML3, streamEnc, prologEnc); + final XmlStreamReader xmlReader = new XmlStreamReader(is, cT, false, alternateEnc); + if (!streamEnc.equals("UTF-16")) { + // we can not assert things here because UTF-8, US-ASCII and + // ISO-8859-1 look alike for the chars used for detection + // (niallp 2010-10-06 - I re-instated the check below - the tests(6) passed) + final String enc = alternateEnc != null ? alternateEnc : streamEnc; + assertEquals(xmlReader.getEncoding(), enc); + } else { + //String enc = (alternateEnc != null) ? alternateEnc : streamEnc; + assertEquals(xmlReader.getEncoding().substring(0, + streamEnc.length()), streamEnc); + } + xmlReader.close(); + } + + public void _testHttpValid(final String cT, final String bomEnc, final String streamEnc, + final String prologEnc) throws Exception { + final InputStream is = getXmlStream(bomEnc, + prologEnc == null ? XML1 : XML3, streamEnc, prologEnc); + final XmlStreamReader xmlReader = new XmlStreamReader(is, cT, false); + if (!streamEnc.equals("UTF-16")) { + // we can not assert things here because UTF-8, US-ASCII and + // ISO-8859-1 look alike for the chars used for detection + // (niallp 2010-10-06 - I re-instated the check below and removed the 2 tests that failed) + assertEquals(xmlReader.getEncoding(), streamEnc); + } else { + assertEquals(xmlReader.getEncoding().substring(0, + streamEnc.length()), streamEnc); + } + xmlReader.close(); + } + + protected void _testHttpInvalid(final String cT, final String bomEnc, final String streamEnc, + final String prologEnc) throws Exception { + final InputStream is = getXmlStream(bomEnc, + prologEnc == null ? XML2 : XML3, streamEnc, prologEnc); + try { + (new XmlStreamReader(is, cT, false)).close();; + fail("It should have failed for HTTP Content-type " + cT + ", BOM " + + bomEnc + ", streamEnc " + streamEnc + " and prologEnc " + + prologEnc); + } catch (final IOException ex) { + assertTrue(ex.getMessage().contains("Invalid encoding,")); + } + } + + protected void _testHttpLenient(final String cT, final String bomEnc, final String streamEnc, + final String prologEnc, final String shouldbe) throws Exception { + final InputStream is = getXmlStream(bomEnc, + prologEnc == null ? XML2 : XML3, streamEnc, prologEnc); + final XmlStreamReader xmlReader = new XmlStreamReader(is, cT, true); + assertEquals(xmlReader.getEncoding(), shouldbe); + xmlReader.close(); + } + + private static final String ENCODING_ATTRIBUTE_XML = " \n" + + "\n" + + "\n" + + " \n" + + " BOMs = new HashMap(); + + static { + BOMs.put("no-bom", NO_BOM_BYTES); + BOMs.put("UTF-16BE-bom", UTF_16BE_BOM_BYTES); + BOMs.put("UTF-16LE-bom", UTF_16LE_BOM_BYTES); + BOMs.put("UTF-32BE-bom", UTF_32BE_BOM_BYTES); + BOMs.put("UTF-32LE-bom", UTF_32LE_BOM_BYTES); + BOMs.put("UTF-16-bom", NO_BOM_BYTES); // it's added by the writer + BOMs.put("UTF-8-bom", UTF_8_BOM_BYTES); + } + + private static final MessageFormat XML = new MessageFormat( + "{2}"); + private static final MessageFormat XML_WITH_PROLOG = new MessageFormat( + "\n{2}"); + private static final MessageFormat XML_WITH_PROLOG_AND_ENCODING_DOUBLE_QUOTES = new MessageFormat( + "\n{2}"); + private static final MessageFormat XML_WITH_PROLOG_AND_ENCODING_SINGLE_QUOTES = new MessageFormat( + "\n{2}"); + private static final MessageFormat XML_WITH_PROLOG_AND_ENCODING_SPACED_SINGLE_QUOTES = new MessageFormat( + "\n{2}"); + + private static final MessageFormat INFO = new MessageFormat( + "\nBOM : {0}\nDoc : {1}\nStream Enc : {2}\nProlog Enc : {3}\n"); + + private static final Map XMLs = new HashMap(); + + static { + XMLs.put(XML1, XML); + XMLs.put(XML2, XML_WITH_PROLOG); + XMLs.put(XML3, XML_WITH_PROLOG_AND_ENCODING_DOUBLE_QUOTES); + XMLs.put(XML4, XML_WITH_PROLOG_AND_ENCODING_SINGLE_QUOTES); + XMLs.put(XML5, XML_WITH_PROLOG_AND_ENCODING_SPACED_SINGLE_QUOTES); + } + + /** + * @param bomType no-bom, UTF-16BE-bom, UTF-16LE-bom, UTF-8-bom + * @param xmlType xml, xml-prolog, xml-prolog-charset + * @param streamEnc encoding of the stream + * @param prologEnc encoding of the prolog + * @return XML stream + * @throws IOException If an I/O error occurs + */ + protected InputStream getXmlStream(final String bomType, final String xmlType, + final String streamEnc, final String prologEnc) throws IOException { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); + int[] bom = BOMs.get(bomType); + if (bom == null) { + bom = new int[0]; + } + for (final int element : bom) { + baos.write(element); + } + final Writer writer = new OutputStreamWriter(baos, streamEnc); + final String xmlDoc = getXML(bomType, xmlType, streamEnc, prologEnc); + writer.write(xmlDoc); + + // PADDDING TO TEST THINGS WORK BEYOND PUSHBACK_SIZE + writer.write("\n"); + for (int i = 0; i < 10000; i++) { + writer.write("\n"); + } + writer.write("\n"); + + writer.close(); + return new ByteArrayInputStream(baos.toByteArray()); + } + + /** + * Create the XML. + */ + private String getXML(final String bomType, final String xmlType, + final String streamEnc, final String prologEnc) { + final MessageFormat xml = XMLs.get(xmlType); + final String info = INFO.format(new Object[]{bomType, xmlType, prologEnc}); + final String xmlDoc = xml.format(new Object[]{streamEnc, prologEnc, info}); + return xmlDoc; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..4f9ed47fce094a7b4a8d0eac9f581cae29d31640 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java" @@ -0,0 +1,332 @@ +/* + * 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.input; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import org.junit.Test; + +/** + * Test the Encoding Utilities part of {@link XmlStreamReader}. + */ +public class XmlStreamReaderUtilitiesTest { + + private static String RAWMGS1 = "encoding mismatch"; + private static String RAWMGS2 = "unknown BOM"; + private static String HTTPMGS1 = "BOM must be NULL"; + private static String HTTPMGS2 = "encoding mismatch"; + private static String HTTPMGS3 = "Invalid MIME"; + + private static String APPXML = "application/xml"; + private static String APPXML_UTF8 = "application/xml;charset=UTF-8"; + private static String APPXML_UTF16 = "application/xml;charset=UTF-16"; + private static String APPXML_UTF32 = "application/xml;charset=UTF-32"; + private static String APPXML_UTF16BE = "application/xml;charset=UTF-16BE"; + private static String APPXML_UTF16LE = "application/xml;charset=UTF-16LE"; + private static String APPXML_UTF32BE = "application/xml;charset=UTF-32BE"; + private static String APPXML_UTF32LE = "application/xml;charset=UTF-32LE"; + private static String TXTXML = "text/xml"; + + @Test + public void testContentTypeEncoding() { + checkContentTypeEncoding(null, null); + checkContentTypeEncoding(null, ""); + checkContentTypeEncoding(null, "application/xml"); + checkContentTypeEncoding(null, "application/xml;"); + checkContentTypeEncoding(null, "multipart/mixed;boundary=frontier"); + checkContentTypeEncoding(null, "multipart/mixed;boundary='frontier'"); + checkContentTypeEncoding(null, "multipart/mixed;boundary=\"frontier\""); + checkContentTypeEncoding("UTF-16", "application/xml;charset=utf-16"); + checkContentTypeEncoding("UTF-16", "application/xml;charset=UTF-16"); + checkContentTypeEncoding("UTF-16", "application/xml;charset='UTF-16'"); + checkContentTypeEncoding("UTF-16", "application/xml;charset=\"UTF-16\""); + checkContentTypeEncoding("UTF-32", "application/xml;charset=utf-32"); + checkContentTypeEncoding("UTF-32", "application/xml;charset=UTF-32"); + checkContentTypeEncoding("UTF-32", "application/xml;charset='UTF-32'"); + checkContentTypeEncoding("UTF-32", "application/xml;charset=\"UTF-32\""); + } + + private void checkContentTypeEncoding(final String expected, final String httpContentType) { + assertEquals("ContentTypeEncoding=[" + httpContentType + "]", expected, XmlStreamReader.getContentTypeEncoding(httpContentType)); + } + + @Test + public void testContentTypeMime() { + checkContentTypeMime(null, null); + checkContentTypeMime("", ""); + checkContentTypeMime("application/xml", "application/xml"); + checkContentTypeMime("application/xml", "application/xml;"); + checkContentTypeMime("application/xml", "application/xml;charset=utf-16"); + checkContentTypeMime("application/xml", "application/xml;charset=utf-32"); + } + + private void checkContentTypeMime(final String expected, final String httpContentType) { + assertEquals("ContentTypeMime=[" + httpContentType + "]", expected, XmlStreamReader.getContentTypeMime(httpContentType)); + } + + @Test + public void testAppXml() { + checkAppXml(false, null); + checkAppXml(false, ""); + checkAppXml(true, "application/xml"); + checkAppXml(true, "application/xml-dtd"); + checkAppXml(true, "application/xml-external-parsed-entity"); + checkAppXml(true, "application/soap+xml"); + checkAppXml(true, "application/atom+xml"); + checkAppXml(false, "application/atomxml"); + checkAppXml(false, "text/xml"); + checkAppXml(false, "text/atom+xml"); + checkAppXml(true, "application/xml-dtd"); + checkAppXml(true, "application/xml-external-parsed-entity"); + } + + @SuppressWarnings("boxing") + private void checkAppXml(final boolean expected, final String mime) { + assertEquals("Mime=[" + mime + "]", expected, XmlStreamReader.isAppXml(mime)); + } + + @Test + public void testTextXml() { + checkTextXml(false, null); + checkTextXml(false, ""); + checkTextXml(true, "text/xml"); + checkTextXml(true, "text/xml-external-parsed-entity"); + checkTextXml(true, "text/soap+xml"); + checkTextXml(true, "text/atom+xml"); + checkTextXml(false, "text/atomxml"); + checkTextXml(false, "application/xml"); + checkTextXml(false, "application/atom+xml"); + } + + @SuppressWarnings("boxing") + private void checkTextXml(final boolean expected, final String mime) { + assertEquals("Mime=[" + mime + "]", expected, XmlStreamReader.isTextXml(mime)); + } + + @Test + public void testCalculateRawEncodingNoBOM() throws IOException { + // No BOM Expected BOM Guess XML Default + checkRawError(RAWMGS2, "UTF-32", null, null, null); + // + checkRawEncoding("UTF-8", null, null, null, null); + checkRawEncoding("UTF-8", null, "UTF-16BE", null, null); /* why default & not Guess? */ + checkRawEncoding("UTF-8", null, null, "UTF-16BE", null); /* why default & not XMLEnc? */ + checkRawEncoding("UTF-8", null, "UTF-8", "UTF-8", "UTF-16BE"); + // + checkRawEncoding("UTF-16BE", null, "UTF-16BE", "UTF-16BE", null); + checkRawEncoding("UTF-16BE", null, null, null, "UTF-16BE"); + checkRawEncoding("UTF-16BE", null, "UTF-8", null, "UTF-16BE"); /* why default & not Guess? */ + checkRawEncoding("UTF-16BE", null, null, "UTF-8", "UTF-16BE"); /* why default & not Guess? */ + checkRawEncoding("UTF-16BE", null, "UTF-16BE", "UTF-16", null); + checkRawEncoding("UTF-16LE", null, "UTF-16LE", "UTF-16", null); + } + + @Test + public void testCalculateRawEncodingStandard() throws IOException { + // Standard BOM Checks BOM Other Default + testCalculateRawEncodingStandard("UTF-8", "UTF-16BE", "UTF-16LE"); + testCalculateRawEncodingStandard("UTF-16BE", "UTF-8", "UTF-16LE"); + testCalculateRawEncodingStandard("UTF-16LE", "UTF-8", "UTF-16BE"); + } + + @Test + //@Ignore + public void testCalculateRawEncodingStandardUtf32() throws IOException { + // Standard BOM Checks BOM Other Default + testCalculateRawEncodingStandard("UTF-8", "UTF-32BE", "UTF-32LE"); + testCalculateRawEncodingStandard("UTF-32BE", "UTF-8", "UTF-32LE"); + testCalculateRawEncodingStandard("UTF-32LE", "UTF-8", "UTF-32BE"); +} + + private void testCalculateRawEncodingStandard(final String bomEnc, final String otherEnc, final String defaultEnc) throws IOException { + // Expected BOM Guess XMLEnc Default + checkRawEncoding(bomEnc, bomEnc, null, null, defaultEnc); + checkRawEncoding(bomEnc, bomEnc, bomEnc, null, defaultEnc); + checkRawError(RAWMGS1, bomEnc, otherEnc, null, defaultEnc); + checkRawEncoding(bomEnc, bomEnc, null, bomEnc, defaultEnc); + checkRawError(RAWMGS1, bomEnc, null, otherEnc, defaultEnc); + checkRawEncoding(bomEnc, bomEnc, bomEnc, bomEnc, defaultEnc); + checkRawError(RAWMGS1, bomEnc, bomEnc, otherEnc, defaultEnc); + checkRawError(RAWMGS1, bomEnc, otherEnc, bomEnc, defaultEnc); + + } + + @Test + public void testCalculateRawEncodingAdditonalUTF16() throws IOException { + // BOM Guess XML Default + checkRawError(RAWMGS1, "UTF-16BE", "UTF-16", null, null); + checkRawEncoding("UTF-16BE", "UTF-16BE", null, "UTF-16", null); + checkRawEncoding("UTF-16BE", "UTF-16BE", "UTF-16BE", "UTF-16", null); + checkRawError(RAWMGS1, "UTF-16BE", null, "UTF-16LE", null); + checkRawError(RAWMGS1, "UTF-16BE", "UTF-16BE", "UTF-16LE", null); + checkRawError(RAWMGS1, "UTF-16LE", "UTF-16", null, null); + checkRawEncoding("UTF-16LE", "UTF-16LE", null, "UTF-16", null); + checkRawEncoding("UTF-16LE", "UTF-16LE", "UTF-16LE", "UTF-16", null); + checkRawError(RAWMGS1, "UTF-16LE", null, "UTF-16BE", null); + checkRawError(RAWMGS1, "UTF-16LE", "UTF-16LE", "UTF-16BE", null); + } + + @Test + public void testCalculateRawEncodingAdditonalUTF32() throws IOException { + // BOM Guess XML Default + checkRawError(RAWMGS1, "UTF-32BE", "UTF-32", null, null); + checkRawEncoding("UTF-32BE", "UTF-32BE", null, "UTF-32", null); + checkRawEncoding("UTF-32BE", "UTF-32BE", "UTF-32BE", "UTF-32", null); + checkRawError(RAWMGS1, "UTF-32BE", null, "UTF-32LE", null); + checkRawError(RAWMGS1, "UTF-32BE", "UTF-32BE", "UTF-32LE", null); + checkRawError(RAWMGS1, "UTF-32LE", "UTF-32", null, null); + checkRawEncoding("UTF-32LE", "UTF-32LE", null, "UTF-32", null); + checkRawEncoding("UTF-32LE", "UTF-32LE", "UTF-32LE", "UTF-32", null); + checkRawError(RAWMGS1, "UTF-32LE", null, "UTF-32BE", null); + checkRawError(RAWMGS1, "UTF-32LE", "UTF-32LE", "UTF-32BE", null); + } + + private void checkRawEncoding(final String expected, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) throws IOException { + final StringBuilder builder = new StringBuilder(); + builder.append("RawEncoding: ").append(bomEnc).append("], "); + builder.append("bomEnc=[").append(bomEnc).append("], "); + builder.append("xmlGuessEnc=[").append(xmlGuessEnc).append("], "); + builder.append("xmlEnc=[").append(xmlEnc).append("], "); + builder.append("defaultEncoding=[").append(defaultEncoding).append("],"); + final String encoding = calculateRawEncoding(bomEnc,xmlGuessEnc,xmlEnc, defaultEncoding); + assertEquals(builder.toString(), expected, encoding); + } + + protected String calculateRawEncoding(final String bomEnc, final String xmlGuessEnc, final String xmlEnc, + final String defaultEncoding) throws IOException { + final MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding); + final String enc = mock.calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc); + mock.close(); + return enc; + } + + private void checkRawError(final String msgSuffix, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) { + try { + checkRawEncoding("XmlStreamReaderException", bomEnc, xmlGuessEnc, xmlEnc, defaultEncoding); + fail("Expected XmlStreamReaderException"); + } catch (final XmlStreamReaderException e) { + assertTrue("Msg Start: " + e.getMessage(), e.getMessage().startsWith("Invalid encoding")); + assertTrue("Msg End: " + e.getMessage(), e.getMessage().endsWith(msgSuffix)); + assertEquals("bomEnc", bomEnc, e.getBomEncoding()); + assertEquals("xmlGuessEnc", xmlGuessEnc, e.getXmlGuessEncoding()); + assertEquals("xmlEnc", xmlEnc, e.getXmlEncoding()); + assertNull("ContentTypeEncoding", e.getContentTypeEncoding()); + assertNull("ContentTypeMime", e.getContentTypeMime()); + } catch (final Exception e) { + fail("Expected XmlStreamReaderException, but threw " + e); + } + } + + @Test + public void testCalculateHttpEncoding() throws IOException { + // No BOM Expected Lenient cType BOM Guess XML Default + checkHttpError(HTTPMGS3, true, null, null, null, null, null); + checkHttpError(HTTPMGS3, false, null, null, null, "UTF-8", null); + checkHttpEncoding("UTF-8", true, null, null, null, "UTF-8", null); + checkHttpEncoding("UTF-16LE", true, null, null, null, "UTF-16LE", null); + checkHttpError(HTTPMGS3, false, "text/css", null, null, null, null); + checkHttpEncoding("US-ASCII", false, TXTXML, null, null, null, null); + checkHttpEncoding("UTF-16BE", false, TXTXML, null, null, null, "UTF-16BE"); + checkHttpEncoding("UTF-8", false, APPXML, null, null, null, null); + checkHttpEncoding("UTF-16BE", false, APPXML, null, null, null, "UTF-16BE"); + checkHttpEncoding("UTF-8", false, APPXML, "UTF-8", null, null, "UTF-16BE"); + checkHttpEncoding("UTF-16LE", false, APPXML_UTF16LE, null, null, null, null); + checkHttpEncoding("UTF-16BE", false, APPXML_UTF16BE, null, null, null, null); + checkHttpError(HTTPMGS1, false, APPXML_UTF16LE, "UTF-16LE", null, null, null); + checkHttpError(HTTPMGS1, false, APPXML_UTF16BE, "UTF-16BE", null, null, null); + checkHttpError(HTTPMGS2, false, APPXML_UTF16, null, null, null, null); + checkHttpError(HTTPMGS2, false, APPXML_UTF16, "UTF-8", null, null, null); + checkHttpEncoding("UTF-16LE", false, APPXML_UTF16, "UTF-16LE", null, null, null); + checkHttpEncoding("UTF-16BE", false, APPXML_UTF16, "UTF-16BE", null, null, null); + checkHttpEncoding("UTF-8", false, APPXML_UTF8, null, null, null, null); + checkHttpEncoding("UTF-8", false, APPXML_UTF8, "UTF-16BE", "UTF-16BE", "UTF-16BE", "UTF-16BE"); + } + + @Test + public void testCalculateHttpEncodingUtf32() throws IOException { + // No BOM Expected Lenient cType BOM Guess XML Default + checkHttpEncoding("UTF-32LE", true, null, null, null, "UTF-32LE", null); + checkHttpEncoding("UTF-32BE", false, TXTXML, null, null, null, "UTF-32BE"); + checkHttpEncoding("UTF-32BE", false, APPXML, null, null, null, "UTF-32BE"); + checkHttpEncoding("UTF-32LE", false, APPXML_UTF32LE, null, null, null, null); + checkHttpEncoding("UTF-32BE", false, APPXML_UTF32BE, null, null, null, null); + checkHttpError(HTTPMGS1, false, APPXML_UTF32LE, "UTF-32LE", null, null, null); + checkHttpError(HTTPMGS1, false, APPXML_UTF32BE, "UTF-32BE", null, null, null); + checkHttpError(HTTPMGS2, false, APPXML_UTF32, null, null, null, null); + checkHttpError(HTTPMGS2, false, APPXML_UTF32, "UTF-8", null, null, null); + checkHttpEncoding("UTF-32LE", false, APPXML_UTF32, "UTF-32LE", null, null, null); + checkHttpEncoding("UTF-32BE", false, APPXML_UTF32, "UTF-32BE", null, null, null); + checkHttpEncoding("UTF-8", false, APPXML_UTF8, "UTF-32BE", "UTF-32BE", "UTF-32BE", "UTF-32BE"); + } + + private void checkHttpEncoding(final String expected, final boolean lenient, final String httpContentType, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) throws IOException { + final StringBuilder builder = new StringBuilder(); + builder.append("HttpEncoding=[").append(bomEnc).append("], "); + builder.append("lenient=[").append(lenient).append("], "); + builder.append("httpContentType=[").append(httpContentType).append("], "); + builder.append("bomEnc=[").append(bomEnc).append("], "); + builder.append("xmlGuessEnc=[").append(xmlGuessEnc).append("], "); + builder.append("xmlEnc=[").append(xmlEnc).append("], "); + builder.append("defaultEncoding=[").append(defaultEncoding).append("],"); + final String encoding = calculateHttpEncoding(httpContentType, bomEnc, xmlGuessEnc, xmlEnc, lenient, defaultEncoding); + assertEquals(builder.toString(), expected, encoding); + } + + protected String calculateHttpEncoding(final String httpContentType, final String bomEnc, final String xmlGuessEnc, + final String xmlEnc, final boolean lenient, final String defaultEncoding) throws IOException { + final MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding); + final String enc = mock.calculateHttpEncoding(httpContentType, bomEnc, xmlGuessEnc, xmlEnc, lenient); + mock.close(); + return enc; + } + + private void checkHttpError(final String msgSuffix, final boolean lenient, final String httpContentType, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final String defaultEncoding) { + try { + checkHttpEncoding("XmlStreamReaderException", lenient, httpContentType, bomEnc, xmlGuessEnc, xmlEnc, defaultEncoding); + fail("Expected XmlStreamReaderException"); + } catch (final XmlStreamReaderException e) { + assertTrue("Msg Start: " + e.getMessage(), e.getMessage().startsWith("Invalid encoding")); + assertTrue("Msg End: " + e.getMessage(), e.getMessage().endsWith(msgSuffix)); + assertEquals("bomEnc", bomEnc, e.getBomEncoding()); + assertEquals("xmlGuessEnc", xmlGuessEnc, e.getXmlGuessEncoding()); + assertEquals("xmlEnc", xmlEnc, e.getXmlEncoding()); + assertEquals("ContentTypeEncoding", XmlStreamReader.getContentTypeEncoding(httpContentType), + e.getContentTypeEncoding()); + assertEquals("ContentTypeMime", XmlStreamReader.getContentTypeMime(httpContentType), + e.getContentTypeMime()); + } catch (final Exception e) { + fail("Expected XmlStreamReaderException, but threw " + e); + } + } + + /** Mock {@link XmlStreamReader} implementation */ + private static class MockXmlStreamReader extends XmlStreamReader { + MockXmlStreamReader(final String defaultEncoding) throws IOException { + super(new ByteArrayInputStream("".getBytes()), null, true, defaultEncoding); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReader.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReader.java" new file mode 100644 index 0000000000000000000000000000000000000000..85e19787e8bf1c3cbfc59445405a22580eb17509 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReader.java" @@ -0,0 +1,744 @@ +/* + * 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.input.compatibility; + +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.text.MessageFormat; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.io.output.XmlStreamWriter; + +/** + * Character stream that handles all the necessary Voodo to figure out the + * charset encoding of the XML document within the stream. + *

+ * IMPORTANT: This class is not related in any way to the org.xml.sax.XMLReader. + * This one IS a character stream. + *

+ * All this has to be done without consuming characters from the stream, if not + * the XML parser will not recognized the document as a valid XML. This is not + * 100% true, but it's close enough (UTF-8 BOM is not handled by all parsers + * right now, XmlStreamReader handles it and things work in all parsers). + *

+ * The XmlStreamReader class handles the charset encoding of XML documents in + * Files, raw streams and HTTP streams by offering a wide set of constructors. + *

+ * By default the charset encoding detection is lenient, the constructor with + * the lenient flag can be used for an script (following HTTP MIME and XML + * specifications). All this is nicely explained by Mark Pilgrim in his blog, + * Determining the character encoding of a feed. + *

+ * Originally developed for ROME under + * Apache License 2.0. + * + * @version $Id: XmlStreamReader.java 1680650 2015-05-20 18:36:40Z britter $ + * @see XmlStreamWriter + */ +public class XmlStreamReader extends Reader { + private static final int BUFFER_SIZE = 4096; + + private static final String UTF_8 = "UTF-8"; + + private static final String US_ASCII = "US-ASCII"; + + private static final String UTF_16BE = "UTF-16BE"; + + private static final String UTF_16LE = "UTF-16LE"; + + private static final String UTF_16 = "UTF-16"; + + private static final String UTF_32BE = "UTF-32BE"; + + private static final String UTF_32LE = "UTF-32LE"; + + private static final String UTF_32 = "UTF-32"; + + private static final String EBCDIC = "CP1047"; + + private static String staticDefaultEncoding = null; + + private Reader reader; + + private String encoding; + + private final String defaultEncoding; + + /** + * Sets the default encoding to use if none is set in HTTP content-type, XML + * prolog and the rules based on content-type are not adequate. + *

+ * If it is set to NULL the content-type based rules are used. + *

+ * By default it is NULL. + * + * @param encoding charset encoding to default to. + */ + public static void setDefaultEncoding(final String encoding) { + staticDefaultEncoding = encoding; + } + + /** + * Returns the default encoding to use if none is set in HTTP content-type, + * XML prolog and the rules based on content-type are not adequate. + *

+ * If it is NULL the content-type based rules are used. + * + * @return the default encoding to use. + */ + public static String getDefaultEncoding() { + return staticDefaultEncoding; + } + + /** + * Creates a Reader for a File. + *

+ * It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset, + * if this is also missing defaults to UTF-8. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param file File to create a Reader from. + * @throws IOException thrown if there is a problem reading the file. + */ + public XmlStreamReader(final File file) throws IOException { + this(new FileInputStream(file)); + } + + /** + * Creates a Reader for a raw InputStream. + *

+ * It follows the same logic used for files. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param is InputStream to create a Reader from. + * @throws IOException thrown if there is a problem reading the stream. + */ + public XmlStreamReader(final InputStream is) throws IOException { + this(is, true); + } + + /** + * Creates a Reader for a raw InputStream. + *

+ * It follows the same logic used for files. + *

+ * If lenient detection is indicated and the detection above fails as per + * specifications it then attempts the following: + *

+ * If the content type was 'text/html' it replaces it with 'text/xml' and + * tries the detection again. + *

+ * Else if the XML prolog had a charset encoding that encoding is used. + *

+ * Else if the content type had a charset encoding that encoding is used. + *

+ * Else 'UTF-8' is used. + *

+ * If lenient detection is indicated an XmlStreamReaderException is never + * thrown. + * + * @param is InputStream to create a Reader from. + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @throws IOException thrown if there is a problem reading the stream. + * @throws XmlStreamReaderException thrown if the charset encoding could not + * be determined according to the specs. + */ + public XmlStreamReader(final InputStream is, final boolean lenient) throws IOException, + XmlStreamReaderException { + defaultEncoding = staticDefaultEncoding; + try { + doRawStream(is); + } catch (final XmlStreamReaderException ex) { + if (!lenient) { + throw ex; + } else { + doLenientDetection(null, ex); + } + } + } + + /** + * Creates a Reader using the InputStream of a URL. + *

+ * If the URL is not of type HTTP and there is not 'content-type' header in + * the fetched data it uses the same logic used for Files. + *

+ * If the URL is a HTTP Url or there is a 'content-type' header in the + * fetched data it uses the same logic used for an InputStream with + * content-type. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param url URL to create a Reader from. + * @throws IOException thrown if there is a problem reading the stream of + * the URL. + */ + public XmlStreamReader(final URL url) throws IOException { + this(url.openConnection()); + } + + /** + * Creates a Reader using the InputStream of a URLConnection. + *

+ * If the URLConnection is not of type HttpURLConnection and there is not + * 'content-type' header in the fetched data it uses the same logic used for + * files. + *

+ * If the URLConnection is a HTTP Url or there is a 'content-type' header in + * the fetched data it uses the same logic used for an InputStream with + * content-type. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param conn URLConnection to create a Reader from. + * @throws IOException thrown if there is a problem reading the stream of + * the URLConnection. + */ + public XmlStreamReader(final URLConnection conn) throws IOException { + defaultEncoding = staticDefaultEncoding; + final boolean lenient = true; + if (conn instanceof HttpURLConnection) { + try { + doHttpStream(conn.getInputStream(), conn.getContentType(), + lenient); + } catch (final XmlStreamReaderException ex) { + doLenientDetection(conn.getContentType(), ex); + } + } else if (conn.getContentType() != null) { + try { + doHttpStream(conn.getInputStream(), conn.getContentType(), + lenient); + } catch (final XmlStreamReaderException ex) { + doLenientDetection(conn.getContentType(), ex); + } + } else { + try { + doRawStream(conn.getInputStream()); + } catch (final XmlStreamReaderException ex) { + doLenientDetection(null, ex); + } + } + } + + /** + * Creates a Reader using an InputStream an the associated content-type + * header. + *

+ * First it checks if the stream has BOM. If there is not BOM checks the + * content-type encoding. If there is not content-type encoding checks the + * XML prolog encoding. If there is not XML prolog encoding uses the default + * encoding mandated by the content-type MIME type. + *

+ * It does a lenient charset encoding detection, check the constructor with + * the lenient parameter for details. + * + * @param is InputStream to create the reader from. + * @param httpContentType content-type header to use for the resolution of + * the charset encoding. + * @throws IOException thrown if there is a problem reading the file. + */ + public XmlStreamReader(final InputStream is, final String httpContentType) + throws IOException { + this(is, httpContentType, true); + } + + /** + * Creates a Reader using an InputStream an the associated content-type + * header. This constructor is lenient regarding the encoding detection. + *

+ * First it checks if the stream has BOM. If there is not BOM checks the + * content-type encoding. If there is not content-type encoding checks the + * XML prolog encoding. If there is not XML prolog encoding uses the default + * encoding mandated by the content-type MIME type. + *

+ * If lenient detection is indicated and the detection above fails as per + * specifications it then attempts the following: + *

+ * If the content type was 'text/html' it replaces it with 'text/xml' and + * tries the detection again. + *

+ * Else if the XML prolog had a charset encoding that encoding is used. + *

+ * Else if the content type had a charset encoding that encoding is used. + *

+ * Else 'UTF-8' is used. + *

+ * If lenient detection is indicated an XmlStreamReaderException is never + * thrown. + * + * @param is InputStream to create the reader from. + * @param httpContentType content-type header to use for the resolution of + * the charset encoding. + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @param defaultEncoding the default encoding to use + * @throws IOException thrown if there is a problem reading the file. + * @throws XmlStreamReaderException thrown if the charset encoding could not + * be determined according to the specs. + */ + public XmlStreamReader(final InputStream is, final String httpContentType, + final boolean lenient, final String defaultEncoding) throws IOException, + XmlStreamReaderException { + this.defaultEncoding = defaultEncoding == null ? staticDefaultEncoding + : defaultEncoding; + try { + doHttpStream(is, httpContentType, lenient); + } catch (final XmlStreamReaderException ex) { + if (!lenient) { + throw ex; + } else { + doLenientDetection(httpContentType, ex); + } + } + } + + /** + * Creates a Reader using an InputStream an the associated content-type + * header. This constructor is lenient regarding the encoding detection. + *

+ * First it checks if the stream has BOM. If there is not BOM checks the + * content-type encoding. If there is not content-type encoding checks the + * XML prolog encoding. If there is not XML prolog encoding uses the default + * encoding mandated by the content-type MIME type. + *

+ * If lenient detection is indicated and the detection above fails as per + * specifications it then attempts the following: + *

+ * If the content type was 'text/html' it replaces it with 'text/xml' and + * tries the detection again. + *

+ * Else if the XML prolog had a charset encoding that encoding is used. + *

+ * Else if the content type had a charset encoding that encoding is used. + *

+ * Else 'UTF-8' is used. + *

+ * If lenient detection is indicated an XmlStreamReaderException is never + * thrown. + * + * @param is InputStream to create the reader from. + * @param httpContentType content-type header to use for the resolution of + * the charset encoding. + * @param lenient indicates if the charset encoding detection should be + * relaxed. + * @throws IOException thrown if there is a problem reading the file. + * @throws XmlStreamReaderException thrown if the charset encoding could not + * be determined according to the specs. + */ + public XmlStreamReader(final InputStream is, final String httpContentType, + final boolean lenient) throws IOException, XmlStreamReaderException { + this(is, httpContentType, lenient, null); + } + + private void doLenientDetection(String httpContentType, + XmlStreamReaderException ex) throws IOException { + if (httpContentType != null) { + if (httpContentType.startsWith("text/html")) { + httpContentType = httpContentType.substring("text/html" + .length()); + httpContentType = "text/xml" + httpContentType; + try { + doHttpStream(ex.getInputStream(), httpContentType, true); + ex = null; + } catch (final XmlStreamReaderException ex2) { + ex = ex2; + } + } + } + if (ex != null) { + String encoding = ex.getXmlEncoding(); + if (encoding == null) { + encoding = ex.getContentTypeEncoding(); + } + if (encoding == null) { + encoding = defaultEncoding == null ? UTF_8 : defaultEncoding; + } + prepareReader(ex.getInputStream(), encoding); + } + } + + /** + * Returns the charset encoding of the XmlStreamReader. + * + * @return charset encoding. + */ + public String getEncoding() { + return encoding; + } + + @Override + public int read(final char[] buf, final int offset, final int len) throws IOException { + return reader.read(buf, offset, len); + } + + /** + * Closes the XmlStreamReader stream. + * + * @throws IOException thrown if there was a problem closing the stream. + */ + @Override + public void close() throws IOException { + reader.close(); + } + + private void doRawStream(final InputStream is) + throws IOException { + final BufferedInputStream pis = new BufferedInputStream(is, BUFFER_SIZE); + final String bomEnc = getBOMEncoding(pis); + final String xmlGuessEnc = getXMLGuessEncoding(pis); + final String xmlEnc = getXmlProlog(pis, xmlGuessEnc); + final String encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, pis); + prepareReader(pis, encoding); + } + + private void doHttpStream(final InputStream is, final String httpContentType, + final boolean lenient) throws IOException { + final BufferedInputStream pis = new BufferedInputStream(is, BUFFER_SIZE); + final String cTMime = getContentTypeMime(httpContentType); + final String cTEnc = getContentTypeEncoding(httpContentType); + final String bomEnc = getBOMEncoding(pis); + final String xmlGuessEnc = getXMLGuessEncoding(pis); + final String xmlEnc = getXmlProlog(pis, xmlGuessEnc); + final String encoding = calculateHttpEncoding(cTMime, cTEnc, bomEnc, + xmlGuessEnc, xmlEnc, pis, lenient); + prepareReader(pis, encoding); + } + + private void prepareReader(final InputStream is, final String encoding) + throws IOException { + reader = new InputStreamReader(is, encoding); + this.encoding = encoding; + } + + // InputStream is passed for XmlStreamReaderException creation only + String calculateRawEncoding(final String bomEnc, final String xmlGuessEnc, + final String xmlEnc, final InputStream is) throws IOException { + String encoding; + if (bomEnc == null) { + if (xmlGuessEnc == null || xmlEnc == null) { + encoding = defaultEncoding == null ? UTF_8 : defaultEncoding; + } else if (xmlEnc.equals(UTF_16) + && (xmlGuessEnc.equals(UTF_16BE) || xmlGuessEnc + .equals(UTF_16LE))) { + encoding = xmlGuessEnc; + } else if (xmlEnc.equals(UTF_32) + && (xmlGuessEnc.equals(UTF_32BE) || xmlGuessEnc + .equals(UTF_32LE))) { + encoding = xmlGuessEnc; + } else { + encoding = xmlEnc; + } + } else if (bomEnc.equals(UTF_8)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(UTF_8)) { + throw new XmlStreamReaderException(RAW_EX_1 + .format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), + bomEnc, xmlGuessEnc, xmlEnc, is); + } + if (xmlEnc != null && !xmlEnc.equals(UTF_8)) { + throw new XmlStreamReaderException(RAW_EX_1 + .format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), + bomEnc, xmlGuessEnc, xmlEnc, is); + } + encoding = UTF_8; + } else if (bomEnc.equals(UTF_16BE) || bomEnc.equals(UTF_16LE)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) { + throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] { bomEnc, + xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is); + } + if (xmlEnc != null && !xmlEnc.equals(UTF_16) + && !xmlEnc.equals(bomEnc)) { + throw new XmlStreamReaderException(RAW_EX_1 + .format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), + bomEnc, xmlGuessEnc, xmlEnc, is); + } + encoding = bomEnc; + } else if (bomEnc.equals(UTF_32BE) || bomEnc.equals(UTF_32LE)) { + if (xmlGuessEnc != null && !xmlGuessEnc.equals(bomEnc)) { + throw new XmlStreamReaderException(RAW_EX_1.format(new Object[] { bomEnc, + xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, xmlEnc, is); + } + if (xmlEnc != null && !xmlEnc.equals(UTF_32) + && !xmlEnc.equals(bomEnc)) { + throw new XmlStreamReaderException(RAW_EX_1 + .format(new Object[] { bomEnc, xmlGuessEnc, xmlEnc }), + bomEnc, xmlGuessEnc, xmlEnc, is); + } + encoding = bomEnc; + } else { + throw new XmlStreamReaderException(RAW_EX_2.format(new Object[] { + bomEnc, xmlGuessEnc, xmlEnc }), bomEnc, xmlGuessEnc, + xmlEnc, is); + } + return encoding; + } + + // InputStream is passed for XmlStreamReaderException creation only + String calculateHttpEncoding(final String cTMime, final String cTEnc, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final InputStream is, + final boolean lenient) throws IOException { + String encoding; + if (lenient & xmlEnc != null) { + encoding = xmlEnc; + } else { + final boolean appXml = isAppXml(cTMime); + final boolean textXml = isTextXml(cTMime); + if (appXml || textXml) { + if (cTEnc == null) { + if (appXml) { + encoding = calculateRawEncoding(bomEnc, xmlGuessEnc, + xmlEnc, is); + } else { + encoding = defaultEncoding == null ? US_ASCII + : defaultEncoding; + } + } else if (bomEnc != null + && (cTEnc.equals(UTF_16BE) || cTEnc.equals(UTF_16LE))) { + throw new XmlStreamReaderException(HTTP_EX_1 + .format(new Object[] { cTMime, cTEnc, bomEnc, + xmlGuessEnc, xmlEnc }), cTMime, cTEnc, + bomEnc, xmlGuessEnc, xmlEnc, is); + } else if (cTEnc.equals(UTF_16)) { + if (bomEnc != null && bomEnc.startsWith(UTF_16)) { + encoding = bomEnc; + } else { + throw new XmlStreamReaderException(HTTP_EX_2 + .format(new Object[] { cTMime, cTEnc, bomEnc, + xmlGuessEnc, xmlEnc }), cTMime, cTEnc, + bomEnc, xmlGuessEnc, xmlEnc, is); + } + } else if (bomEnc != null + && (cTEnc.equals(UTF_32BE) || cTEnc.equals(UTF_32LE))) { + throw new XmlStreamReaderException(HTTP_EX_1 + .format(new Object[] { cTMime, cTEnc, bomEnc, + xmlGuessEnc, xmlEnc }), cTMime, cTEnc, + bomEnc, xmlGuessEnc, xmlEnc, is); + } else if (cTEnc.equals(UTF_32)) { + if (bomEnc != null && bomEnc.startsWith(UTF_32)) { + encoding = bomEnc; + } else { + throw new XmlStreamReaderException(HTTP_EX_2 + .format(new Object[] { cTMime, cTEnc, bomEnc, + xmlGuessEnc, xmlEnc }), cTMime, cTEnc, + bomEnc, xmlGuessEnc, xmlEnc, is); + } + } else { + encoding = cTEnc; + } + } else { + throw new XmlStreamReaderException(HTTP_EX_3 + .format(new Object[] { cTMime, cTEnc, bomEnc, + xmlGuessEnc, xmlEnc }), cTMime, cTEnc, bomEnc, + xmlGuessEnc, xmlEnc, is); + } + } + return encoding; + } + + // returns MIME type or NULL if httpContentType is NULL + static String getContentTypeMime(final String httpContentType) { + String mime = null; + if (httpContentType != null) { + final int i = httpContentType.indexOf(";"); + mime = (i == -1 ? httpContentType : httpContentType.substring(0, + i)).trim(); + } + return mime; + } + + private static final Pattern CHARSET_PATTERN = Pattern + .compile("charset=[\"']?([.[^; \"']]*)[\"']?"); + + // returns charset parameter value, NULL if not present, NULL if + // httpContentType is NULL + static String getContentTypeEncoding(final String httpContentType) { + String encoding = null; + if (httpContentType != null) { + final int i = httpContentType.indexOf(";"); + if (i > -1) { + final String postMime = httpContentType.substring(i + 1); + final Matcher m = CHARSET_PATTERN.matcher(postMime); + encoding = m.find() ? m.group(1) : null; + encoding = encoding != null ? encoding.toUpperCase() : null; + } + } + return encoding; + } + + // returns the BOM in the stream, NULL if not present, + // if there was BOM the in the stream it is consumed + static String getBOMEncoding(final BufferedInputStream is) + throws IOException { + String encoding = null; + final int[] bytes = new int[3]; + is.mark(3); + bytes[0] = is.read(); + bytes[1] = is.read(); + bytes[2] = is.read(); + + if (bytes[0] == 0xFE && bytes[1] == 0xFF) { + encoding = UTF_16BE; + is.reset(); + is.read(); + is.read(); + } else if (bytes[0] == 0xFF && bytes[1] == 0xFE) { + encoding = UTF_16LE; + is.reset(); + is.read(); + is.read(); + } else if (bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) { + encoding = UTF_8; + } else { + is.reset(); + } + return encoding; + } + + // returns the best guess for the encoding by looking the first bytes of the + // stream, ', NULL if none + private static String getXmlProlog(final BufferedInputStream is, final String guessedEnc) + throws IOException { + String encoding = null; + if (guessedEnc != null) { + final byte[] bytes = new byte[BUFFER_SIZE]; + is.mark(BUFFER_SIZE); + int offset = 0; + int max = BUFFER_SIZE; + int c = is.read(bytes, offset, max); + int firstGT = -1; + String xmlProlog = ""; // avoid possible NPE warning (cannot happen; this just silences the warning) + while (c != -1 && firstGT == -1 && offset < BUFFER_SIZE) { + offset += c; + max -= c; + c = is.read(bytes, offset, max); + xmlProlog = new String(bytes, 0, offset, guessedEnc); + firstGT = xmlProlog.indexOf('>'); + } + if (firstGT == -1) { + if (c == -1) { + throw new IOException("Unexpected end of XML stream"); + } else { + throw new IOException( + "XML prolog or ROOT element not found on first " + + offset + " bytes"); + } + } + final int bytesRead = offset; + if (bytesRead > 0) { + is.reset(); + final BufferedReader bReader = new BufferedReader(new StringReader( + xmlProlog.substring(0, firstGT + 1))); + final StringBuffer prolog = new StringBuffer(); + String line = bReader.readLine(); + while (line != null) { + prolog.append(line); + line = bReader.readLine(); + } + final Matcher m = ENCODING_PATTERN.matcher(prolog); + if (m.find()) { + encoding = m.group(1).toUpperCase(); + encoding = encoding.substring(1, encoding.length() - 1); + } + } + } + return encoding; + } + + // indicates if the MIME type belongs to the APPLICATION XML family + static boolean isAppXml(final String mime) { + return mime != null + && (mime.equals("application/xml") + || mime.equals("application/xml-dtd") + || mime + .equals("application/xml-external-parsed-entity") || mime + .startsWith("application/") && mime.endsWith("+xml")); + } + + // indicates if the MIME type belongs to the TEXT XML family + static boolean isTextXml(final String mime) { + return mime != null + && (mime.equals("text/xml") + || mime.equals("text/xml-external-parsed-entity") || mime + .startsWith("text/") && mime.endsWith("+xml")); + } + + private static final MessageFormat RAW_EX_1 = new MessageFormat( + "Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] encoding mismatch"); + + private static final MessageFormat RAW_EX_2 = new MessageFormat( + "Invalid encoding, BOM [{0}] XML guess [{1}] XML prolog [{2}] unknown BOM"); + + private static final MessageFormat HTTP_EX_1 = new MessageFormat( + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], BOM must be NULL"); + + private static final MessageFormat HTTP_EX_2 = new MessageFormat( + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], encoding mismatch"); + + private static final MessageFormat HTTP_EX_3 = new MessageFormat( + "Invalid encoding, CT-MIME [{0}] CT-Enc [{1}] BOM [{2}] XML guess [{3}] XML prolog [{4}], Invalid MIME"); + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderException.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderException.java" new file mode 100644 index 0000000000000000000000000000000000000000..d1d5cd0f62d668aa0aa5dc6285064f80fdcf29cf --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderException.java" @@ -0,0 +1,85 @@ +/* + * 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.input.compatibility; + +import java.io.InputStream; + +/** + * The XmlStreamReaderException is thrown by the XmlStreamReader constructors if + * the charset encoding can not be determined according to the XML 1.0 + * specification and RFC 3023. + *

+ * The exception returns the unconsumed InputStream to allow the application to + * do an alternate processing with the stream. Note that the original + * InputStream given to the XmlStreamReader cannot be used as that one has been + * already read. + * + * @version $Id: XmlStreamReaderException.java 1415850 2012-11-30 20:51:39Z ggregory $ + */ +public class XmlStreamReaderException extends org.apache.commons.io.input.XmlStreamReaderException { + + private static final long serialVersionUID = 1L; + + private final InputStream is; + + /** + * Creates an exception instance if the charset encoding could not be + * determined. + *

+ * Instances of this exception are thrown by the XmlStreamReader. + * + * @param msg message describing the reason for the exception. + * @param bomEnc BOM encoding. + * @param xmlGuessEnc XML guess encoding. + * @param xmlEnc XML prolog encoding. + * @param is the unconsumed InputStream. + */ + public XmlStreamReaderException(final String msg, final String bomEnc, + final String xmlGuessEnc, final String xmlEnc, final InputStream is) { + this(msg, null, null, bomEnc, xmlGuessEnc, xmlEnc, is); + } + + /** + * Creates an exception instance if the charset encoding could not be + * determined. + *

+ * Instances of this exception are thrown by the XmlStreamReader. + * + * @param msg message describing the reason for the exception. + * @param ctMime MIME type in the content-type. + * @param ctEnc encoding in the content-type. + * @param bomEnc BOM encoding. + * @param xmlGuessEnc XML guess encoding. + * @param xmlEnc XML prolog encoding. + * @param is the unconsumed InputStream. + */ + public XmlStreamReaderException(final String msg, final String ctMime, final String ctEnc, + final String bomEnc, final String xmlGuessEnc, final String xmlEnc, final InputStream is) { + super(msg, ctMime, ctEnc, bomEnc, xmlGuessEnc, xmlEnc); + this.is = is; + } + + /** + * Returns the unconsumed InputStream to allow the application to do an + * alternate encoding detection on the InputStream. + * + * @return the unconsumed InputStream. + */ + public InputStream getInputStream() { + return is; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..d1c7d10f8972bb22d71c2b4a4eb30787315970e2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java" @@ -0,0 +1,55 @@ +/* + * 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.input.compatibility; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import org.apache.commons.io.input.XmlStreamReaderUtilitiesTest; + +/** + * Test compatibility of the original XmlStreamReader (before all the refactoring). + */ +public class XmlStreamReaderUtilitiesCompatibilityTest extends XmlStreamReaderUtilitiesTest { + + @Override + protected String calculateRawEncoding(final String bomEnc, final String xmlGuessEnc, final String xmlEnc, + final String defaultEncoding) throws IOException { + final MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding); + final String enc = mock.calculateRawEncoding(bomEnc, xmlGuessEnc, xmlEnc, null); + mock.close(); + return enc; + } + @Override + protected String calculateHttpEncoding(final String httpContentType, final String bomEnc, final String xmlGuessEnc, + final String xmlEnc, final boolean lenient, final String defaultEncoding) throws IOException { + final MockXmlStreamReader mock = new MockXmlStreamReader(defaultEncoding); + String enc = mock.calculateHttpEncoding( + XmlStreamReader.getContentTypeMime(httpContentType), + XmlStreamReader.getContentTypeEncoding(httpContentType), + bomEnc, xmlGuessEnc, xmlEnc, null, lenient); + mock.close(); + return enc; + } + + /** Mock {@link XmlStreamReader} implementation */ + private static class MockXmlStreamReader extends XmlStreamReader { + MockXmlStreamReader(final String defaultEncoding) throws IOException { + super(new ByteArrayInputStream("".getBytes()), null, true, defaultEncoding); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..dd47997ddedd4a1bb73eec658674c5ce35f4b207 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java" @@ -0,0 +1,163 @@ +/* + * 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.monitor; + +import java.io.File; +import java.io.FileFilter; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.FileFilterUtils; +import org.apache.commons.io.filefilter.HiddenFileFilter; +import org.apache.commons.io.filefilter.IOFileFilter; +import org.apache.commons.io.testtools.TestUtils; +import org.junit.After; +import org.junit.Before; + +import static org.apache.commons.io.testtools.TestUtils.sleepQuietly; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * {@link FileAlterationObserver} Test Case. + */ +public abstract class AbstractMonitorTestCase { + + /** File observer */ + protected FileAlterationObserver observer; + + /** Listener which collects file changes */ + protected CollectionFileListener listener; + + /** Test diretory name */ + protected String testDirName = null; + + /** Directory for test files */ + protected File testDir; + + /** Time in milliseconds to pause in tests */ + protected long pauseTime = 100L; + + @Before + public void setUp() throws Exception { + testDir = new File(new File("."), testDirName); + if (testDir.exists()) { + FileUtils.cleanDirectory(testDir); + } else { + testDir.mkdir(); + } + + final IOFileFilter files = FileFilterUtils.fileFileFilter(); + final IOFileFilter javaSuffix = FileFilterUtils.suffixFileFilter(".java"); + final IOFileFilter fileFilter = FileFilterUtils.and(files, javaSuffix); + + final IOFileFilter directories = FileFilterUtils.directoryFileFilter(); + final IOFileFilter visible = HiddenFileFilter.VISIBLE; + final IOFileFilter dirFilter = FileFilterUtils.and(directories, visible); + + final IOFileFilter filter = FileFilterUtils.or(dirFilter, fileFilter); + + createObserver(testDir, filter); + } + + /** + * Create a {@link FileAlterationObserver}. + * + * @param file The directory to observe + * @param fileFilter The file filter to apply + */ + protected void createObserver(final File file, final FileFilter fileFilter) { + observer = new FileAlterationObserver(file, fileFilter); + observer.addListener(listener); + observer.addListener(new FileAlterationListenerAdaptor()); + try { + observer.initialize(); + } catch (final Exception e) { + fail("Observer init() threw " + e); + } + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(testDir); + } + + /** + * Check all the Collections are empty + * + * @param label the label to use for this check + */ + protected void checkCollectionsEmpty(final String label) { + checkCollectionSizes("EMPTY-" + label, 0, 0, 0, 0, 0, 0); + } + + /** + * Check all the Collections have the expected sizes. + * + * @param label the label to use for this check + * @param dirCreate expected number of dirs created + * @param dirChange expected number of dirs changed + * @param dirDelete expected number of dirs deleted + * @param fileCreate expected number of files created + * @param fileChange expected number of files changed + * @param fileDelete expected number of files deleted + */ + protected void checkCollectionSizes(String label, + final int dirCreate, + final int dirChange, + final int dirDelete, + final int fileCreate, + final int fileChange, + final int fileDelete) { + label = label + "[" + listener.getCreatedDirectories().size() + + " " + listener.getChangedDirectories().size() + + " " + listener.getDeletedDirectories().size() + + " " + listener.getCreatedFiles().size() + + " " + listener.getChangedFiles().size() + + " " + listener.getDeletedFiles().size() + "]"; + assertEquals(label + ": No. of directories created", dirCreate, listener.getCreatedDirectories().size()); + assertEquals(label + ": No. of directories changed", dirChange, listener.getChangedDirectories().size()); + assertEquals(label + ": No. of directories deleted", dirDelete, listener.getDeletedDirectories().size()); + assertEquals(label + ": No. of files created", fileCreate, listener.getCreatedFiles().size()); + assertEquals(label + ": No. of files changed", fileChange, listener.getChangedFiles().size()); + assertEquals(label + ": No. of files deleted", fileDelete, listener.getDeletedFiles().size()); + } + + /** + * Either creates a file if it doesn't exist or updates the last modified date/time + * if it does. + * + * @param file The file to touch + * @return The file + */ + protected File touch(File file) { + final long lastModified = file.exists() ? file.lastModified() : 0; + try { + FileUtils.touch(file); + file = new File(file.getParent(), file.getName()); + while (lastModified == file.lastModified()) { + sleepQuietly(pauseTime); + FileUtils.touch(file); + file = new File(file.getParent(), file.getName()); + } + } catch (final Exception e) { + fail("Touching " + file + ": " + e); + } + sleepQuietly(pauseTime); + return file; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java" new file mode 100644 index 0000000000000000000000000000000000000000..8d847430ea412a5f460e657497d7b17ca2e62e44 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/CollectionFileListener.java" @@ -0,0 +1,187 @@ +/* + * 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.monitor; + +import java.io.File; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; + +/** + * {@link FileAlterationListener} implementation that adds created, changed and deleted + * files/directories to a set of {@link Collection}s. + */ +public class CollectionFileListener implements FileAlterationListener, Serializable { + + private static final long serialVersionUID = 939724715678693963L; + private final boolean clearOnStart; + private final Collection createdFiles = new ArrayList(); + private final Collection changedFiles = new ArrayList(); + private final Collection deletedFiles = new ArrayList(); + private final Collection createdDirectories = new ArrayList(); + private final Collection changedDirectories = new ArrayList(); + private final Collection deletedDirectories = new ArrayList(); + + /** + * Create a new observer. + * + * @param clearOnStart true if clear() should be called by onStart(). + */ + public CollectionFileListener(final boolean clearOnStart) { + this.clearOnStart = clearOnStart; + } + + /** + * File system observer started checking event. + * + * @param observer The file system observer + */ + public void onStart(final FileAlterationObserver observer) { + if (clearOnStart) { + clear(); + } + } + + /** + * Clear file collections. + */ + public void clear() { + createdFiles.clear(); + changedFiles.clear(); + deletedFiles.clear(); + createdDirectories.clear(); + changedDirectories.clear(); + deletedDirectories.clear(); + } + + /** + * Return the set of changed directories. + * + * @return Directories which have changed + */ + public Collection getChangedDirectories() { + return changedDirectories; + } + + /** + * Return the set of changed files. + * + * @return Files which have changed + */ + public Collection getChangedFiles() { + return changedFiles; + } + + /** + * Return the set of created directories. + * + * @return Directories which have been created + */ + public Collection getCreatedDirectories() { + return createdDirectories; + } + + /** + * Return the set of created files. + * + * @return Files which have been created + */ + public Collection getCreatedFiles() { + return createdFiles; + } + + /** + * Return the set of deleted directories. + * + * @return Directories which been deleted + */ + public Collection getDeletedDirectories() { + return deletedDirectories; + } + + /** + * Return the set of deleted files. + * + * @return Files which been deleted + */ + public Collection getDeletedFiles() { + return deletedFiles; + } + + /** + * Directory created Event. + * + * @param directory The directory created + */ + public void onDirectoryCreate(final File directory) { + createdDirectories.add(directory); + } + + /** + * Directory changed Event. + * + * @param directory The directory changed + */ + public void onDirectoryChange(final File directory) { + changedDirectories.add(directory); + } + + /** + * Directory deleted Event. + * + * @param directory The directory deleted + */ + public void onDirectoryDelete(final File directory) { + deletedDirectories.add(directory); + } + + /** + * File created Event. + * + * @param file The file created + */ + public void onFileCreate(final File file) { + createdFiles.add(file); + } + + /** + * File changed Event. + * + * @param file The file changed + */ + public void onFileChange(final File file) { + changedFiles.add(file); + } + + /** + * File deleted Event. + * + * @param file The file deleted + */ + public void onFileDelete(final File file) { + deletedFiles.add(file); + } + + /** + * File system observer finished checking event. + * + * @param observer The file system observer + */ + public void onStop(final FileAlterationObserver observer) { + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..ec8b792611c01f861a015389f755a3934aa41b44 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/FileAlterationMonitorTestCase.java" @@ -0,0 +1,187 @@ +/* + * 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.monitor; + +import org.apache.commons.io.testtools.TestUtils; +import org.junit.Test; + +import java.io.File; +import java.util.Collection; +import java.util.Iterator; +import java.util.concurrent.Executors; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * {@link FileAlterationMonitor} Test Case. + */ +public class FileAlterationMonitorTestCase extends AbstractMonitorTestCase { + + /** + * Construct a new test case. + * + */ + public FileAlterationMonitorTestCase() { + testDirName = "test-monitor"; + listener = new CollectionFileListener(false); + } + + /** + * Test default constructor. + */ + @Test + public void testDefaultConstructor() { + final FileAlterationMonitor monitor = new FileAlterationMonitor(); + assertEquals("Interval", 10000, monitor.getInterval()); + } + + /** + * Test add/remove observers. + */ + @Test + public void testAddRemoveObservers() { + FileAlterationObserver[] observers = null; + FileAlterationMonitor monitor = null; + + // Null Observers + monitor = new FileAlterationMonitor(123, observers); + assertEquals("Interval", 123, monitor.getInterval()); + assertFalse("Observers[1]", monitor.getObservers().iterator().hasNext()); + + // Null Observer + observers = new FileAlterationObserver[1]; // observer is null + monitor = new FileAlterationMonitor(456, observers); + assertFalse("Observers[2]", monitor.getObservers().iterator().hasNext()); + + // Null Observer + monitor.addObserver(null); + assertFalse("Observers[3]", monitor.getObservers().iterator().hasNext()); + monitor.removeObserver(null); + + // Add Observer + final FileAlterationObserver observer = new FileAlterationObserver("foo"); + monitor.addObserver(observer); + final Iterator it = monitor.getObservers().iterator(); + assertTrue("Observers[4]", it.hasNext()); + assertEquals("Added", observer, it.next()); + assertFalse("Observers[5]", it.hasNext()); + + // Remove Observer + monitor.removeObserver(observer); + assertFalse("Observers[6]", monitor.getObservers().iterator().hasNext()); + } + + /** + * Test checkAndNotify() method + */ + @Test + public void testMonitor() { + try { + final long interval = 100; + listener.clear(); + final FileAlterationMonitor monitor = new FileAlterationMonitor(interval, observer); + assertEquals("Interval", interval, monitor.getInterval()); + monitor.start(); + + try { + monitor.start(); // try and start again + } catch (final IllegalStateException e) { + // expected result, monitor already running + } + + // Create a File + checkCollectionsEmpty("A"); + File file1 = touch(new File(testDir, "file1.java")); + checkFile("Create", file1, listener.getCreatedFiles()); + listener.clear(); + + // Update a file + checkCollectionsEmpty("B"); + file1 = touch(file1); + checkFile("Update", file1, listener.getChangedFiles()); + listener.clear(); + + // Delete a file + checkCollectionsEmpty("C"); + file1.delete(); + checkFile("Delete", file1, listener.getDeletedFiles()); + listener.clear(); + + // Stop monitoring + monitor.stop(); + + try { + monitor.stop(); // try and stop again + } catch (final IllegalStateException e) { + // expected result, monitor already stopped + } + } catch (final Exception e) { + e.printStackTrace(); + fail("Threw " + e); + } + } + + /** + * Test using a thread factory. + */ + @Test + public void testThreadFactory() { + try { + final long interval = 100; + listener.clear(); + final FileAlterationMonitor monitor = new FileAlterationMonitor(interval, observer); + monitor.setThreadFactory(Executors.defaultThreadFactory()); + assertEquals("Interval", interval, monitor.getInterval()); + monitor.start(); + + // Create a File + checkCollectionsEmpty("A"); + final File file2 = touch(new File(testDir, "file2.java")); + checkFile("Create", file2, listener.getCreatedFiles()); + listener.clear(); + + // Delete a file + checkCollectionsEmpty("B"); + file2.delete(); + checkFile("Delete", file2, listener.getDeletedFiles()); + listener.clear(); + + // Stop monitoring + monitor.stop(); + + } catch (final Exception e) { + e.printStackTrace(); + fail("Threw " + e); + } + } + + /** + * Check all the File Collections have the expected sizes. + */ + private void checkFile(final String label, final File file, final Collection files) { + for (int i = 0; i < 20; i++) { + if (files.contains(file)) { + return; // found, test passes + } + TestUtils.sleepQuietly(pauseTime); + } + fail(label + " " + file + " not found"); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..13758dc1da3d29f8742a7c125b9fe9de682bfe18 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/monitor/FileAlterationObserverTestCase.java" @@ -0,0 +1,406 @@ +/* + * 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.monitor; + +import java.io.File; +import java.io.FileFilter; +import java.util.Iterator; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.CanReadFileFilter; +import org.apache.commons.io.filefilter.FileFilterUtils; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * {@link FileAlterationObserver} Test Case. + */ +public class FileAlterationObserverTestCase extends AbstractMonitorTestCase { + + /** + * Construct a new test case. + * + */ + public FileAlterationObserverTestCase() { + testDirName = "test-observer"; + listener = new CollectionFileListener(true); + } + + /** + * Test add/remove listeners. + */ + @Test + public void testAddRemoveListeners() { + final FileAlterationObserver observer = new FileAlterationObserver("/foo"); + // Null Listener + observer.addListener(null); + assertFalse("Listeners[1]", observer.getListeners().iterator().hasNext()); + observer.removeListener(null); + assertFalse("Listeners[2]", observer.getListeners().iterator().hasNext()); + + // Add Listener + final FileAlterationListenerAdaptor listener = new FileAlterationListenerAdaptor(); + observer.addListener(listener); + final Iterator it = observer.getListeners().iterator(); + assertTrue("Listeners[3]", it.hasNext()); + assertEquals("Added", listener, it.next()); + assertFalse("Listeners[4]", it.hasNext()); + + // Remove Listener + observer.removeListener(listener); + assertFalse("Listeners[5]", observer.getListeners().iterator().hasNext()); + } + + /** + * Test toString(). + */ + @Test + public void testToString() { + final File file = new File("/foo"); + FileAlterationObserver observer = null; + + observer = new FileAlterationObserver(file); + assertEquals("FileAlterationObserver[file='" + file.getPath() + "', listeners=0]", + observer.toString()); + + observer = new FileAlterationObserver(file, CanReadFileFilter.CAN_READ); + assertEquals("FileAlterationObserver[file='" + file.getPath() + "', CanReadFileFilter, listeners=0]", + observer.toString()); + + assertEquals(file, observer.getDirectory()); + } + + /** + * Test checkAndNotify() method + */ + @Test + public void testDirectory() { + try { + checkAndNotify(); + checkCollectionsEmpty("A"); + final File testDirA = new File(testDir, "test-dir-A"); + final File testDirB = new File(testDir, "test-dir-B"); + final File testDirC = new File(testDir, "test-dir-C"); + testDirA.mkdir(); + testDirB.mkdir(); + testDirC.mkdir(); + final File testDirAFile1 = touch(new File(testDirA, "A-file1.java")); + final File testDirAFile2 = touch(new File(testDirA, "A-file2.txt")); // filter should ignore this + final File testDirAFile3 = touch(new File(testDirA, "A-file3.java")); + File testDirAFile4 = touch(new File(testDirA, "A-file4.java")); + final File testDirBFile1 = touch(new File(testDirB, "B-file1.java")); + + checkAndNotify(); + checkCollectionSizes("B", 3, 0, 0, 4, 0, 0); + assertTrue("B testDirA", listener.getCreatedDirectories().contains(testDirA)); + assertTrue("B testDirB", listener.getCreatedDirectories().contains(testDirB)); + assertTrue("B testDirC", listener.getCreatedDirectories().contains(testDirC)); + assertTrue("B testDirAFile1", listener.getCreatedFiles().contains(testDirAFile1)); + assertFalse("B testDirAFile2", listener.getCreatedFiles().contains(testDirAFile2)); + assertTrue("B testDirAFile3", listener.getCreatedFiles().contains(testDirAFile3)); + assertTrue("B testDirAFile4", listener.getCreatedFiles().contains(testDirAFile4)); + assertTrue("B testDirBFile1", listener.getCreatedFiles().contains(testDirBFile1)); + + checkAndNotify(); + checkCollectionsEmpty("C"); + + testDirAFile4 = touch(testDirAFile4); + FileUtils.deleteDirectory(testDirB); + checkAndNotify(); + checkCollectionSizes("D", 0, 0, 1, 0, 1, 1); + assertTrue("D testDirB", listener.getDeletedDirectories().contains(testDirB)); + assertTrue("D testDirAFile4", listener.getChangedFiles().contains(testDirAFile4)); + assertTrue("D testDirBFile1", listener.getDeletedFiles().contains(testDirBFile1)); + + FileUtils.deleteDirectory(testDir); + checkAndNotify(); + checkCollectionSizes("E", 0, 0, 2, 0, 0, 3); + assertTrue("E testDirA", listener.getDeletedDirectories().contains(testDirA)); + assertTrue("E testDirAFile1", listener.getDeletedFiles().contains(testDirAFile1)); + assertFalse("E testDirAFile2", listener.getDeletedFiles().contains(testDirAFile2)); + assertTrue("E testDirAFile3", listener.getDeletedFiles().contains(testDirAFile3)); + assertTrue("E testDirAFile4", listener.getDeletedFiles().contains(testDirAFile4)); + + testDir.mkdir(); + checkAndNotify(); + checkCollectionsEmpty("F"); + + checkAndNotify(); + checkCollectionsEmpty("G"); + } catch (final Exception e) { + e.printStackTrace(); + fail("Threw " + e); + } + } + + /** + * Test checkAndNotify() creating + */ + @Test + public void testFileCreate() { + try { + checkAndNotify(); + checkCollectionsEmpty("A"); + File testDirA = new File(testDir, "test-dir-A"); + testDirA.mkdir(); + testDir = touch(testDir); + testDirA = touch(testDirA); + File testDirAFile1 = new File(testDirA, "A-file1.java"); + final File testDirAFile2 = touch(new File(testDirA, "A-file2.java")); + File testDirAFile3 = new File(testDirA, "A-file3.java"); + final File testDirAFile4 = touch(new File(testDirA, "A-file4.java")); + File testDirAFile5 = new File(testDirA, "A-file5.java"); + + checkAndNotify(); + checkCollectionSizes("B", 1, 0, 0, 2, 0, 0); + assertFalse("B testDirAFile1", listener.getCreatedFiles().contains(testDirAFile1)); + assertTrue("B testDirAFile2", listener.getCreatedFiles().contains(testDirAFile2)); + assertFalse("B testDirAFile3", listener.getCreatedFiles().contains(testDirAFile3)); + assertTrue("B testDirAFile4", listener.getCreatedFiles().contains(testDirAFile4)); + assertFalse("B testDirAFile5", listener.getCreatedFiles().contains(testDirAFile5)); + + assertFalse("B testDirAFile1 exists", testDirAFile1.exists()); + assertTrue("B testDirAFile2 exists", testDirAFile2.exists()); + assertFalse("B testDirAFile3 exists", testDirAFile3.exists()); + assertTrue("B testDirAFile4 exists", testDirAFile4.exists()); + assertFalse("B testDirAFile5 exists", testDirAFile5.exists()); + + checkAndNotify(); + checkCollectionsEmpty("C"); + + // Create file with name < first entry + testDirAFile1 = touch(testDirAFile1); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("D", 0, 1, 0, 1, 0, 0); + assertTrue("D testDirAFile1 exists", testDirAFile1.exists()); + assertTrue("D testDirAFile1", listener.getCreatedFiles().contains(testDirAFile1)); + + // Create file with name between 2 entries + testDirAFile3 = touch(testDirAFile3); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("E", 0, 1, 0, 1, 0, 0); + assertTrue("E testDirAFile3 exists", testDirAFile3.exists()); + assertTrue("E testDirAFile3", listener.getCreatedFiles().contains(testDirAFile3)); + + // Create file with name > last entry + testDirAFile5 = touch(testDirAFile5); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("F", 0, 1, 0, 1, 0, 0); + assertTrue("F testDirAFile5 exists", testDirAFile5.exists()); + assertTrue("F testDirAFile5", listener.getCreatedFiles().contains(testDirAFile5)); + } catch (final Exception e) { + fail("Threw " + e); + } + } + + /** + * Test checkAndNotify() creating + */ + @Test + public void testFileUpdate() { + try { + checkAndNotify(); + checkCollectionsEmpty("A"); + File testDirA = new File(testDir, "test-dir-A"); + testDirA.mkdir(); + testDir = touch(testDir); + testDirA = touch(testDirA); + File testDirAFile1 = touch(new File(testDirA, "A-file1.java")); + final File testDirAFile2 = touch(new File(testDirA, "A-file2.java")); + File testDirAFile3 = touch(new File(testDirA, "A-file3.java")); + final File testDirAFile4 = touch(new File(testDirA, "A-file4.java")); + File testDirAFile5 = touch(new File(testDirA, "A-file5.java")); + + checkAndNotify(); + checkCollectionSizes("B", 1, 0, 0, 5, 0, 0); + assertTrue("B testDirAFile1", listener.getCreatedFiles().contains(testDirAFile1)); + assertTrue("B testDirAFile2", listener.getCreatedFiles().contains(testDirAFile2)); + assertTrue("B testDirAFile3", listener.getCreatedFiles().contains(testDirAFile3)); + assertTrue("B testDirAFile4", listener.getCreatedFiles().contains(testDirAFile4)); + assertTrue("B testDirAFile5", listener.getCreatedFiles().contains(testDirAFile5)); + + assertTrue("B testDirAFile1 exists", testDirAFile1.exists()); + assertTrue("B testDirAFile2 exists", testDirAFile2.exists()); + assertTrue("B testDirAFile3 exists", testDirAFile3.exists()); + assertTrue("B testDirAFile4 exists", testDirAFile4.exists()); + assertTrue("B testDirAFile5 exists", testDirAFile5.exists()); + + checkAndNotify(); + checkCollectionsEmpty("C"); + + // Update first entry + testDirAFile1 = touch(testDirAFile1); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("D", 0, 1, 0, 0, 1, 0); + assertTrue("D testDirAFile1", listener.getChangedFiles().contains(testDirAFile1)); + + // Update file with name between 2 entries + testDirAFile3 = touch(testDirAFile3); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("E", 0, 1, 0, 0, 1, 0); + assertTrue("E testDirAFile3", listener.getChangedFiles().contains(testDirAFile3)); + + // Update last entry + testDirAFile5 = touch(testDirAFile5); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("F", 0, 1, 0, 0, 1, 0); + assertTrue("F testDirAFile5", listener.getChangedFiles().contains(testDirAFile5)); + } catch (final Exception e) { + fail("Threw " + e); + } + } + + /** + * Test checkAndNotify() deleting + */ + @Test + public void testFileDelete() { + try { + checkAndNotify(); + checkCollectionsEmpty("A"); + File testDirA = new File(testDir, "test-dir-A"); + testDirA.mkdir(); + testDir = touch(testDir); + testDirA = touch(testDirA); + final File testDirAFile1 = touch(new File(testDirA, "A-file1.java")); + final File testDirAFile2 = touch(new File(testDirA, "A-file2.java")); + final File testDirAFile3 = touch(new File(testDirA, "A-file3.java")); + final File testDirAFile4 = touch(new File(testDirA, "A-file4.java")); + final File testDirAFile5 = touch(new File(testDirA, "A-file5.java")); + + assertTrue("B testDirAFile1 exists", testDirAFile1.exists()); + assertTrue("B testDirAFile2 exists", testDirAFile2.exists()); + assertTrue("B testDirAFile3 exists", testDirAFile3.exists()); + assertTrue("B testDirAFile4 exists", testDirAFile4.exists()); + assertTrue("B testDirAFile5 exists", testDirAFile5.exists()); + + checkAndNotify(); + checkCollectionSizes("B", 1, 0, 0, 5, 0, 0); + assertTrue("B testDirAFile1", listener.getCreatedFiles().contains(testDirAFile1)); + assertTrue("B testDirAFile2", listener.getCreatedFiles().contains(testDirAFile2)); + assertTrue("B testDirAFile3", listener.getCreatedFiles().contains(testDirAFile3)); + assertTrue("B testDirAFile4", listener.getCreatedFiles().contains(testDirAFile4)); + assertTrue("B testDirAFile5", listener.getCreatedFiles().contains(testDirAFile5)); + + checkAndNotify(); + checkCollectionsEmpty("C"); + + // Delete first entry + FileUtils.deleteQuietly(testDirAFile1); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("D", 0, 1, 0, 0, 0, 1); + assertFalse("D testDirAFile1 exists", testDirAFile1.exists()); + assertTrue("D testDirAFile1", listener.getDeletedFiles().contains(testDirAFile1)); + + // Delete file with name between 2 entries + FileUtils.deleteQuietly(testDirAFile3); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("E", 0, 1, 0, 0, 0, 1); + assertFalse("E testDirAFile3 exists", testDirAFile3.exists()); + assertTrue("E testDirAFile3", listener.getDeletedFiles().contains(testDirAFile3)); + + // Delete last entry + FileUtils.deleteQuietly(testDirAFile5); + testDirA = touch(testDirA); + checkAndNotify(); + checkCollectionSizes("F", 0, 1, 0, 0, 0, 1); + assertFalse("F testDirAFile5 exists", testDirAFile5.exists()); + assertTrue("F testDirAFile5", listener.getDeletedFiles().contains(testDirAFile5)); + + } catch (final Exception e) { + fail("Threw " + e); + } + } + + /** + * Test checkAndNotify() method + */ + @Test + public void testObserveSingleFile() { + try { + final File testDirA = new File(testDir, "test-dir-A"); + File testDirAFile1 = new File(testDirA, "A-file1.java"); + testDirA.mkdir(); + + final FileFilter nameFilter = FileFilterUtils.nameFileFilter(testDirAFile1.getName()); + createObserver(testDirA, nameFilter); + checkAndNotify(); + checkCollectionsEmpty("A"); + assertFalse("A testDirAFile1 exists", testDirAFile1.exists()); + + // Create + testDirAFile1 = touch(testDirAFile1); + File testDirAFile2 = touch(new File(testDirA, "A-file2.txt")); /* filter should ignore */ + File testDirAFile3 = touch(new File(testDirA, "A-file3.java")); /* filter should ignore */ + assertTrue("B testDirAFile1 exists", testDirAFile1.exists()); + assertTrue("B testDirAFile2 exists", testDirAFile2.exists()); + assertTrue("B testDirAFile3 exists", testDirAFile3.exists()); + checkAndNotify(); + checkCollectionSizes("C", 0, 0, 0, 1, 0, 0); + assertTrue("C created", listener.getCreatedFiles().contains(testDirAFile1)); + assertFalse("C created", listener.getCreatedFiles().contains(testDirAFile2)); + assertFalse("C created", listener.getCreatedFiles().contains(testDirAFile3)); + + // Modify + testDirAFile1 = touch(testDirAFile1); + testDirAFile2 = touch(testDirAFile2); + testDirAFile3 = touch(testDirAFile3); + checkAndNotify(); + checkCollectionSizes("D", 0, 0, 0, 0, 1, 0); + assertTrue("D changed", listener.getChangedFiles().contains(testDirAFile1)); + assertFalse("D changed", listener.getChangedFiles().contains(testDirAFile2)); + assertFalse("D changed", listener.getChangedFiles().contains(testDirAFile3)); + + // Delete + FileUtils.deleteQuietly(testDirAFile1); + FileUtils.deleteQuietly(testDirAFile2); + FileUtils.deleteQuietly(testDirAFile3); + assertFalse("E testDirAFile1 exists", testDirAFile1.exists()); + assertFalse("E testDirAFile2 exists", testDirAFile2.exists()); + assertFalse("E testDirAFile3 exists", testDirAFile3.exists()); + checkAndNotify(); + checkCollectionSizes("E", 0, 0, 0, 0, 0, 1); + assertTrue("E deleted", listener.getDeletedFiles().contains(testDirAFile1)); + assertFalse("E deleted", listener.getDeletedFiles().contains(testDirAFile2)); + assertFalse("E deleted", listener.getDeletedFiles().contains(testDirAFile3)); + + } catch (final Exception e) { + fail("Threw " + e); + } + } + + /** + * Call {@link FileAlterationObserver#checkAndNotify()}. + * + * @throws Exception if an error occurs + */ + protected void checkAndNotify() throws Exception { + observer.checkAndNotify(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..8132db60d4d4022339662d39de15488d7a21a4f5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/AppendableOutputStreamTest.java" @@ -0,0 +1,53 @@ +/* + * 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.output; + +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; + +/** + * Unit tests for {@link AppendableOutputStream}. + * + * @version $Id: AppendableOutputStreamTest.java 1681007 2015-05-22 06:58:18Z britter $ + */ +public class AppendableOutputStreamTest { + + private AppendableOutputStream out; + + @Before + public void setUp() throws Exception { + out = new AppendableOutputStream(new StringBuilder()); + } + + @Test + public void testWriteStringBuilder() throws Exception { + String testData = "ABCD"; + + out.write(testData.getBytes()); + + assertEquals(testData, out.getAppendable().toString()); + } + + @Test + public void testWriteInt() throws Exception { + out.write((int) 'F'); + + assertEquals("F", out.getAppendable().toString()); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/BrokenOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/BrokenOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..b91d2ed752b1f081eb3ef6f8c4af3b6019b63bcb --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/BrokenOutputStreamTest.java" @@ -0,0 +1,87 @@ +/* + * 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.output; + +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.io.OutputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link BrokenOutputStream}. + */ +public class BrokenOutputStreamTest { + + private IOException exception; + + private OutputStream stream; + + @Before + public void setUp() { + exception = new IOException("test exception"); + stream = new BrokenOutputStream(exception); + } + + @Test + public void testWrite() { + try { + stream.write(1); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + + try { + stream.write(new byte[1]); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + + try { + stream.write(new byte[1], 0, 1); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + + @Test + public void testFlush() { + try { + stream.flush(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + + @Test + public void testClose() { + try { + stream.close(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertEquals(exception, e); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..794b5643ea6956005a7d91d7a9f5bf44f7a7b49e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java" @@ -0,0 +1,223 @@ +/* + * 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.output; + +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + +/** + * Basic unit tests for the alternative ByteArrayOutputStream implementation. + */ +public class ByteArrayOutputStreamTestCase { + + private static final byte[] DATA; + + static { + DATA = new byte[64]; + for (byte i = 0; i < 64; i++) { + DATA[i] = i; + } + } + + private int writeData(final ByteArrayOutputStream baout, + final java.io.ByteArrayOutputStream ref, + final int count) { + if (count > DATA.length) { + throw new IllegalArgumentException("Requesting too many bytes"); + } + if (count == 0) { + baout.write(100); + ref.write(100); + return 1; + } else { + baout.write(DATA, 0, count); + ref.write(DATA, 0, count); + return count; + } + } + + private int writeData(final ByteArrayOutputStream baout, + final java.io.ByteArrayOutputStream ref, + final int[] instructions) { + int written = 0; + for (final int instruction : instructions) { + written += writeData(baout, ref, instruction); + } + return written; + } + + private static boolean byteCmp(final byte[] src, final byte[] cmp) { + for (int i = 0; i < cmp.length; i++) { + if (src[i] != cmp[i]) { + return false; + } + } + return true; + } + + private void checkByteArrays(final byte[] expected, final byte[] actual) { + if (expected.length != actual.length) { + fail("Resulting byte arrays are not equally long"); + } + if (!byteCmp(expected, actual)) { + fail("Resulting byte arrays are not equal"); + } + } + + private void checkStreams( + final ByteArrayOutputStream actual, + final java.io.ByteArrayOutputStream expected) { + assertEquals("Sizes are not equal", expected.size(), actual.size()); + final byte[] buf = actual.toByteArray(); + final byte[] refbuf = expected.toByteArray(); + checkByteArrays(buf, refbuf); + } + + @Test + public void testToInputStream() throws IOException { + ByteArrayOutputStream baout = new ByteArrayOutputStream(); + java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream(); + + //Write 8224 bytes + writeData(baout, ref, 32); + for(int i=0;i<128;i++) { + writeData(baout, ref, 64); + } + + //Get data before more writes + InputStream in = baout.toInputStream(); + byte refData[] = ref.toByteArray(); + + //Write some more data + writeData(baout, ref, new int[] { 2, 4, 8, 16 }); + + //Check original data + byte baoutData[] = IOUtils.toByteArray(in); + assertEquals(8224, baoutData.length); + checkByteArrays(refData, baoutData); + + //Check all data written + baoutData = IOUtils.toByteArray(baout.toInputStream()); + refData = ref.toByteArray(); + assertEquals(8254, baoutData.length); + checkByteArrays(refData, baoutData); + baout.close(); + in.close(); + } + + @Test + public void testToInputStreamWithReset() throws IOException { + //Make sure reset() do not destroy InputStream returned from toInputStream() + ByteArrayOutputStream baout = new ByteArrayOutputStream(); + java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream(); + + //Write 8224 bytes + writeData(baout, ref, 32); + for(int i=0;i<128;i++) { + writeData(baout, ref, 64); + } + + //Get data before reset + InputStream in = baout.toInputStream(); + byte refData[] = ref.toByteArray(); + + //Reset and write some new data + baout.reset(); + ref.reset(); + writeData(baout, ref, new int[] { 2, 4, 8, 16 }); + + //Check original data + byte baoutData[] = IOUtils.toByteArray(in); + assertEquals(8224, baoutData.length); + checkByteArrays(refData, baoutData); + + //Check new data written after reset + baoutData = IOUtils.toByteArray(baout.toInputStream()); + refData = ref.toByteArray(); + assertEquals(30, baoutData.length); + checkByteArrays(refData, baoutData); + baout.close(); + in.close(); + } + + @Test + public void testStream() throws Exception { + int written; + + //The ByteArrayOutputStream is initialized with 32 bytes to match + //the original more closely for this test. + final ByteArrayOutputStream baout = new ByteArrayOutputStream(32); + final java.io.ByteArrayOutputStream ref = new java.io.ByteArrayOutputStream(); + + //First three writes + written = writeData(baout, ref, new int[] {4, 10, 22}); + assertEquals(36, written); + checkStreams(baout, ref); + + //Another two writes to see if there are any bad effects after toByteArray() + written = writeData(baout, ref, new int[] {20, 12}); + assertEquals(32, written); + checkStreams(baout, ref); + + //Now reset the streams + baout.reset(); + ref.reset(); + + //Test again to see if reset() had any bad effects + written = writeData(baout, ref, new int[] {5, 47, 33, 60, 1, 0, 8}); + assertEquals(155, written); + checkStreams(baout, ref); + + //Test the readFrom(InputStream) method + baout.reset(); + written = baout.write(new ByteArrayInputStream(ref.toByteArray())); + assertEquals(155, written); + checkStreams(baout, ref); + + //Write the commons Byte[]OutputStream to a java.io.Byte[]OutputStream + //and vice-versa to test the writeTo() method. + final ByteArrayOutputStream baout1 = new ByteArrayOutputStream(32); + ref.writeTo(baout1); + final java.io.ByteArrayOutputStream ref1 = new java.io.ByteArrayOutputStream(); + baout.writeTo(ref1); + checkStreams(baout1, ref1); + + //Testing toString(String) + final String baoutString = baout.toString("ASCII"); + final String refString = ref.toString("ASCII"); + assertEquals("ASCII decoded String must be equal", refString, baoutString); + + //Make sure that empty ByteArrayOutputStreams really don't create garbage + //on toByteArray() + final ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); + final ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + assertSame(baos1.toByteArray(), baos2.toByteArray()); + baos1.close(); + baos2.close(); + baout.close(); + baout1.close(); + } +} + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..079296171f59b6e6ac00c109e710ebe820396ed3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java" @@ -0,0 +1,68 @@ +/* + * 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.output; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.Test; + +/** + * Test the chunked output stream + */ +public class ChunkedOutputStreamTest { + + @Test + public void write_four_chunks() throws Exception { + final AtomicInteger numWrites = new AtomicInteger(); + ByteArrayOutputStream baos = getByteArrayOutputStream(numWrites); + ChunkedOutputStream chunked = new ChunkedOutputStream(baos, 10); + chunked.write("0123456789012345678901234567891".getBytes()); + assertEquals(4, numWrites.get()); + chunked.close(); + } + + @Test(expected = IllegalArgumentException.class) + public void negative_chunksize_not_permitted() throws Exception{ + ChunkedOutputStream chunked = new ChunkedOutputStream(new ByteArrayOutputStream(), 0); + chunked.close(); + } + + @Test + public void defaultConstructor() throws IOException { + final AtomicInteger numWrites = new AtomicInteger(); + ByteArrayOutputStream baos = getByteArrayOutputStream(numWrites); + ChunkedOutputStream chunked = new ChunkedOutputStream(baos); + chunked.write(new byte[1024 * 4 + 1]); + assertEquals(2, numWrites.get()); + chunked.close(); + } + + private ByteArrayOutputStream getByteArrayOutputStream(final AtomicInteger numWrites) { + return new ByteArrayOutputStream() { + @Override + public void write(byte[] b, int off, int len) { + numWrites.incrementAndGet(); + super.write(b, off, len); + } + }; + } + + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..924d75a7aea6f2307d40607d63bc3a5be9a83a53 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ChunkedWriterTest.java" @@ -0,0 +1,67 @@ +/* + * 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.output; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.Test; + +public class ChunkedWriterTest { + @Test + public void write_four_chunks() throws Exception { + final AtomicInteger numWrites = new AtomicInteger(); + OutputStreamWriter osw = getOutputStreamWriter(numWrites); + + ChunkedWriter chunked = new ChunkedWriter(osw, 10); + chunked.write("0123456789012345678901234567891".toCharArray()); + chunked.flush(); + assertEquals(4, numWrites.get()); + chunked.close(); + } + + @Test + public void write_two_chunks_default_constructor() throws Exception { + final AtomicInteger numWrites = new AtomicInteger(); + OutputStreamWriter osw = getOutputStreamWriter(numWrites); + + ChunkedWriter chunked = new ChunkedWriter(osw); + chunked.write(new char[1024 * 4 + 1]); + chunked.flush(); + assertEquals(2, numWrites.get()); + chunked.close(); + } + + private OutputStreamWriter getOutputStreamWriter(final AtomicInteger numWrites) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + return new OutputStreamWriter(baos) { + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + numWrites.incrementAndGet(); + super.write(cbuf, off, len); + } + }; + } + + @Test(expected = IllegalArgumentException.class) + public void negative_chunksize_not_permitted() throws Exception { + (new ChunkedWriter(new OutputStreamWriter(new ByteArrayOutputStream()), 0)).close();; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/CloseShieldOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/CloseShieldOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..da618a0061bd6580b1bebb06957d448f8b172f4f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/CloseShieldOutputStreamTest.java" @@ -0,0 +1,67 @@ +/* + * 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.output; + +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.io.OutputStream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link CloseShieldOutputStream}. + */ +public class CloseShieldOutputStreamTest { + + private ByteArrayOutputStream original; + + private OutputStream shielded; + + private boolean closed; + + @Before + public void setUp() { + original = new ByteArrayOutputStream() { + @Override + public void close() { + closed = true; + } + }; + shielded = new CloseShieldOutputStream(original); + closed = false; + } + + @Test + public void testClose() throws IOException { + shielded.close(); + assertFalse("closed", closed); + try { + shielded.write('x'); + fail("write(b)"); + } catch (final IOException ignore) { + // expected + } + original.write('y'); + assertEquals(1, original.size()); + assertEquals('y', original.toByteArray()[0]); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..71b1453d761bac6c291979d3c243e071b0d8f724 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ClosedOutputStreamTest.java" @@ -0,0 +1,49 @@ +/* + * 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.output; + +import java.io.IOException; + +import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link ClosedOutputStream}. + */ +public class ClosedOutputStreamTest { + + /** + * Test the write(b) method. + * @throws Exception + */ + @Test + public void testRead() throws Exception { + ClosedOutputStream cos = null; + try { + cos = new ClosedOutputStream(); + cos.write('x'); + fail("write(b)"); + } catch (final IOException e) { + // expected + } finally { + cos.close(); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..4f8e715bb48007694a7fd01a3c6bf1dced2776ce --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/CountingOutputStreamTest.java" @@ -0,0 +1,117 @@ +/* + * 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.output; + + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.input.NullInputStream; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + + +/** + * @version $Id: CountingOutputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ + +public class CountingOutputStreamTest { + + + @Test + public void testCounting() throws IOException { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final CountingOutputStream cos = new CountingOutputStream(baos); + + for(int i = 0; i < 20; i++) { + cos.write(i); + } + assertByteArrayEquals("CountingOutputStream.write(int)", baos.toByteArray(), 0, 20); + assertEquals("CountingOutputStream.getCount()", cos.getCount(), 20); + + final byte[] array = new byte[10]; + for(int i = 20; i < 30; i++) { + array[i-20] = (byte)i; + } + cos.write(array); + assertByteArrayEquals("CountingOutputStream.write(byte[])", baos.toByteArray(), 0, 30); + assertEquals("CountingOutputStream.getCount()", cos.getCount(), 30); + + for(int i = 25; i < 35; i++) { + array[i-25] = (byte)i; + } + cos.write(array, 5, 5); + assertByteArrayEquals("CountingOutputStream.write(byte[], int, int)", baos.toByteArray(), 0, 35); + assertEquals("CountingOutputStream.getCount()", cos.getCount(), 35); + + final int count = cos.resetCount(); + assertEquals("CountingOutputStream.resetCount()", count, 35); + + for(int i = 0; i < 10; i++) { + cos.write(i); + } + assertByteArrayEquals("CountingOutputStream.write(int)", baos.toByteArray(), 35, 45); + assertEquals("CountingOutputStream.getCount()", cos.getCount(), 10); + + cos.close(); + } + + /* + * Test for files > 2GB in size - see issue IO-84 + */ + @Test + public void testLargeFiles_IO84() throws Exception { + final long size = (long)Integer.MAX_VALUE + (long)1; + + final NullInputStream mock = new NullInputStream(size); + final OutputStream nos = new NullOutputStream(); + final CountingOutputStream cos = new CountingOutputStream(nos); + + // Test integer methods + IOUtils.copyLarge(mock, cos); + try { + cos.getCount(); + fail("Expected getCount() to throw an ArithmeticException"); + } catch (final ArithmeticException ae) { + // expected result + } + try { + cos.resetCount(); + fail("Expected resetCount() to throw an ArithmeticException"); + } catch (final ArithmeticException ae) { + // expected result + } + + mock.close(); + + // Test long methods + IOUtils.copyLarge(mock, cos); + assertEquals("getByteCount()", size, cos.getByteCount()); + assertEquals("resetByteCount()", size, cos.resetByteCount()); + } + + private void assertByteArrayEquals(final String msg, final byte[] array, final int start, final int end) { + for (int i = start; i < end; i++) { + assertEquals(msg+": array[" + i + "] mismatch", array[i], i-start); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..13afde01a195b9d899c3db686ef70a5b6323a91e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java" @@ -0,0 +1,384 @@ +/* + * 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.output; + +import org.junit.Test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Arrays; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Unit tests for the DeferredFileOutputStream class. + * + * @version $Id: DeferredFileOutputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class DeferredFileOutputStreamTest + { + + /** + * The test data as a string (which is the simplest form). + */ + private final String testString = "0123456789"; + + /** + * The test data as a byte array, derived from the string. + */ + private final byte[] testBytes = testString.getBytes(); + + /** + * Tests the case where the amount of data falls below the threshold, and + * is therefore confined to memory. + */ + @Test + public void testBelowThreshold() + { + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length + 42, null); + try + { + dfos.write(testBytes, 0, testBytes.length); + dfos.close(); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + assertTrue(dfos.isInMemory()); + + final byte[] resultBytes = dfos.getData(); + assertEquals(testBytes.length, resultBytes.length); + assertTrue(Arrays.equals(resultBytes, testBytes)); + } + + /** + * Tests the case where the amount of data is exactly the same as the + * threshold. The behavior should be the same as that for the amount of + * data being below (i.e. not exceeding) the threshold. + */ + @Test + public void testAtThreshold() { + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length, null); + try + { + dfos.write(testBytes, 0, testBytes.length); + dfos.close(); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + assertTrue(dfos.isInMemory()); + + final byte[] resultBytes = dfos.getData(); + assertEquals(testBytes.length, resultBytes.length); + assertTrue(Arrays.equals(resultBytes, testBytes)); + } + + /** + * Tests the case where the amount of data exceeds the threshold, and is + * therefore written to disk. The actual data written to disk is verified, + * as is the file itself. + */ + @Test + public void testAboveThreshold() { + final File testFile = new File("testAboveThreshold.dat"); + + // Ensure that the test starts from a clean base. + testFile.delete(); + + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length - 5, testFile); + try + { + dfos.write(testBytes, 0, testBytes.length); + dfos.close(); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + assertFalse(dfos.isInMemory()); + assertNull(dfos.getData()); + + verifyResultFile(testFile); + + // Ensure that the test starts from a clean base. + testFile.delete(); + } + + /** + * Tests the case where there are multiple writes beyond the threshold, to + * ensure that the thresholdReached() method is only called + * once, as the threshold is crossed for the first time. + */ + @Test + public void testThresholdReached() { + final File testFile = new File("testThresholdReached.dat"); + + // Ensure that the test starts from a clean base. + testFile.delete(); + + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length / 2, testFile); + final int chunkSize = testBytes.length / 3; + + try + { + dfos.write(testBytes, 0, chunkSize); + dfos.write(testBytes, chunkSize, chunkSize); + dfos.write(testBytes, chunkSize * 2, + testBytes.length - chunkSize * 2); + dfos.close(); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + assertFalse(dfos.isInMemory()); + assertNull(dfos.getData()); + + verifyResultFile(testFile); + + // Ensure that the test starts from a clean base. + testFile.delete(); + } + + + /** + * Test wether writeTo() properly writes small content. + */ + @Test + public void testWriteToSmall(){ + final File testFile = new File("testWriteToMem.dat"); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // Ensure that the test starts from a clean base. + testFile.delete(); + + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length *2, testFile); + try{ + dfos.write(testBytes); + + assertFalse(testFile.exists()); + assertTrue(dfos.isInMemory()); + + try { + dfos.writeTo(baos); + fail("Should not have been able to write before closing"); + } catch (final IOException ioe) { + // ok, as expected + } + + dfos.close(); + dfos.writeTo(baos); + } catch (final IOException ioe) { + fail("Unexpected IOException"); + } + final byte[] copiedBytes = baos.toByteArray(); + assertTrue(Arrays.equals(testBytes, copiedBytes)); + + testFile.delete(); + } + + /** + * Test wether writeTo() properly writes large content. + */ + @Test + public void testWriteToLarge(){ + final File testFile = new File("testWriteToFile.dat"); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // Ensure that the test starts from a clean base. + testFile.delete(); + + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length / 2, testFile); + try{ + dfos.write(testBytes); + + assertTrue(testFile.exists()); + assertFalse(dfos.isInMemory()); + + try { + dfos.writeTo(baos); + fail("Should not have been able to write before closeing"); + } catch (final IOException ioe) { + // ok, as expected + } + + dfos.close(); + dfos.writeTo(baos); + } catch (final IOException ioe) { + fail("Unexpected IOException"); + } + final byte[] copiedBytes = baos.toByteArray(); + assertTrue(Arrays.equals(testBytes, copiedBytes)); + verifyResultFile(testFile); + testFile.delete(); + } + + /** + * Test specifying a temporary file and the threshold not reached. + */ + @Test + public void testTempFileBelowThreshold() { + + final String prefix = "commons-io-test"; + final String suffix = ".out"; + final File tempDir = new File("."); + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length + 42, prefix, suffix, tempDir); + assertNull("Check file is null-A", dfos.getFile()); + try + { + dfos.write(testBytes, 0, testBytes.length); + dfos.close(); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + assertTrue(dfos.isInMemory()); + assertNull("Check file is null-B", dfos.getFile()); + } + + /** + * Test specifying a temporary file and the threshold is reached. + */ + @Test + public void testTempFileAboveThreshold() { + + final String prefix = "commons-io-test"; + final String suffix = ".out"; + final File tempDir = new File("."); + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length - 5, prefix, suffix, tempDir); + assertNull("Check file is null-A", dfos.getFile()); + try + { + dfos.write(testBytes, 0, testBytes.length); + dfos.close(); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + assertFalse(dfos.isInMemory()); + assertNull(dfos.getData()); + assertNotNull("Check file not null", dfos.getFile()); + assertTrue("Check file exists", dfos.getFile().exists()); + assertTrue("Check prefix", dfos.getFile().getName().startsWith(prefix)); + assertTrue("Check suffix", dfos.getFile().getName().endsWith(suffix)); + assertEquals("Check dir", tempDir.getPath(), dfos.getFile().getParent()); + + verifyResultFile(dfos.getFile()); + + // Delete the temporary file. + dfos.getFile().delete(); + } + + /** + * Test specifying a temporary file and the threshold is reached. + */ + @Test + public void testTempFileAboveThresholdPrefixOnly() { + + final String prefix = "commons-io-test"; + final String suffix = null; + final File tempDir = null; + final DeferredFileOutputStream dfos = + new DeferredFileOutputStream(testBytes.length - 5, prefix, suffix, tempDir); + assertNull("Check file is null-A", dfos.getFile()); + try + { + dfos.write(testBytes, 0, testBytes.length); + dfos.close(); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + assertFalse(dfos.isInMemory()); + assertNull(dfos.getData()); + assertNotNull("Check file not null", dfos.getFile()); + assertTrue("Check file exists", dfos.getFile().exists()); + assertTrue("Check prefix", dfos.getFile().getName().startsWith(prefix)); + assertTrue("Check suffix", dfos.getFile().getName().endsWith(".tmp")); // ".tmp" is default + + verifyResultFile(dfos.getFile()); + + // Delete the temporary file. + dfos.getFile().delete(); + } + + /** + * Test specifying a temporary file and the threshold is reached. + * @throws Exception + */ + @Test + public void testTempFileError() throws Exception { + + final String prefix = null; + final String suffix = ".out"; + final File tempDir = new File("."); + try + { + (new DeferredFileOutputStream(testBytes.length - 5, prefix, suffix, tempDir)).close(); + fail("Expected IllegalArgumentException "); + } + catch (final IllegalArgumentException e) { + // expected + } + } + + /** + * Verifies that the specified file contains the same data as the original + * test data. + * + * @param testFile The file containing the test output. + */ + private void verifyResultFile(final File testFile) { + try + { + final FileInputStream fis = new FileInputStream(testFile); + assertEquals(testBytes.length, fis.available()); + + final byte[] resultBytes = new byte[testBytes.length]; + assertEquals(testBytes.length, fis.read(resultBytes)); + + assertTrue(Arrays.equals(resultBytes, testBytes)); + assertEquals(-1, fis.read(resultBytes)); + + try + { + fis.close(); + } + catch (final IOException e) { + // Ignore an exception on close + } + } + catch (final FileNotFoundException e) { + fail("Unexpected FileNotFoundException"); + } + catch (final IOException e) { + fail("Unexpected IOException"); + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..8071702199ddc21e217b44aa2a4462eed9a29d85 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java" @@ -0,0 +1,271 @@ +/* + * 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.output; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; + +import junit.framework.AssertionFailedError; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.apache.commons.io.testtools.TestUtils.checkFile; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Tests that the encoding is actually set and used. + * + * @version $Id: FileWriterWithEncodingTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class FileWriterWithEncodingTest extends FileBasedTestCase { + + private String defaultEncoding; + private File file1; + private File file2; + private String textContent; + private char[] anotherTestContent = new char[]{'f', 'z', 'x'}; + + @Before + public void setUp() { + final File encodingFinder = new File(getTestDirectory(), "finder.txt"); + OutputStreamWriter out = null; + try { + out = new OutputStreamWriter(new FileOutputStream(encodingFinder)); + defaultEncoding = out.getEncoding(); + } catch (final IOException ex) { + throw new RuntimeException(ex.getMessage()); + } finally { + IOUtils.closeQuietly(out); + } + file1 = new File(getTestDirectory(), "testfile1.txt"); + file2 = new File(getTestDirectory(), "testfile2.txt"); + final char[] arr = new char[1024]; + final char[] chars = "ABCDEFGHIJKLMNOPQabcdefgihklmnopq".toCharArray(); + for (int i = 0; i < arr.length; i++) { + arr[i] = chars[i % chars.length]; + } + textContent = new String(arr); + } + + @After + public void tearDown() throws Exception { + FileUtils.deleteDirectory(getTestDirectory()); + defaultEncoding = null; + textContent = null; + } + + //----------------------------------------------------------------------- + @Test + public void sameEncoding_string_constructor() throws Exception { + succesfulRun(new FileWriterWithEncoding(file2, defaultEncoding)); + } + + @Test + public void sameEncoding_string_string_constructor() throws Exception { + succesfulRun(new FileWriterWithEncoding(file2.getPath(), defaultEncoding)); + } + + @Test + public void sameEncoding_Charset_constructor() throws Exception { + succesfulRun(new FileWriterWithEncoding(file2, Charset.defaultCharset())); + } + + @Test + public void sameEncoding_string_Charset_constructor() throws Exception { + succesfulRun(new FileWriterWithEncoding(file2.getPath(), Charset.defaultCharset())); + } + + @Test + public void sameEncoding_CharsetEncoder_constructor() throws Exception { + CharsetEncoder enc = Charset.defaultCharset().newEncoder(); + succesfulRun(new FileWriterWithEncoding(file2, enc)); + } + + @Test + public void sameEncoding_string_CharsetEncoder_constructor() throws Exception { + CharsetEncoder enc = Charset.defaultCharset().newEncoder(); + succesfulRun(new FileWriterWithEncoding(file2.getPath(), enc)); + } + + private void succesfulRun(FileWriterWithEncoding fw21) throws Exception { + FileWriter fw1 = null; + FileWriterWithEncoding fw2 = null; + try { + fw1 = new FileWriter(file1); // default encoding + fw2 = fw21; + writeTestPayload(fw1, fw2); + checkFile(file1, file2); + + } finally { + IOUtils.closeQuietly(fw1); + IOUtils.closeQuietly(fw2); + } + assertTrue(file1.exists()); + assertTrue(file2.exists()); + } + + @Test + public void testDifferentEncoding() throws Exception { + if (Charset.isSupported("UTF-16BE")) { + FileWriter fw1 = null; + FileWriterWithEncoding fw2 = null; + try { + fw1 = new FileWriter(file1); // default encoding + fw2 = new FileWriterWithEncoding(file2, defaultEncoding); + writeTestPayload(fw1, fw2); + try { + checkFile(file1, file2); + fail(); + } catch (final AssertionError ex) { + // success + } + + } finally { + IOUtils.closeQuietly(fw1); + IOUtils.closeQuietly(fw2); + } + assertTrue(file1.exists()); + assertTrue(file2.exists()); + } + if (Charset.isSupported("UTF-16LE")) { + FileWriter fw1 = null; + FileWriterWithEncoding fw2 = null; + try { + fw1 = new FileWriter(file1); // default encoding + fw2 = new FileWriterWithEncoding(file2, defaultEncoding); + writeTestPayload(fw1, fw2); + try { + checkFile(file1, file2); + fail(); + } catch (final AssertionError ex) { + // success + } + + } finally { + IOUtils.closeQuietly(fw1); + IOUtils.closeQuietly(fw2); + } + assertTrue(file1.exists()); + assertTrue(file2.exists()); + } + } + + private void writeTestPayload(FileWriter fw1, FileWriterWithEncoding fw2) throws IOException { + assertTrue(file1.exists()); + assertTrue(file2.exists()); + + fw1.write(textContent); + fw2.write(textContent); + fw1.write(65); + fw2.write(65); + fw1.write(anotherTestContent); + fw2.write(anotherTestContent); + fw1.write(anotherTestContent, 1, 2); + fw2.write(anotherTestContent, 1, 2); + fw1.write("CAFE", 1, 2); + fw2.write("CAFE", 1, 2); + + fw1.flush(); + fw2.flush(); + } + + //----------------------------------------------------------------------- + @Test + public void constructor_File_encoding_badEncoding() { + Writer writer = null; + try { + writer = new FileWriterWithEncoding(file1, "BAD-ENCODE"); + fail(); + } catch (final IOException ex) { + // expected + assertFalse(file1.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file1.exists()); + } + + //----------------------------------------------------------------------- + @Test + public void constructor_File_directory() { + Writer writer = null; + try { + writer = new FileWriterWithEncoding(getTestDirectory(), defaultEncoding); + fail(); + } catch (final IOException ex) { + // expected + assertFalse(file1.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file1.exists()); + } + + //----------------------------------------------------------------------- + @Test + public void constructor_File_nullFile() throws IOException { + Writer writer = null; + try { + writer = new FileWriterWithEncoding((File) null, defaultEncoding); + fail(); + } catch (final NullPointerException ex) { + // expected + assertFalse(file1.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file1.exists()); + } + + //----------------------------------------------------------------------- + @Test + public void constructor_fileName_nullFile() throws IOException { + Writer writer = null; + try { + writer = new FileWriterWithEncoding((String) null, defaultEncoding); + fail(); + } catch (final NullPointerException ex) { + // expected + assertFalse(file1.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file1.exists()); + } + + @Test + public void sameEncoding_null_Charset_constructor() throws Exception { + try { + succesfulRun(new FileWriterWithEncoding(file2, (Charset) null)); + fail(); + } catch (NullPointerException ignore) { + + } + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..33dc506169025e1d599a529eaebfa11cd2db6ea3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java" @@ -0,0 +1,235 @@ +/* + * 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.output; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.nio.charset.UnsupportedCharsetException; + +import org.apache.commons.io.Charsets; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.testtools.FileBasedTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * Tests that files really lock, although no writing is done as + * the locking is tested only on construction. + * + * @version $Id: LockableFileWriterTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class LockableFileWriterTest extends FileBasedTestCase { + + private File file; + private File lockDir; + private File lockFile; + private File altLockDir; + private File altLockFile; + + @Before + public void setUp() { + file = new File(getTestDirectory(), "testlockfile"); + lockDir = new File(System.getProperty("java.io.tmpdir")); + lockFile = new File(lockDir, file.getName() + ".lck"); + altLockDir = getTestDirectory(); + altLockFile = new File(altLockDir, file.getName() + ".lck"); + } + + @After + public void tearDown() { + file.delete(); + lockFile.delete(); + altLockFile.delete(); + } + + //----------------------------------------------------------------------- + @Test public void testFileLocked() throws IOException { + LockableFileWriter lfw1 = null; + LockableFileWriter lfw2 = null; + LockableFileWriter lfw3 = null; + try { + // open a valid locakable writer + lfw1 = new LockableFileWriter(file); + assertTrue(file.exists()); + assertTrue(lockFile.exists()); + + // try to open a second writer + try { + lfw2 = new LockableFileWriter(file); + fail("Somehow able to open a locked file. "); + } catch(final IOException ioe) { + final String msg = ioe.getMessage(); + assertTrue( "Exception message does not start correctly. ", + msg.startsWith("Can't write file, lock ") ); + assertTrue(file.exists()); + assertTrue(lockFile.exists()); + } + + // try to open a third writer + try { + lfw3 = new LockableFileWriter(file); + fail("Somehow able to open a locked file. "); + } catch(final IOException ioe) { + final String msg = ioe.getMessage(); + assertTrue( "Exception message does not start correctly. ", + msg.startsWith("Can't write file, lock ") ); + assertTrue(file.exists()); + assertTrue(lockFile.exists()); + } + + } finally { + IOUtils.closeQuietly(lfw1); + IOUtils.closeQuietly(lfw2); + IOUtils.closeQuietly(lfw3); + } + assertTrue(file.exists()); + assertFalse(lockFile.exists()); + } + + //----------------------------------------------------------------------- + @SuppressWarnings("deprecation") // unavoidable until Java 7 + @Test public void testAlternateLockDir() throws IOException { + LockableFileWriter lfw1 = null; + LockableFileWriter lfw2 = null; + try { + // open a valid locakable writer + lfw1 = new LockableFileWriter(file, "UTF-8" ,true, altLockDir.getAbsolutePath()); + assertTrue(file.exists()); + assertTrue(altLockFile.exists()); + + // try to open a second writer + try { + lfw2 = new LockableFileWriter(file, Charsets.UTF_8, true, altLockDir.getAbsolutePath()); + fail("Somehow able to open a locked file. "); + } catch(final IOException ioe) { + final String msg = ioe.getMessage(); + assertTrue( "Exception message does not start correctly. ", + msg.startsWith("Can't write file, lock ") ); + assertTrue(file.exists()); + assertTrue(altLockFile.exists()); + } + + } finally { + IOUtils.closeQuietly(lfw1); + IOUtils.closeQuietly(lfw2); + } + assertTrue(file.exists()); + assertFalse(altLockFile.exists()); + } + + //----------------------------------------------------------------------- + @Test public void testFileNotLocked() throws IOException { + // open a valid locakable writer + LockableFileWriter lfw1 = null; + try { + lfw1 = new LockableFileWriter(file); + assertTrue(file.exists()); + assertTrue(lockFile.exists()); + } finally { + IOUtils.closeQuietly(lfw1); + } + assertTrue(file.exists()); + assertFalse(lockFile.exists()); + + // open a second valid writer on the same file + LockableFileWriter lfw2 = null; + try { + lfw2 = new LockableFileWriter(file); + assertTrue(file.exists()); + assertTrue(lockFile.exists()); + } finally { + IOUtils.closeQuietly(lfw2); + } + assertTrue(file.exists()); + assertFalse(lockFile.exists()); + } + + //----------------------------------------------------------------------- + @Test public void testConstructor_File_encoding_badEncoding() throws IOException { + Writer writer = null; + try { + writer = new LockableFileWriter(file, "BAD-ENCODE"); + fail(); + } catch (final UnsupportedCharsetException ex) { + // expected + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } + + //----------------------------------------------------------------------- + @Test public void testConstructor_File_directory() { + Writer writer = null; + try { + writer = new LockableFileWriter(getTestDirectory()); + fail(); + } catch (final IOException ex) { + // expected + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } + + //----------------------------------------------------------------------- + @Test public void testConstructor_File_nullFile() throws IOException { + Writer writer = null; + try { + writer = new LockableFileWriter((File) null); + fail(); + } catch (final NullPointerException ex) { + // expected + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } + + //----------------------------------------------------------------------- + @Test public void testConstructor_fileName_nullFile() throws IOException { + Writer writer = null; + try { + writer = new LockableFileWriter((String) null); + fail(); + } catch (final NullPointerException ex) { + // expected + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } finally { + IOUtils.closeQuietly(writer); + } + assertFalse(file.exists()); + assertFalse(lockFile.exists()); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..a7cdd6fd3ab7d1e9f89e622e782b6f54a106a448 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/NullOutputStreamTest.java" @@ -0,0 +1,47 @@ +/* + * 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.output; + + +import org.junit.Test; + +import java.io.IOException; + + +/** + * Really not a lot to do here, but checking that no + * Exceptions are thrown. + * + * @version $Id: NullOutputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ + +public class NullOutputStreamTest { + + @Test + public void testNull() throws IOException { + final NullOutputStream nos = new NullOutputStream(); + nos.write("string".getBytes()); + nos.write("some string".getBytes(), 3, 5); + nos.write(1); + nos.write(0x0f); + nos.flush(); + nos.close(); + nos.write("allowed".getBytes()); + nos.write(255); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/NullWriterTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/NullWriterTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..ff32ee49739a287a438b912d96c7407bb189ccdf --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/NullWriterTest.java" @@ -0,0 +1,42 @@ +/* + * 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.output; + +import org.junit.Test; + +/** + * Really not a lot to do here, but checking that no + * Exceptions are thrown. + * + * @version $Id: NullWriterTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class NullWriterTest { + + @Test + public void testNull() { + final char[] chars = new char[] {'A', 'B', 'C'}; + final NullWriter writer = new NullWriter(); + writer.write(1); + writer.write(chars); + writer.write(chars, 1, 1); + writer.write("some string"); + writer.write("some string", 2, 2); + writer.flush(); + writer.close(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ProxyOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ProxyOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..fdd9c0de98115f0f26cb9587ad687e105b9ee4e7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ProxyOutputStreamTest.java" @@ -0,0 +1,62 @@ +/* + * 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.output; + +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.io.OutputStream; + +import static org.junit.Assert.assertEquals; + +/** + * JUnit Test Case for {@link CloseShieldOutputStream}. + */ +public class ProxyOutputStreamTest { + + private ByteArrayOutputStream original; + + private OutputStream proxied; + + @Before + public void setUp() { + original = new ByteArrayOutputStream(){ + @Override + public void write(final byte[] ba) throws IOException { + if (ba != null){ + super.write(ba); + } + } + }; + proxied = new ProxyOutputStream(original); + } + + @Test + public void testWrite() throws Exception { + proxied.write('y'); + assertEquals(1, original.size()); + assertEquals('y', original.toByteArray()[0]); + } + + @Test + public void testWriteNullBaSucceeds() throws Exception { + final byte[] ba = null; + original.write(ba); + proxied.write(ba); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..7b4423551e60b1b47af997c05390ae4f5827a9ec --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java" @@ -0,0 +1,339 @@ +/* + * 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.output; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; + +import org.junit.Test; + +/** + * Test {@link ProxyWriter}. + * + * @version $Id: ProxyWriterTest.java 1687859 2015-06-26 21:35:40Z krosenvold $ + */ +public class ProxyWriterTest { + + @Test + public void appendCharSequence() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + try { + proxy.append("ABC"); + } catch (final Exception e) { + fail("Appending CharSequence threw " + e); + } + assertEquals("ABC", writer.toString()); + proxy.close(); + } + + @Test + public void appendCharSequence_with_offset() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + proxy.append("ABC", 1, 3); + proxy.flush(); + assertEquals("BC", writer.toString()); + proxy.close(); + } + + @Test + public void appendChar() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + proxy.append('c'); + assertEquals("c", writer.toString()); + proxy.close(); + } + + @Test + public void writeString() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + try { + proxy.write("ABC"); + } catch (final Exception e) { + fail("Writing String threw " + e); + } + assertEquals("ABC", writer.toString()); + proxy.close(); + } + + @Test + public void writeStringPartial() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + try { + proxy.write("ABC", 1, 2); + } catch (final Exception e) { + fail("Writing String threw " + e); + } + assertEquals("BC", writer.toString()); + proxy.close(); + } + + @Test + public void writeCharArray() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + try { + proxy.write(new char[]{'A', 'B', 'C'}); + } catch (final Exception e) { + fail("Writing char[] threw " + e); + } + assertEquals("ABC", writer.toString()); + proxy.close(); + } + + @Test + public void writeInt() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + try { + proxy.write(65); + } catch (final Exception e) { + fail("Writing char[] threw " + e); + } + assertEquals("A", writer.toString()); + proxy.close(); + } + + @Test + public void writeCharArrayPartial() throws Exception { + final StringBuilderWriter writer = new StringBuilderWriter(); + final ProxyWriter proxy = new ProxyWriter(writer); + try { + proxy.write(new char[]{'A', 'B', 'C'}, 1, 2); + } catch (final Exception e) { + fail("Writing char[] threw " + e); + } + assertEquals("BC", writer.toString()); + proxy.close(); + } + + @Test + public void nullString() throws Exception { + + final ProxyWriter proxy = new ProxyWriter(new NullWriter()); + + try { + proxy.write((String) null); + } catch (final Exception e) { + fail("Writing null String threw " + e); + } + + try { + proxy.write((String) null, 0, 0); + } catch (final Exception e) { + fail("Writing null String threw " + e); + } + proxy.close(); + } + + @Test + public void nullCharArray() throws Exception { + + final ProxyWriter proxy = new ProxyWriter(new NullWriter()); + + try { + proxy.write((char[]) null); + } catch (final Exception e) { + fail("Writing null char[] threw " + e); + } + + try { + proxy.write((char[]) null, 0, 0); + } catch (final Exception e) { + fail("Writing null char[] threw " + e); + } + proxy.close(); + } + + @Test + public void nullCharSequencec() throws Exception { + + final ProxyWriter proxy = new ProxyWriter(new NullWriter()); + + try { + proxy.append(null); + } catch (final Exception e) { + fail("Appending null CharSequence threw " + e); + } + proxy.close(); + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_append_char() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void write(int c) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.append('c'); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_append_charSequence() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public Writer append(CharSequence csq) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.append("ABCE"); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_append_charSequence_offset() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public Writer append(CharSequence csq, int start, int end) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.append("ABCE", 1, 2); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_write_int() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void write(int c) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.write((int) 'a'); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_write_char_array() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void write(char[] cbuf) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.write("ABCE".toCharArray()); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_write_offset_char_array() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.write("ABCE".toCharArray(), 2, 3); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_write_string() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void write(String str) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.write("ABCE"); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_write_string_offset() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void write(String str, int off, int len) throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.write("ABCE", 1, 3); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_flush() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void flush() throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + try { + proxy.flush(); + } finally { + proxy.close(); + } + } + + @Test(expected = UnsupportedEncodingException.class) + public void exceptions_in_close() throws IOException { + OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { + @Override + public void close() throws IOException { + throw new UnsupportedEncodingException("Bah"); + } + }; + final ProxyWriter proxy = new ProxyWriter(osw); + proxy.close(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..28694264ec6a72acf7f5672611e66673e8ed0858 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/StringBuilderWriterTest.java" @@ -0,0 +1,152 @@ +/* + * 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.output; + +import org.junit.Test; + +import java.io.IOException; +import java.io.Writer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + +/** + * Test case for {@link StringBuilderWriter}. + * + * @version $Id: StringBuilderWriterTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class StringBuilderWriterTest { + private static final char[] FOOBAR_CHARS = new char[] {'F', 'o', 'o', 'B', 'a', 'r'}; + + + @Test + public void testAppendConstructCapacity() throws IOException { + final Writer writer = new StringBuilderWriter(100); + writer.append("Foo"); + assertEquals("Foo", writer.toString()); + writer.close(); + } + + @Test + public void testAppendConstructStringBuilder() { + final StringBuilder builder = new StringBuilder("Foo"); + final StringBuilderWriter writer = new StringBuilderWriter(builder); + writer.append("Bar"); + assertEquals("FooBar", writer.toString()); + assertSame(builder, writer.getBuilder()); + writer.close(); + } + + @Test + public void testAppendConstructNull() throws IOException { + final Writer writer = new StringBuilderWriter(null); + writer.append("Foo"); + assertEquals("Foo", writer.toString()); + writer.close(); + } + + @Test + public void testAppendChar() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.append('F').append('o').append('o'); + assertEquals("Foo", writer.toString()); + writer.close(); + } + + @Test + public void testAppendCharSequence() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.append("Foo").append("Bar"); + assertEquals("FooBar", writer.toString()); + writer.close(); + } + + @Test + public void testAppendCharSequencePortion() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.append("FooBar", 3, 6).append(new StringBuffer("FooBar"), 0, 3); + assertEquals("BarFoo", writer.toString()); + writer.close(); + } + + @Test + public void testClose() { + final Writer writer = new StringBuilderWriter(); + try { + writer.append("Foo"); + writer.close(); + writer.append("Bar"); + } catch (final Throwable t) { + fail("Threw: " + t); + } + assertEquals("FooBar", writer.toString()); + } + + @Test + public void testWriteChar() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.write('F'); + assertEquals("F", writer.toString()); + writer.write('o'); + assertEquals("Fo", writer.toString()); + writer.write('o'); + assertEquals("Foo", writer.toString()); + writer.close(); + } + + @Test + public void testWriteCharArray() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.write(new char[] {'F', 'o', 'o'}); + assertEquals("Foo", writer.toString()); + writer.write(new char[] {'B', 'a', 'r'}); + assertEquals("FooBar", writer.toString()); + writer.close(); + } + + @Test + public void testWriteCharArrayPortion() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.write(FOOBAR_CHARS, 3, 3); + assertEquals("Bar", writer.toString()); + writer.write(FOOBAR_CHARS, 0, 3); + assertEquals("BarFoo", writer.toString()); + writer.close(); + } + + @Test + public void testWriteString() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.write("Foo"); + assertEquals("Foo", writer.toString()); + writer.write("Bar"); + assertEquals("FooBar", writer.toString()); + writer.close(); + } + + @Test + public void testWriteStringPortion() throws IOException { + final Writer writer = new StringBuilderWriter(); + writer.write("FooBar", 3, 3); + assertEquals("Bar", writer.toString()); + writer.write("FooBar", 0, 3); + assertEquals("BarFoo", writer.toString()); + writer.close(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..0f0421b28725525d05ad40ec68a73f978cee0522 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/TaggedOutputStreamTest.java" @@ -0,0 +1,131 @@ +/* + * 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.output; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.UUID; + +import junit.framework.TestCase; + +import org.apache.commons.io.TaggedIOException; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * JUnit Test Case for {@link TaggedOutputStream}. + */ +public class TaggedOutputStreamTest { + + @Test + public void testNormalStream() { + try { + final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + final OutputStream stream = new TaggedOutputStream(buffer); + stream.write('a'); + stream.write(new byte[] { 'b' }); + stream.write(new byte[] { 'c' }, 0, 1); + stream.flush(); + stream.close(); + assertEquals(3, buffer.size()); + assertEquals('a', buffer.toByteArray()[0]); + assertEquals('b', buffer.toByteArray()[1]); + assertEquals('c', buffer.toByteArray()[2]); + } catch (final IOException e) { + fail("Unexpected exception thrown"); + } + } + + @Test + public void testBrokenStream() { + final IOException exception = new IOException("test exception"); + final TaggedOutputStream stream = + new TaggedOutputStream(new BrokenOutputStream(exception)); + + // Test the write() method + try { + stream.write('x'); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertTrue(stream.isCauseOf(e)); + try { + stream.throwIfCauseOf(e); + fail("Expected exception not thrown."); + } catch (final IOException e2) { + assertEquals(exception, e2); + } + } + + // Test the flush() method + try { + stream.flush(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertTrue(stream.isCauseOf(e)); + try { + stream.throwIfCauseOf(e); + fail("Expected exception not thrown."); + } catch (final IOException e2) { + assertEquals(exception, e2); + } + } + + // Test the close() method + try { + stream.close(); + fail("Expected exception not thrown."); + } catch (final IOException e) { + assertTrue(stream.isCauseOf(e)); + try { + stream.throwIfCauseOf(e); + fail("Expected exception not thrown."); + } catch (final IOException e2) { + assertEquals(exception, e2); + } + } + } + + @Test + public void testOtherException() throws Exception { + final IOException exception = new IOException("test exception"); + final OutputStream closed = new ClosedOutputStream(); + final TaggedOutputStream stream = new TaggedOutputStream(closed); + + assertFalse(stream.isCauseOf(exception)); + assertFalse(stream.isCauseOf( + new TaggedIOException(exception, UUID.randomUUID()))); + + try { + stream.throwIfCauseOf(exception); + } catch (final IOException e) { + fail("Unexpected exception thrown"); + } + + try { + stream.throwIfCauseOf( + new TaggedIOException(exception, UUID.randomUUID())); + } catch (final IOException e) { + fail("Unexpected exception thrown"); + } + stream.close(); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..fbdd9a7a4f8c1c491c67f5af7dffbde9de4df813 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/TeeOutputStreamTest.java" @@ -0,0 +1,119 @@ +/* + * 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.output; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + +/** + * @version $Id: TeeOutputStreamTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ + +public class TeeOutputStreamTest { + + private static class ExceptionOnCloseByteArrayOutputStream extends ByteArrayOutputStream { + + @Override + public void close() throws IOException { + throw new IOException(); + } + } + + private static class RecordCloseByteArrayOutputStream extends ByteArrayOutputStream { + + boolean closed; + + @Override + public void close() throws IOException { + super.close(); + closed = true; + } + } + + /** + * Tests that the branch {@code OutputStream} is closed when closing the main {@code OutputStream} throws an + * exception on {@link TeeOutputStream#close()}. + */ + @Test + public void testCloseBranchIOException() { + final ByteArrayOutputStream badOs = new ExceptionOnCloseByteArrayOutputStream(); + final RecordCloseByteArrayOutputStream goodOs = new RecordCloseByteArrayOutputStream(); + final TeeOutputStream tos = new TeeOutputStream(goodOs, badOs); + try { + tos.close(); + Assert.fail("Expected " + IOException.class.getName()); + } catch (final IOException e) { + Assert.assertTrue(goodOs.closed); + } + } + + /** + * Tests that the main {@code OutputStream} is closed when closing the branch {@code OutputStream} throws an + * exception on {@link TeeOutputStream#close()}. + */ + @Test + public void testCloseMainIOException() { + final ByteArrayOutputStream badOs = new ExceptionOnCloseByteArrayOutputStream(); + final RecordCloseByteArrayOutputStream goodOs = new RecordCloseByteArrayOutputStream(); + final TeeOutputStream tos = new TeeOutputStream(badOs, goodOs); + try { + tos.close(); + Assert.fail("Expected " + IOException.class.getName()); + } catch (final IOException e) { + Assert.assertTrue(goodOs.closed); + } + } + + @Test + public void testTee() throws IOException { + final ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); + final ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); + final TeeOutputStream tos = new TeeOutputStream(baos1, baos2); + for (int i = 0; i < 20; i++) { + tos.write(i); + } + assertByteArrayEquals("TeeOutputStream.write(int)", baos1.toByteArray(), baos2.toByteArray()); + + final byte[] array = new byte[10]; + for (int i = 20; i < 30; i++) { + array[i - 20] = (byte) i; + } + tos.write(array); + assertByteArrayEquals("TeeOutputStream.write(byte[])", baos1.toByteArray(), baos2.toByteArray()); + + for (int i = 25; i < 35; i++) { + array[i - 25] = (byte) i; + } + tos.write(array, 5, 5); + assertByteArrayEquals("TeeOutputStream.write(byte[], int, int)", baos1.toByteArray(), baos2.toByteArray()); + tos.flush(); + tos.close(); + } + + private void assertByteArrayEquals(final String msg, final byte[] array1, final byte[] array2) { + assertEquals(msg + ": array size mismatch", array1.length, array2.length); + for (int i = 0; i < array1.length; i++) { + assertEquals(msg + ": array[ " + i + "] mismatch", array1[i], array2[i]); + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..695e31cc5717f82623ce44819e82db25df6abbff --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/ThresholdingOutputStreamTest.java" @@ -0,0 +1,52 @@ +package org.apache.commons.io.output; +/* + * 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 static org.junit.Assert.*; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.junit.Test; + +public class ThresholdingOutputStreamTest { + + @Test + public void testSetByteCount() throws Exception { + final AtomicBoolean reached = new AtomicBoolean(false); + ThresholdingOutputStream tos = new ThresholdingOutputStream(3) { + { + setByteCount(2); + } + @Override + protected OutputStream getStream() throws IOException { + return new ByteArrayOutputStream(4); + } + + @Override + protected void thresholdReached() throws IOException { + reached.set( true); + } + }; + + tos.write(12); + assertFalse( reached.get()); + tos.write(12); + assertTrue(reached.get()); + tos.close(); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..c0b39f74b6051b3ada2eac23fabd6702a1b2bc96 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/WriterOutputStreamTest.java" @@ -0,0 +1,149 @@ +/* + * 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.output; + +import org.junit.Test; + +import java.io.IOException; +import java.io.StringWriter; +import java.util.Random; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class WriterOutputStreamTest { + private static final String TEST_STRING = "\u00e0 peine arriv\u00e9s nous entr\u00e2mes dans sa chambre"; + private static final String LARGE_TEST_STRING; + + static { + final StringBuilder buffer = new StringBuilder(); + for (int i=0; i<100; i++) { + buffer.append(TEST_STRING); + } + LARGE_TEST_STRING = buffer.toString(); + } + + private final Random random = new Random(); + + private void testWithSingleByteWrite(final String testString, final String charsetName) throws IOException { + final byte[] bytes = testString.getBytes(charsetName); + final StringWriter writer = new StringWriter(); + final WriterOutputStream out = new WriterOutputStream(writer, charsetName); + for (final byte b : bytes) { + out.write(b); + } + out.close(); + assertEquals(testString, writer.toString()); + } + + private void testWithBufferedWrite(final String testString, final String charsetName) throws IOException { + final byte[] expected = testString.getBytes(charsetName); + final StringWriter writer = new StringWriter(); + final WriterOutputStream out = new WriterOutputStream(writer, charsetName); + int offset = 0; + while (offset < expected.length) { + final int length = Math.min(random.nextInt(128), expected.length-offset); + out.write(expected, offset, length); + offset += length; + } + out.close(); + assertEquals(testString, writer.toString()); + } + + @Test + public void testUTF8WithSingleByteWrite() throws IOException { + testWithSingleByteWrite(TEST_STRING, "UTF-8"); + } + + @Test + public void testLargeUTF8WithSingleByteWrite() throws IOException { + testWithSingleByteWrite(LARGE_TEST_STRING, "UTF-8"); + } + + @Test + public void testUTF8WithBufferedWrite() throws IOException { + testWithBufferedWrite(TEST_STRING, "UTF-8"); + } + + @Test + public void testLargeUTF8WithBufferedWrite() throws IOException { + testWithBufferedWrite(LARGE_TEST_STRING, "UTF-8"); + } + + @Test + public void testUTF16WithSingleByteWrite() throws IOException { + try { + testWithSingleByteWrite(TEST_STRING, "UTF-16"); + } catch (UnsupportedOperationException e){ + if (!System.getProperty("java.vendor").contains("IBM")){ + fail("This test should only throw UOE on IBM JDKs with broken UTF-16"); + } + } + } + + @Test + public void testUTF16WithBufferedWrite() throws IOException { + try { + testWithBufferedWrite(TEST_STRING, "UTF-16"); + } catch (UnsupportedOperationException e) { + if (!System.getProperty("java.vendor").contains("IBM")) { + fail("This test should only throw UOE on IBM JDKs with broken UTF-16"); + } + } + } + + @Test + public void testUTF16BEWithSingleByteWrite() throws IOException { + testWithSingleByteWrite(TEST_STRING, "UTF-16BE"); + } + + @Test + public void testUTF16BEWithBufferedWrite() throws IOException { + testWithBufferedWrite(TEST_STRING, "UTF-16BE"); + } + + @Test + public void testUTF16LEWithSingleByteWrite() throws IOException { + testWithSingleByteWrite(TEST_STRING, "UTF-16LE"); + } + + @Test + public void testUTF16LEWithBufferedWrite() throws IOException { + testWithBufferedWrite(TEST_STRING, "UTF-16LE"); + } + + + @Test + public void testFlush() throws IOException { + final StringWriter writer = new StringWriter(); + final WriterOutputStream out = new WriterOutputStream(writer, "us-ascii", 1024, false); + out.write("abc".getBytes("us-ascii")); + assertEquals(0, writer.getBuffer().length()); + out.flush(); + assertEquals("abc", writer.toString()); + out.close(); + } + + @Test + public void testWriteImmediately() throws IOException { + final StringWriter writer = new StringWriter(); + final WriterOutputStream out = new WriterOutputStream(writer, "us-ascii", 1024, true); + out.write("abc".getBytes("us-ascii")); + assertEquals("abc", writer.toString()); + out.close(); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..bda5f0cbe32a96da2331e514fc08c4d06cfc1bf0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/output/XmlStreamWriterTest.java" @@ -0,0 +1,150 @@ +/* + * 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.output; + +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Arrays; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * @version $Id: XmlStreamWriterTest.java 1718944 2015-12-09 19:50:30Z krosenvold $ + */ +public class XmlStreamWriterTest { + /** french */ + private static final String TEXT_LATIN1 = "eacute: \u00E9"; + /** greek */ + private static final String TEXT_LATIN7 = "alpha: \u03B1"; + /** euro support */ + private static final String TEXT_LATIN15 = "euro: \u20AC"; + /** japanese */ + private static final String TEXT_EUC_JP = "hiragana A: \u3042"; + /** Unicode: support everything */ + private static final String TEXT_UNICODE = TEXT_LATIN1 + ", " + TEXT_LATIN7 + + ", " + TEXT_LATIN15 + ", " + TEXT_EUC_JP; + + private static String createXmlContent(final String text, final String encoding) { + String xmlDecl = ""; + if (encoding != null) { + xmlDecl = ""; + } + return xmlDecl + "\n" + text + ""; + } + + private static void checkXmlContent(final String xml, final String encoding, final String defaultEncoding) + throws IOException { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + final XmlStreamWriter writer = new XmlStreamWriter(out, defaultEncoding); + writer.write(xml); + writer.close(); + final byte[] xmlContent = out.toByteArray(); + assertEquals(encoding, writer.getEncoding()); + assertTrue(Arrays.equals(xml.getBytes(encoding), xmlContent)); + + } + + private static void checkXmlWriter(final String text, final String encoding) + throws IOException { + checkXmlWriter(text, encoding, null); + } + + private static void checkXmlWriter(final String text, final String encoding, final String defaultEncoding) + throws IOException { + final String xml = createXmlContent(text, encoding); + String effectiveEncoding = encoding; + if (effectiveEncoding == null) { + effectiveEncoding = defaultEncoding == null ? "UTF-8" : defaultEncoding; + } + checkXmlContent(xml, effectiveEncoding, defaultEncoding); + } + + @Test + public void testNoXmlHeader() throws IOException { + final String xml = "text with no XML header"; + checkXmlContent(xml, "UTF-8", null); + } + + @Test + public void testEmpty() throws IOException { + final ByteArrayOutputStream out = new ByteArrayOutputStream(); + final XmlStreamWriter writer = new XmlStreamWriter(out); + writer.flush(); + writer.write(""); + writer.flush(); + writer.write("."); + writer.flush(); + writer.close(); + } + + @Test + public void testDefaultEncoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, null, null); + checkXmlWriter(TEXT_UNICODE, null, "UTF-8"); + checkXmlWriter(TEXT_UNICODE, null, "UTF-16"); + checkXmlWriter(TEXT_UNICODE, null, "UTF-16BE"); + checkXmlWriter(TEXT_UNICODE, null, "ISO-8859-1"); + } + + @Test + public void testUTF8Encoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-8"); + } + + @Test + public void testUTF16Encoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-16"); + } + + @Test + public void testUTF16BEEncoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-16BE"); + } + + @Test + public void testUTF16LEEncoding() throws IOException { + checkXmlWriter(TEXT_UNICODE, "UTF-16LE"); + } + + @Test + public void testLatin1Encoding() throws IOException { + checkXmlWriter(TEXT_LATIN1, "ISO-8859-1"); + } + + @Test + public void testLatin7Encoding() throws IOException { + checkXmlWriter(TEXT_LATIN7, "ISO-8859-7"); + } + + @Test + public void testLatin15Encoding() throws IOException { + checkXmlWriter(TEXT_LATIN15, "ISO-8859-15"); + } + + @Test + public void testEUC_JPEncoding() throws IOException { + checkXmlWriter(TEXT_EUC_JP, "EUC-JP"); + } + + @Test + public void testEBCDICEncoding() throws IOException { + checkXmlWriter("simple text in EBCDIC", "CP1047"); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/ClosingBase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/ClosingBase.java" new file mode 100644 index 0000000000000000000000000000000000000000..45ade5305c5489ee239571a2b24a48af8921c9cd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/ClosingBase.java" @@ -0,0 +1,54 @@ +/* + * 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.serialization; + +import java.io.Closeable; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; + +/** Test base class that keeps track of Closeable objects + * and cleans them up. + */ +public class ClosingBase { + private final List toClose = new ArrayList(); + + protected T willClose(T t) { + toClose.add(t); + return t; + } + + @Before + public void setup() throws IOException { + toClose.clear(); + } + + @After + public void cleanup() { + for (Closeable c : toClose) { + try { + c.close(); + } catch (IOException ignored) { + } + } + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/FullClassNameMatcherTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/FullClassNameMatcherTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..6f787363d3ed0164d12f44212bcf058922a4ec17 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/FullClassNameMatcherTest.java" @@ -0,0 +1,42 @@ +/* + * 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.serialization; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class FullClassNameMatcherTest { + + private static final String [] NAMES_ARRAY = { Integer.class.getName(), Long.class.getName() }; + + @Test + public void noNames() throws Exception { + final FullClassNameMatcher m = new FullClassNameMatcher(); + assertFalse(m.matches(Integer.class.getName())); + } + + @Test + public void withNames() throws Exception { + final FullClassNameMatcher m = new FullClassNameMatcher(NAMES_ARRAY); + assertTrue(m.matches(Integer.class.getName())); + assertFalse(m.matches(String.class.getName())); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java" new file mode 100644 index 0000000000000000000000000000000000000000..55ca45b2d316548425f6a907c707560123496cb3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MockSerializedClass.java" @@ -0,0 +1,44 @@ +/* + * 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.serialization; + +import java.io.Serializable; + +public class MockSerializedClass implements Serializable { + private static final long serialVersionUID = 2139985988735372175L; + + private final String str; + + MockSerializedClass(String str) { + this.str = str; + } + + @Override + public int hashCode() { + return str.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if(!(obj instanceof MockSerializedClass)) { + return false; + } + return str.equals(((MockSerializedClass)obj).str); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MoreComplexObject.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MoreComplexObject.java" new file mode 100644 index 0000000000000000000000000000000000000000..54ad5a1fafdc934dff9a51297a0c845fc8c561fc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MoreComplexObject.java" @@ -0,0 +1,53 @@ +/* + * 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.serialization; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; +import java.util.UUID; + +/** A test class that uses various java.* member objects, + * to show which settings are necessary to deserialize + * those. + */ +public class MoreComplexObject implements Serializable { + private static final long serialVersionUID = -5187124661539240729L; + + private final Random random = new Random(System.currentTimeMillis()); + private final String string = UUID.randomUUID().toString(); + private final Integer integer = random.nextInt(); + private final int pInt = random.nextInt(); + private final long pLong = random.nextLong(); + private final Integer [] intArray = { random.nextInt(), random.nextInt() }; + private final List boolList = new ArrayList(); + + MoreComplexObject() { + for(int i=0 ; i < 5; i++) { + boolList.add(random.nextBoolean()); + } + } + + @Override + public String toString() { + return string + integer + pInt + pLong + Arrays.asList(intArray) + boolList; + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MoreComplexObjectTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MoreComplexObjectTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..d55ed3860156d8ba4aba299deaefd2e0704c20ce --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/MoreComplexObjectTest.java" @@ -0,0 +1,103 @@ +/* + * 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.serialization; + +import static org.junit.Assert.assertEquals; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.Random; + +import org.junit.Before; +import org.junit.Test; + +/** This is more an example than a test - deserialize our {@link MoreComplexObject} + * to verify which settings it requires, as the object uses a number of primitive + * and java.* member objects. + */ +public class MoreComplexObjectTest extends ClosingBase { + + private InputStream inputStream; + private MoreComplexObject original; + + @Before + public void setup() throws IOException { + original = new MoreComplexObject(); + final ByteArrayOutputStream bos = willClose(new ByteArrayOutputStream()); + final ObjectOutputStream oos = willClose(new ObjectOutputStream(bos)); + oos.writeObject(original); + inputStream = willClose(new ByteArrayInputStream(bos.toByteArray())); + } + + private void assertSerialization(ObjectInputStream ois) throws ClassNotFoundException, IOException { + final MoreComplexObject copy = (MoreComplexObject) (ois.readObject()); + assertEquals("Expecting same data after deserializing", original.toString(), copy.toString()); + } + + /** Trusting java.lang.* and the array variants of that means we have + * to define a number of accept classes explicitly. Quite safe but + * might become a bit verbose. + */ + @Test + public void trustJavaLang() throws IOException, ClassNotFoundException { + assertSerialization(willClose( + new ValidatingObjectInputStream(inputStream) + .accept(MoreComplexObject.class, ArrayList.class, Random.class) + .accept("java.lang.*","[Ljava.lang.*") + )); + } + + /** Trusting java.* is probably reasonable and avoids having to be too + * detailed in the accepts. + */ + @Test + public void trustJavaIncludingArrays() throws IOException, ClassNotFoundException { + assertSerialization(willClose( + new ValidatingObjectInputStream(inputStream) + .accept(MoreComplexObject.class) + .accept("java.*","[Ljava.*") + )); + } + + /** Here we accept everything but reject specific classes, using a pure + * blacklist mode. + * + * That's not as safe as it's hard to get an exhaustive blacklist, but + * might be ok in controlled environments. + */ + @Test + public void useBlacklist() throws IOException, ClassNotFoundException { + final String [] blacklist = { + "org.apache.commons.collections.functors.InvokerTransformer", + "org.codehaus.groovy.runtime.ConvertedClosure", + "org.codehaus.groovy.runtime.MethodClosure", + "org.springframework.beans.factory.ObjectFactory" + }; + assertSerialization(willClose( + new ValidatingObjectInputStream(inputStream) + .accept("*") + .reject(blacklist) + )); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..4225aba05c6867561468c1433bc9d0a999dc1f2c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/RegexpClassNameMatcherTest.java" @@ -0,0 +1,61 @@ +/* + * 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.serialization; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.regex.Pattern; + +import org.junit.Test; + +public class RegexpClassNameMatcherTest { + + @Test + public void testSimplePatternFromString() { + ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*"); + assertTrue(ca.matches("foo.should.match")); + assertFalse(ca.matches("bar.should.not.match")); + } + + @Test + public void testSimplePatternFromPattern() { + ClassNameMatcher ca = new RegexpClassNameMatcher(Pattern.compile("foo.*")); + assertTrue(ca.matches("foo.should.match")); + assertFalse(ca.matches("bar.should.not.match")); + } + + @Test + public void testOrPattern() { + ClassNameMatcher ca = new RegexpClassNameMatcher("foo.*|bar.*"); + assertTrue(ca.matches("foo.should.match")); + assertTrue(ca.matches("bar.should.match")); + assertFalse(ca.matches("zoo.should.not.match")); + } + + @Test(expected=NullPointerException.class) + public void testNullStringPattern() { + new RegexpClassNameMatcher((String)null); + } + + @Test(expected=IllegalArgumentException.class) + public void testNullPatternPattern() { + new RegexpClassNameMatcher((Pattern)null); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..4f6e70b9a548b2b8fac3c67f16589b207583a029 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/ValidatingObjectInputStreamTest.java" @@ -0,0 +1,224 @@ +/* + * 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.serialization; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InvalidClassException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.UUID; +import java.util.regex.Pattern; + +import org.junit.Before; +import org.junit.Test; + +public class ValidatingObjectInputStreamTest extends ClosingBase { + private MockSerializedClass testObject; + private InputStream testStream; + + static private final ClassNameMatcher ALWAYS_TRUE = new ClassNameMatcher() { + @Override + public boolean matches(String className) { + return true; + } + }; + + @Before + public void setup() throws IOException { + testObject = new MockSerializedClass(UUID.randomUUID().toString()); + final ByteArrayOutputStream bos = willClose(new ByteArrayOutputStream()); + final ObjectOutputStream oos = willClose(new ObjectOutputStream(bos)); + oos.writeObject(testObject); + testStream = willClose(new ByteArrayInputStream(bos.toByteArray())); + } + + private void assertSerialization(ObjectInputStream ois) throws ClassNotFoundException, IOException { + final MockSerializedClass result = (MockSerializedClass) (ois.readObject()); + assertEquals(testObject, result); + } + + @Test(expected = InvalidClassException.class) + public void noAccept() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream))); + } + + @Test + public void exceptionIncludesClassName() throws Exception { + try { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream))); + fail("Expected an InvalidClassException"); + } catch(InvalidClassException ice) { + final String name = MockSerializedClass.class.getName(); + assertTrue("Expecting message to contain " + name, ice.getMessage().contains(name)); + } + } + + @Test + public void acceptCustomMatcher() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(ALWAYS_TRUE) + ); + } + + @Test(expected = InvalidClassException.class) + public void rejectCustomMatcher() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(MockSerializedClass.class) + .reject(ALWAYS_TRUE) + ); + } + + @Test + public void acceptPattern() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(Pattern.compile(".*MockSerializedClass.*")) + ); + } + + @Test(expected = InvalidClassException.class) + public void rejectPattern() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(MockSerializedClass.class) + .reject(Pattern.compile("org.*")) + ); + } + + @Test + public void acceptWildcard() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept("org.apache.commons.io.*") + ); + } + + @Test(expected = InvalidClassException.class) + public void rejectWildcard() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(MockSerializedClass.class) + .reject("org.*") + ); + } + + @Test(expected = InvalidClassException.class) + public void ourTestClassNotAccepted() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(Integer.class) + ); + } + + @Test + public void ourTestClassOnlyAccepted() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(MockSerializedClass.class) + ); + } + + @Test + public void ourTestClassAcceptedFirst() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(MockSerializedClass.class, Integer.class) + ); + } + + @Test + public void ourTestClassAcceptedSecond() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(Integer.class, MockSerializedClass.class) + ); + } + + @Test + public void ourTestClassAcceptedFirstWildcard() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept("*MockSerializedClass","*Integer") + ); + } + + @Test + public void ourTestClassAcceptedSecondWildcard() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept("*Integer","*MockSerializedClass") + ); + } + + @Test(expected = InvalidClassException.class) + public void reject() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(Long.class) + .reject(MockSerializedClass.class, Integer.class) + ); + } + + @Test(expected = InvalidClassException.class) + public void rejectPrecedence() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .accept(MockSerializedClass.class) + .reject(MockSerializedClass.class, Integer.class) + ); + } + + @Test(expected = InvalidClassException.class) + public void rejectOnly() throws Exception { + assertSerialization( + willClose(new ValidatingObjectInputStream(testStream)) + .reject(Integer.class) + ); + } + + @Test(expected = RuntimeException.class) + public void customInvalidMethod() throws Exception { + class CustomVOIS extends ValidatingObjectInputStream { + CustomVOIS(InputStream is) throws IOException { + super(is); + } + + @Override + protected void invalidClassNameFound(String className) throws InvalidClassException { + throw new RuntimeException("Custom exception"); + } + }; + + assertSerialization( + willClose(new CustomVOIS(testStream)) + .reject(Integer.class) + ); + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..59a950b7a212914a5ba938ec064d2bb6fb06fff4 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/serialization/WildcardClassNameMatcherTest.java" @@ -0,0 +1,50 @@ +/* + * 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.serialization; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class WildcardClassNameMatcherTest { + + @Test + public void noPattern() { + ClassNameMatcher ca = new WildcardClassNameMatcher("org.foo"); + assertTrue(ca.matches("org.foo")); + assertFalse(ca.matches("org.foo.and.more")); + assertFalse(ca.matches("org_foo")); + } + + @Test + public void star() { + ClassNameMatcher ca = new WildcardClassNameMatcher("org*"); + assertTrue(ca.matches("org.foo.should.match")); + assertFalse(ca.matches("bar.should.not.match")); + } + + @Test + public void starAndQuestionMark() { + ClassNameMatcher ca = new WildcardClassNameMatcher("org?apache?something*"); + assertTrue(ca.matches("org.apache_something.more")); + assertFalse(ca.matches("org..apache_something.more")); + } + +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/FileBasedTestCase.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/FileBasedTestCase.java" new file mode 100644 index 0000000000000000000000000000000000000000..33b694145881ef90064c9f888474c13775fd0a2b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/FileBasedTestCase.java" @@ -0,0 +1,38 @@ +/* + * 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.testtools; + +import java.io.*; + +/** + * Base class for testcases doing tests with files. + */ +public abstract class FileBasedTestCase { + + private static volatile File testDir; + + @SuppressWarnings("ResultOfMethodCallIgnored") + public static File getTestDirectory() { + if (testDir == null) { + testDir = new File("test/io/").getAbsoluteFile(); + } + testDir.mkdirs(); + return testDir; + } + + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/TestUtils.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/TestUtils.java" new file mode 100644 index 0000000000000000000000000000000000000000..467d0c6704b49cb45de4b511940fa626f4903896 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/TestUtils.java" @@ -0,0 +1,248 @@ +/* + * 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.testtools; + +import junit.framework.AssertionFailedError; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.output.ByteArrayOutputStream; + +import java.io.*; +import java.util.Arrays; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +/** + * Base class for testcases doing tests with files. + */ +public abstract class TestUtils { + + private TestUtils() { + + } + + public static void createFile(final File file, final long size) + throws IOException { + if (!file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + + " as the parent directory does not exist"); + } + final BufferedOutputStream output = + new BufferedOutputStream(new java.io.FileOutputStream(file)); + try { + generateTestData(output, size); + } finally { + IOUtils.closeQuietly(output); + } + } + + public static byte[] generateTestData(final long size) { + try { + final ByteArrayOutputStream baout = new ByteArrayOutputStream(); + generateTestData(baout, size); + return baout.toByteArray(); + } catch (final IOException ioe) { + throw new RuntimeException("This should never happen: " + ioe.getMessage()); + } + } + + public static void generateTestData(final OutputStream out, final long size) + throws IOException { + for (int i = 0; i < size; i++) { + //output.write((byte)'X'); + + // nice varied byte pattern compatible with Readers and Writers + out.write((byte) ((i % 127) + 1)); + } + } + + public static void createLineBasedFile(final File file, final String[] data) throws IOException { + if (file.getParentFile() != null && !file.getParentFile().exists()) { + throw new IOException("Cannot create file " + file + " as the parent directory does not exist"); + } + final PrintWriter output = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); + try { + for (final String element : data) { + output.println(element); + } + } finally { + IOUtils.closeQuietly(output); + } + } + + public static File newFile(File testDirectory, final String filename) throws IOException { + final File destination = new File(testDirectory, filename); + /* + assertTrue( filename + "Test output data file shouldn't previously exist", + !destination.exists() ); + */ + if (destination.exists()) { + FileUtils.forceDelete(destination); + } + return destination; + } + + public static void checkFile(final File file, final File referenceFile) + throws Exception { + assertTrue("Check existence of output file", file.exists()); + assertEqualContent(referenceFile, file); + } + + /** + * Assert that the content of two files is the same. + */ + private static void assertEqualContent(final File f0, final File f1) + throws IOException { + /* This doesn't work because the filesize isn't updated until the file + * is closed. + assertTrue( "The files " + f0 + " and " + f1 + + " have differing file sizes (" + f0.length() + + " vs " + f1.length() + ")", ( f0.length() == f1.length() ) ); + */ + final InputStream is0 = new java.io.FileInputStream(f0); + try { + final InputStream is1 = new java.io.FileInputStream(f1); + try { + final byte[] buf0 = new byte[1024]; + final byte[] buf1 = new byte[1024]; + int n0 = 0; + int n1; + + while (-1 != n0) { + n0 = is0.read(buf0); + n1 = is1.read(buf1); + assertTrue("The files " + f0 + " and " + f1 + + " have differing number of bytes available (" + n0 + + " vs " + n1 + ")", (n0 == n1)); + + assertTrue("The files " + f0 + " and " + f1 + + " have different content", Arrays.equals(buf0, buf1)); + } + } finally { + is1.close(); + } + } finally { + is0.close(); + } + } + + /** + * Assert that the content of a file is equal to that in a byte[]. + * + * @param b0 the expected contents + * @param file the file to check + * @throws IOException If an I/O error occurs while reading the file contents + */ + public static void assertEqualContent(final byte[] b0, final File file) throws IOException { + final InputStream is = new java.io.FileInputStream(file); + int count = 0, numRead = 0; + final byte[] b1 = new byte[b0.length]; + try { + while (count < b0.length && numRead >= 0) { + numRead = is.read(b1, count, b0.length); + count += numRead; + } + assertEquals("Different number of bytes: ", b0.length, count); + for (int i = 0; i < count; i++) { + assertEquals("byte " + i + " differs", b0[i], b1[i]); + } + } finally { + is.close(); + } + } + + /** + * Assert that the content of a file is equal to that in a char[]. + * + * @param c0 the expected contents + * @param file the file to check + * @throws IOException If an I/O error occurs while reading the file contents + */ + public static void assertEqualContent(final char[] c0, final File file) throws IOException { + final Reader ir = new java.io.FileReader(file); + int count = 0, numRead = 0; + final char[] c1 = new char[c0.length]; + try { + while (count < c0.length && numRead >= 0) { + numRead = ir.read(c1, count, c0.length); + count += numRead; + } + assertEquals("Different number of chars: ", c0.length, count); + for (int i = 0; i < count; i++) { + assertEquals("char " + i + " differs", c0[i], c1[i]); + } + } finally { + ir.close(); + } + } + + public static void checkWrite(final OutputStream output) throws Exception { + try { + new java.io.PrintStream(output).write(0); + } catch (final Throwable t) { + throw new AssertionFailedError( + "The copy() method closed the stream " + + "when it shouldn't have. " + + t.getMessage()); + } + } + + public static void checkWrite(final Writer output) throws Exception { + try { + new java.io.PrintWriter(output).write('a'); + } catch (final Throwable t) { + throw new AssertionFailedError( + "The copy() method closed the stream " + + "when it shouldn't have. " + + t.getMessage()); + } + } + + public static void deleteFile(final File file) + throws Exception { + if (file.exists()) { + assertTrue("Couldn't delete file: " + file, file.delete()); + } + } + + /** + * Sleep for a guaranteed 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 details. + * @ + * @param ms the number of milliseconds to sleep for + * @throws InterruptedException if interrupted + */ + public 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); + } + + public static void sleepQuietly(long ms) { + try { + sleep(ms); + } catch (InterruptedException ignored){ + } + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/YellOnCloseInputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/YellOnCloseInputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..0e940dcf62b9b349e1e4e8b802e7b86d6894c22f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/YellOnCloseInputStream.java" @@ -0,0 +1,44 @@ +/* + * 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.testtools; + +import java.io.IOException; +import java.io.InputStream; + +import junit.framework.AssertionFailedError; + +import org.apache.commons.io.input.ProxyInputStream; + +/** + * Helper class for checking behaviour of IO classes. + */ +public class YellOnCloseInputStream extends ProxyInputStream { + + /** + * @param proxy InputStream to delegate to. + */ + public YellOnCloseInputStream(final InputStream proxy) { + super(proxy); + } + + /** @see java.io.InputStream#close() */ + @Override + public void close() throws IOException { + throw new AssertionFailedError("close() was called on OutputStream"); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/YellOnFlushAndCloseOutputStream.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/YellOnFlushAndCloseOutputStream.java" new file mode 100644 index 0000000000000000000000000000000000000000..7c73d0d5c86459a9aeb4abe548c9db42e4a7bf40 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/java/org/apache/commons/io/testtools/YellOnFlushAndCloseOutputStream.java" @@ -0,0 +1,68 @@ +/* + * 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.testtools; + +import java.io.IOException; +import java.io.OutputStream; + +import junit.framework.AssertionFailedError; + +import org.apache.commons.io.output.ProxyOutputStream; + +/** + * Helper class for checking behaviour of IO classes. + */ +public class YellOnFlushAndCloseOutputStream extends ProxyOutputStream { + + private boolean yellForFlush; + private boolean yellForClose; + + /** + * @param proxy OutputStream to delegate to. + * @param yellForFlush True if flush() is forbidden + * @param yellForClose True if close() is forbidden + */ + public YellOnFlushAndCloseOutputStream(final OutputStream proxy, final boolean yellForFlush, final boolean yellForClose) { + super(proxy); + this.yellForFlush = yellForFlush; + this.yellForClose = yellForClose; + } + + /** @see java.io.OutputStream#flush() */ + @Override + public void flush() throws IOException { + if (yellForFlush) { + throw new AssertionFailedError("flush() was called on OutputStream"); + } + super.flush(); + } + + /** @see java.io.OutputStream#close() */ + @Override + public void close() throws IOException { + if (yellForClose) { + throw new AssertionFailedError("close() was called on OutputStream"); + } + super.close(); + } + + public void off() { + yellForFlush = false; + yellForClose = false; + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataCR.dat" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataCR.dat" new file mode 100644 index 0000000000000000000000000000000000000000..beff0d6db42ac7b78efcb84effaf900d8b37c3d2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataCR.dat" @@ -0,0 +1 @@ +1 2 3 \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataCRLF.dat" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataCRLF.dat" new file mode 100644 index 0000000000000000000000000000000000000000..294d77900d9a99f99d53ad9d8d40942024d5f166 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataCRLF.dat" @@ -0,0 +1,3 @@ +1 +2 +3 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataLF.dat" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataLF.dat" new file mode 100644 index 0000000000000000000000000000000000000000..01e79c32a8c99c557f0757da7cb6d65b3414466d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/FileUtilsTestDataLF.dat" @@ -0,0 +1,3 @@ +1 +2 +3 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/testfileBOM.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/testfileBOM.xml" new file mode 100644 index 0000000000000000000000000000000000000000..9701aaa3e51673b78349ab4706c4197dcde71c19 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/testfileBOM.xml" @@ -0,0 +1,40 @@ + + + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + +Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. + +Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. + +Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. + +At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. + +Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus. + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + +Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. + +Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/testfileNoBOM.xml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/testfileNoBOM.xml" new file mode 100644 index 0000000000000000000000000000000000000000..0c9c9513a19f4b97e27f115d4f85d7320c255e2c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/org/apache/commons/io/testfileNoBOM.xml" @@ -0,0 +1,40 @@ + + + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + +Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. + +Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. + +Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. + +At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. + +Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus. + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. + +Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. + +Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-20byteslength.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-20byteslength.bin" new file mode 100644 index 0000000000000000000000000000000000000000..1823b69e951b145d9765c787e6523fd43e3efc3b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-20byteslength.bin" @@ -0,0 +1,2 @@ +123456789 +123456789 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-empty.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-empty.bin" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-gbk.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-gbk.bin" new file mode 100644 index 0000000000000000000000000000000000000000..5c1efeb6f42effe920f9e338ac2f0df4c6a4bbf7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-gbk.bin" @@ -0,0 +1,2 @@ +Ã÷ݔ×Ӿ© +¼òÌåÖÐÎÄ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-iso8859-1-shortlines-win-linebr.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-iso8859-1-shortlines-win-linebr.bin" new file mode 100644 index 0000000000000000000000000000000000000000..6291acb98f63ec7727a26d58cc7866ab86890a13 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-iso8859-1-shortlines-win-linebr.bin" @@ -0,0 +1,12 @@ +1 + + + +2 + + + +3 + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-iso8859-1.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-iso8859-1.bin" new file mode 100644 index 0000000000000000000000000000000000000000..db93dd9ab5c35068400cfaae126c9fa3ef7f11ad --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-iso8859-1.bin" @@ -0,0 +1,52 @@ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²® +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±² +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£± +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ © +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïç +A Test Line. Special chars: ÄäÜüÖöß Ãáéíï +A Test Line. Special chars: ÄäÜüÖöß Ãáéí +A Test Line. Special chars: ÄäÜüÖöß Ãáé +A Test Line. Special chars: ÄäÜüÖöß Ãá +A Test Line. Special chars: ÄäÜüÖöß Ã +A Test Line. Special chars: ÄäÜüÖöß +A Test Line. Special chars: ÄäÜüÖöß +A Test Line. Special chars: ÄäÜüÖö +A Test Line. Special chars: ÄäÜüÖ +A Test Line. Special chars: ÄäÜü +A Test Line. Special chars: ÄäÜ +A Test Line. Special chars: Ää +A Test Line. Special chars: Ä +A Test Line. Special chars: +A Test Line. Special chars: +A Test Line. Special chars +A Test Line. Special char +A Test Line. Special cha +A Test Line. Special ch +A Test Line. Special c +A Test Line. Special +A Test Line. Special +A Test Line. Specia +A Test Line. Speci +A Test Line. Spec +A Test Line. Spe +A Test Line. Sp +A Test Line. S +A Test Line. +A Test Line. +A Test Line +A Test Lin +A Test Li +A Test L +A Test +A Test +A Tes +A Te +A T +A +A diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-shiftjis.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-shiftjis.bin" new file mode 100644 index 0000000000000000000000000000000000000000..74c6d05b328ca6cada8b525cb25ddd627976a6a0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-shiftjis.bin" @@ -0,0 +1,2 @@ +Hiragana letters: ‚Ÿ‚ ‚¡‚¢‚£ +Kanji letters: –¾—AŽq‹ž diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf16be.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf16be.bin" new file mode 100644 index 0000000000000000000000000000000000000000..31bef00dfc0340d85ec26a1f7295b2d7cb436a1e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf16be.bin" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf16le.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf16le.bin" new file mode 100644 index 0000000000000000000000000000000000000000..023d31c41134f9eb8d28ba277a950a40c95343f3 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf16le.bin" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8-cr-only.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8-cr-only.bin" new file mode 100644 index 0000000000000000000000000000000000000000..42748a83c28ac11902071528d0e3ce6df7403098 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8-cr-only.bin" @@ -0,0 +1 @@ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²® A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±² A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£± A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£ A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥ A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ © A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ A Test Line. Special chars: ÄäÜüÖöß Ãáéíïç A Test Line. Special chars: ÄäÜüÖöß Ãáéíï A Test Line. Special chars: ÄäÜüÖöß Ãáéí A Test Line. Special chars: ÄäÜüÖöß Ãáé A Test Line. Special chars: ÄäÜüÖöß Ãá A Test Line. Special chars: ÄäÜüÖöß Ã A Test Line. Special chars: ÄäÜüÖöß A Test Line. Special chars: ÄäÜüÖöß A Test Line. Special chars: ÄäÜüÖö A Test Line. Special chars: ÄäÜüÖ A Test Line. Special chars: ÄäÜü A Test Line. Special chars: ÄäÜ A Test Line. Special chars: Ää A Test Line. Special chars: Ä A Test Line. Special chars: A Test Line. Special chars: A Test Line. Special chars A Test Line. Special char A Test Line. Special cha A Test Line. Special ch A Test Line. Special c A Test Line. Special A Test Line. Special A Test Line. Specia A Test Line. Speci A Test Line. Spec A Test Line. Spe A Test Line. Sp A Test Line. S A Test Line. A Test Line. A Test Line A Test Lin A Test Li A Test L A Test A Test A Tes A Te A T A A \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8-win-linebr.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8-win-linebr.bin" new file mode 100644 index 0000000000000000000000000000000000000000..91b0a066c6f9fa377c2638a9a88155c349f7988c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8-win-linebr.bin" @@ -0,0 +1,52 @@ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²® +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±² +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£± +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ © +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïç +A Test Line. Special chars: ÄäÜüÖöß Ãáéíï +A Test Line. Special chars: ÄäÜüÖöß Ãáéí +A Test Line. Special chars: ÄäÜüÖöß Ãáé +A Test Line. Special chars: ÄäÜüÖöß Ãá +A Test Line. Special chars: ÄäÜüÖöß Ã +A Test Line. Special chars: ÄäÜüÖöß +A Test Line. Special chars: ÄäÜüÖöß +A Test Line. Special chars: ÄäÜüÖö +A Test Line. Special chars: ÄäÜüÖ +A Test Line. Special chars: ÄäÜü +A Test Line. Special chars: ÄäÜ +A Test Line. Special chars: Ää +A Test Line. Special chars: Ä +A Test Line. Special chars: +A Test Line. Special chars: +A Test Line. Special chars +A Test Line. Special char +A Test Line. Special cha +A Test Line. Special ch +A Test Line. Special c +A Test Line. Special +A Test Line. Special +A Test Line. Specia +A Test Line. Speci +A Test Line. Spec +A Test Line. Spe +A Test Line. Sp +A Test Line. S +A Test Line. +A Test Line. +A Test Line +A Test Lin +A Test Li +A Test L +A Test +A Test +A Tes +A Te +A T +A +A diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8.bin" new file mode 100644 index 0000000000000000000000000000000000000000..616b09137875e29bfbc94ef17c57c2d3f2740f1c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-utf8.bin" @@ -0,0 +1,52 @@ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±²® +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£±² +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£± +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥£ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ¥ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ ©µ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ © +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïçñ +A Test Line. Special chars: ÄäÜüÖöß Ãáéíïç +A Test Line. Special chars: ÄäÜüÖöß Ãáéíï +A Test Line. Special chars: ÄäÜüÖöß Ãáéí +A Test Line. Special chars: ÄäÜüÖöß Ãáé +A Test Line. Special chars: ÄäÜüÖöß Ãá +A Test Line. Special chars: ÄäÜüÖöß Ã +A Test Line. Special chars: ÄäÜüÖöß +A Test Line. Special chars: ÄäÜüÖöß +A Test Line. Special chars: ÄäÜüÖö +A Test Line. Special chars: ÄäÜüÖ +A Test Line. Special chars: ÄäÜü +A Test Line. Special chars: ÄäÜ +A Test Line. Special chars: Ää +A Test Line. Special chars: Ä +A Test Line. Special chars: +A Test Line. Special chars: +A Test Line. Special chars +A Test Line. Special char +A Test Line. Special cha +A Test Line. Special ch +A Test Line. Special c +A Test Line. Special +A Test Line. Special +A Test Line. Specia +A Test Line. Speci +A Test Line. Spec +A Test Line. Spe +A Test Line. Sp +A Test Line. S +A Test Line. +A Test Line. +A Test Line +A Test Lin +A Test Li +A Test L +A Test +A Test +A Tes +A Te +A T +A +A diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-windows-31j.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-windows-31j.bin" new file mode 100644 index 0000000000000000000000000000000000000000..eff55df94e85281e69f7f7bbee3490ddcc8c911b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-windows-31j.bin" @@ -0,0 +1,2 @@ +‚Ÿ‚ ‚¡‚¢‚£ +–¾—AŽq‹ž diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-x-windows-949.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-x-windows-949.bin" new file mode 100644 index 0000000000000000000000000000000000000000..60d203e0b445bac19da748b60d08eb2e64d2b789 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-x-windows-949.bin" @@ -0,0 +1,2 @@ +Çѱ¹¾î +´ëÇѹα¹ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-x-windows-950.bin" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-x-windows-950.bin" new file mode 100644 index 0000000000000000000000000000000000000000..7c9cd59c8a00e0bd3f18da42b32cd40024ad1505 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5-src/src/test/resources/test-file-x-windows-950.bin" @@ -0,0 +1,2 @@ +©ú¿é¤l¨Ê +ÁcÅ餤¤å diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/LICENSE.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/LICENSE.txt" new file mode 100644 index 0000000000000000000000000000000000000000..6b0b1270ff0ca8f03867efcd09ba6ddb6392b1e1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/LICENSE.txt" @@ -0,0 +1,203 @@ + + 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. + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/NOTICE.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/NOTICE.txt" new file mode 100644 index 0000000000000000000000000000000000000000..18053bbe1a8e79d87fe357d053b55042d6699c06 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/NOTICE.txt" @@ -0,0 +1,5 @@ +Apache Commons IO +Copyright 2002-2016 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/RELEASE-NOTES.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/RELEASE-NOTES.txt" new file mode 100644 index 0000000000000000000000000000000000000000..5c0b9360f79022f8c842894281dcd29a57369a32 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/RELEASE-NOTES.txt" @@ -0,0 +1,993 @@ + +Apache Commons IO +Version 2.5 +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. + +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 to +sebb. +o IO-333: Export OSGi packages at version 1.x in addition to 2.x. Thanks +to fmeschbe. +o IO-320: Add XmlStreamReader support for UTF-32. Thanks to ggregory. +o IO-331: BOMInputStream wrongly detects UTF-32LE_BOM files as +UTF-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. Thanks +to raviprak. +o IO-324: Add missing Charset sister APIs to method that take a String +charset name. Thanks to raviprak. + +Fixed Bugs: +o IO-336: Yottabyte (YB) incorrectly defined in FileUtils. Thanks to +rleavelle. +o IO-279: Tailer erroneously considers file as new. Thanks to Sergio +Bossa, Chris Baron. +o IO-335: Tailer#readLines - incorrect CR handling. +o IO-334: FileUtils.toURLs throws NPE for null parameter; document the +behavior. +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 to +raviprak. + + +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: Yes +Source compatible: Yes +Semantic 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 for +those 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 JIRA +http://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 Team diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileSystemUtils.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileSystemUtils.class" index ff58050b5d9150f715322e110e02956de3efbe19..6abd124687cbe97090415222c2c9a8f9aef17297 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileSystemUtils.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileSystemUtils.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils$1.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils$1.class" index 7683be8490696af802204c47658cf82b85b0076c..c3c0a31de89af5736b1e6dfb391f8a76f8f2e07c 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils$1.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils$1.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils.class" index 87a01ea6bb490512dc5bca407e28ea95c544edd7..c20d3c648a35dff74133532792569d1f88766733 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FileUtils.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FilenameUtils.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FilenameUtils.class" index 5c66bf5a064bac3796ebb2400280e056d8a16007..8d9c48a6fc6bc21f0f59b28984c6af7e5784187d 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FilenameUtils.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/FilenameUtils.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/HexDump.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/HexDump.class" index 73e06279fc4b7260dec70ae7d2c66afc8d76e625..e3470bdea4f2db1ea008bcfbc1ab1272729c45ab 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/HexDump.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/HexDump.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOCase.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOCase.class" index 3d9f52f87215b89ae6ce275f96f5fae2172b3a99..d167006b3d40b968287e8bd41101dd041cca80e2 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOCase.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOCase.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOExceptionWithCause.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOExceptionWithCause.class" index b056906e32aabb6939b0a99e607902a0d385aa5d..6005008d5c14f90f01ad1b64c0d99ecafc08999e 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOExceptionWithCause.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOExceptionWithCause.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOUtils.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOUtils.class" index 2a82a1dad89fc0c1b2598efff6692af0d603efb1..120d62cb45733cdbee1cfd773c6dcc8d8a9c0465 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOUtils.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/IOUtils.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/Java7Support.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/Java7Support.class" index 735381b062058e517b0befa4b86ca474a1d4ac29..4f7e9f664e8195ab5edd4313350c99e6f32fdb61 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/Java7Support.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/Java7Support.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/LineIterator.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/LineIterator.class" index 729ed3a544653ce3796f5b653a50812dfe48be89..08221a75d9b59ee0f1bfbca925b7072b472df67b 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/LineIterator.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/LineIterator.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/TaggedIOException.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/TaggedIOException.class" index 25131553a1c85a98f84c48b134e5bee92fd7e9b4..cac6aa0ac4d68dd1459453941d2a705e3bae20f0 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/TaggedIOException.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/TaggedIOException.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/ThreadMonitor.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/ThreadMonitor.class" index 190baa06ca8956dc04943e4b39e91e3d4350705e..2c29ef66244577af59048a858000cd68f76bdb56 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/ThreadMonitor.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/ThreadMonitor.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/AutoCloseInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/AutoCloseInputStream.class" index 43e17b1312903ca04fc4e300484b4f490dc20a50..6c565dbb9dd34cc0360fbe947ad3b1264d7c889e 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/AutoCloseInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/AutoCloseInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream$1.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream$1.class" index d3cab2030ea863554a67e7bcbf84cadf2649cac1..4c7328e3decf13b23bd2bca1c5c5fb6cdce8d4ef 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream$1.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream$1.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream.class" index 75fe0821a1ae50e91d4ce99df5754885b00e5838..8bb36a3c83b844035ad9f80630e367a420a7109c 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BOMInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedInputStream.class" index 6d4006f579975b3822f560a15caa94d499fbf97f..d230fb995a6566d6c41077e4366e745c9115932a 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedReader.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedReader.class" index c051ec6204fa5d0df9a068b0ea60ebd0d63bf7dc..e0abdf5929fb9867319cf00facfb39941cc51605 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedReader.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BoundedReader.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BrokenInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BrokenInputStream.class" index 5a639113dc2d7c1d57c895123d5c99d93fd846ba..c4ed6a991e52756c3b77f443c57078cbc2ac1068 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BrokenInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/BrokenInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceInputStream.class" index faad5ce84e3656b2ed128becb5782d2f48deaca4..4c5fbb9a22c296c3b6c983af2b93fea06dec3952 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceReader.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceReader.class" index 6465b767c7fd10cee00d74af2a83872831bd15bb..787d2a9c82c7614c4f6b23b4fe915a68e09f19ce 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceReader.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CharSequenceReader.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClassLoaderObjectInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClassLoaderObjectInputStream.class" index fb6f4e40644a73e327d0c468a02d6a073437115c..b41333f6a044364df38d17ee843f380dbdef1cd9 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClassLoaderObjectInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClassLoaderObjectInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CloseShieldInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CloseShieldInputStream.class" index cfcc1d6fb43b136429deb88ac35bb1d37c1a883b..89c5b5d0696d5cfd41175ceb557d286357dc6fd6 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CloseShieldInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CloseShieldInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClosedInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClosedInputStream.class" index a84fe5558cdca1bd04598c76d68e7a5085f40746..0065e1246a520b06f71a25421f33bd6e595d89dc 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClosedInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ClosedInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CountingInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CountingInputStream.class" index 9a5576f27ae0cad61a783b226b507a69b934d354..06fb2f4da4028f9dff03936324931270ae8e3f16 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CountingInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/CountingInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/DemuxInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/DemuxInputStream.class" index 4240c41b965e265a3321a07d827f025fbd44b172..c5198b71198d49e53b188424846355e90c4a5827 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/DemuxInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/DemuxInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullInputStream.class" index d9093e5d426a9cc2b6242fa7d31818b562b90eff..963c2187722c76152724b6f93c5a9adbf067a35a 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullReader.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullReader.class" index 00e4416ecdc0ec5fcbb177804864a8791a47f3c9..dab6853301bd59b954732c373b6ceccd3d08e821 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullReader.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/NullReader.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyInputStream.class" index c732845a0364b41b80762177a9230b009e55b487..7516fdaca4084d5f7ce1908f8e7f318540c5b149 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyReader.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyReader.class" index 824f21ec672be2dd60d595fb8aa1f6f928e0dcb6..d611c1dc993f58b44b6aa5297fa7ef96e49c803a 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyReader.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ProxyReader.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReaderInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReaderInputStream.class" index 5877db240a890fbecf6f1d27d68e3c59c065b03f..6ee00fbf0b63510f86d4945f92615a7101f9ede5 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReaderInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReaderInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$1.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$1.class" index 5d49a0d7d6e8815056d8ef8364d9bb4be3a1326b..e7a796ca29bf8bf7bc1fb74de969caa56897f6dc 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$1.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$1.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$FilePart.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$FilePart.class" index 60c87d0b031ee3e85765113aaa1599f6ffd4612f..85b5fb4c27dd74115a8ef2f2dba49149e98be15c 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$FilePart.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader$FilePart.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader.class" index 7e5f3791e80b37120921b109e7c8b660574a8a30..c78565814154f66966321151fe1258ce19ffbd7e 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/ReversedLinesFileReader.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/SwappedDataInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/SwappedDataInputStream.class" index 644e2c803f14f522a30571041d90a7fd9d86f757..9901fdc0470125a769f15d14617913a174ecf42b 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/SwappedDataInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/SwappedDataInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TaggedInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TaggedInputStream.class" index 94148a7ccf1c599ae5ed98a587a025009562b04a..2e3c7571af904a38b3b56a01496d50d8001385da 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TaggedInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TaggedInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/Tailer.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/Tailer.class" index ae681aaf2a9c0db86f86909d6e19bbcf8660670a..bdb569381378b2892623320b0b0579331e079d03 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/Tailer.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/Tailer.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListener.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListener.class" index 209955e0c7e35aac886af85a73c3836db05be839..a0f1b7d9687f9858039327568994942cfac79990 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListener.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListener.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListenerAdapter.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListenerAdapter.class" index c854637d4f865cd78aeb753c018e5f48d052dfb3..347f0be72f58061ece9f7c6d4c13c56dae02c740 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListenerAdapter.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TailerListenerAdapter.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TeeInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TeeInputStream.class" index 9e2db14de1eee12733152db514f7a74a1d29efc3..0bf8ca7b5a3bf2b97a3d1b597503478c0b6df85a 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TeeInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/TeeInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/UnixLineEndingInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/UnixLineEndingInputStream.class" index 959a6e32609fd523c805405a64064a5dec649bfc..97a2687cec43afbb300f5dc649a7730ab5aa2762 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/UnixLineEndingInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/UnixLineEndingInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/WindowsLineEndingInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/WindowsLineEndingInputStream.class" index 9c1b49e8f3338dfec3c6643738b334ca11af1989..5c337d0607e624cd10208922ad476aa98683016a 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/WindowsLineEndingInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/WindowsLineEndingInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReader.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReader.class" index a1e94f9c1247ae2e63aba5bc027815f557efe62f..d2ef1872e21982d64340fd46a64bd32ed9a0007c 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReader.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReader.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReaderException.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReaderException.class" index 95512bcd30f91bb107b14e6ae0de59c60f254dc5..d0d2cf4ba2b731d6ea6e0e5a9dee95d8cbd6da3b 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReaderException.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/input/XmlStreamReaderException.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListener.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListener.class" index 925df84dd07bbd17471705617beb9f369e38e726..90ffd926efa970edad89c94ee99ac8fe9a0bb75b 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListener.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListener.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.class" index 71c9c97d2fac002ed2729d87c42477d6f8b1d11a..e3f7f582512b56fe938e8584cf5e28e7b4023ce8 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationMonitor.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationMonitor.class" index a4b954392329cf59b908efe774abbd16a9bf5e98..8a8f006df1e1c7bec36f905e2726952870f9eff5 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationMonitor.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationMonitor.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationObserver.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationObserver.class" index acda20ed54fff7065a015fa96f1d30c93dc3dbc1..f049b2b34551654d221e644c9381ae6a63eb2c2d 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationObserver.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileAlterationObserver.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileEntry.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileEntry.class" index f89fb288eeae98beb1db816a91796d6b2bad0e00..1d44b0f23fc52d7e8891a107d9100f655729e829 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileEntry.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/monitor/FileEntry.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/AppendableOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/AppendableOutputStream.class" index e05af33befb04e7648c7a4ad690708b31e9d7eb6..30d4951de780f690f73cc602f546c4b72265dfe2 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/AppendableOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/AppendableOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/BrokenOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/BrokenOutputStream.class" index 721feab83045a0426ce06c32798ed9e50af2d584..06c9873e82f5b4dea9ca2bdb9b202ed598a4aa34 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/BrokenOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/BrokenOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ByteArrayOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ByteArrayOutputStream.class" index 1e2a3ebe78965e6e7aa1d022b2f1d6a6ea336b14..84ed4fb93c559f1fc7c34d93f371ae37c0653350 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ByteArrayOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ByteArrayOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedOutputStream.class" index 0184fd8127ce0f2c7a0bc32b10348f41e3af087e..130cd1f7faa824422eec7ad3be8e221b228c446f 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedWriter.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedWriter.class" index 94d302a2a81086f25498f5905322db0df67ccfda..138fbc93dbe44d7e7349f341991dcf7954437de4 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedWriter.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ChunkedWriter.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CloseShieldOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CloseShieldOutputStream.class" index 24fc69be2eec117fa9796d6c076f54c109ee4718..734579ba3b8e5e762db92a2e8b8066fb3eb8ffd1 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CloseShieldOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CloseShieldOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ClosedOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ClosedOutputStream.class" index 8a26e0fffe2676599439570766f748e90ec17da6..c8dd34de8af171fb5723566a9bbfc373706792f1 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ClosedOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ClosedOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CountingOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CountingOutputStream.class" index b1065cfda78fff9bb58b5ba475508a6a20f9172f..65d60dd8b9c08cfd9871270fd0a0f7717e84b0c4 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CountingOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/CountingOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DeferredFileOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DeferredFileOutputStream.class" index 0f4fd710664ecdb0bbb423a6b35500fb58a89b78..db4824f10d409af5b3d02523a8cbff139c2a4ccc 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DeferredFileOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DeferredFileOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DemuxOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DemuxOutputStream.class" index ce4bfb8a043802cecadd3d580b0244f2a5a1884f..7cbb1f1b0f0dc5ace50366f1744349f67f65c8a1 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DemuxOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/DemuxOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/FileWriterWithEncoding.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/FileWriterWithEncoding.class" index 3a0b74e47a076440a806d17e916dddde9f81952b..20f17d4aef730ddf0bc744df5ec4ba8a69f56bc0 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/FileWriterWithEncoding.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/FileWriterWithEncoding.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/LockableFileWriter.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/LockableFileWriter.class" index 3aa6edf3afc3106770ff47562c44cffc9e6e54f7..f4d72ab345abb2d12fafaad51f8159d3c3c2ea60 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/LockableFileWriter.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/LockableFileWriter.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullOutputStream.class" index 1c28efe0cdf01a21228ad10a2e1f00f9acf878e6..c9a9e1d95e9083288683ec7f36bbbff1542aae6f 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullWriter.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullWriter.class" index 4034d32a05ea30ad497c10c0fa69678f07e6161f..87ff91f6adba5370a266fd9298e600caf8901e21 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullWriter.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/NullWriter.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyOutputStream.class" index 907bd8eb8c0c03c40bff868bb680d3508b18f7c3..e0619cc9be5b5656ebef74dc5a8f6b0acc76752d 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyWriter.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyWriter.class" index 1893d7090975ddcdb3968e433904fa8f2054e91d..813340fde9e3c8acbede57c3b461a8564cfd2ade 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyWriter.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ProxyWriter.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/StringBuilderWriter.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/StringBuilderWriter.class" index 83c7c0ab052b28c4d494bec1bd79da0fb4cf65ed..fc8ab4d2dc355d3e4520f98c79c829f05ed297a4 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/StringBuilderWriter.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/StringBuilderWriter.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TaggedOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TaggedOutputStream.class" index ad91910bc9b4524e79533053336700704f6c4f00..52b5a498444ce478c1273cb806fe3dce8bcf99c3 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TaggedOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TaggedOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TeeOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TeeOutputStream.class" index 2c0aa33debede06ecd74f33b0350629ae20018c7..7de3c99f8a8a8acff7ece6473949ff80cdc087a5 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TeeOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/TeeOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ThresholdingOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ThresholdingOutputStream.class" index eb673b1a67e13e516a079dec727059f9f4a6e204..5a5a18fe0371798575eea4994ca668cc5cf50649 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ThresholdingOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/ThresholdingOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/WriterOutputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/WriterOutputStream.class" index cbc432e635e3c54716843d2b19dd07689910e8c7..e9a280417f3923c3fe8350ace9e604f01aaca047 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/WriterOutputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/WriterOutputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/XmlStreamWriter.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/XmlStreamWriter.class" index 11dee6973562166783f22091fdb5cecefd21382f..608909937ef6fa83183f6d175509ec9764728e64 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/XmlStreamWriter.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/output/XmlStreamWriter.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ClassNameMatcher.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ClassNameMatcher.class" index aa2f5650daf627f7d37586897c3b0e653c17ddcb..6b952c44fd59ea8c6fa2db2134b307eff2db9685 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ClassNameMatcher.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ClassNameMatcher.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/FullClassNameMatcher.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/FullClassNameMatcher.class" index 1d02edabe81de22e8aa37193d0ecd4826f2dbc94..820f4ca7f2ca80deb601e4ba6ffbce940e648866 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/FullClassNameMatcher.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/FullClassNameMatcher.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/RegexpClassNameMatcher.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/RegexpClassNameMatcher.class" index a5e5378ead1ebc77942663905b15acc8cfbd2401..67234aa9e83378e6a00b1d481079cd397c06b80b 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/RegexpClassNameMatcher.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/RegexpClassNameMatcher.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ValidatingObjectInputStream.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ValidatingObjectInputStream.class" index c549d9d1ac49e33dcad72a47d8fffa113f25965d..ec2ec3a5c590770096d7183abdf216906bf5baaa 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ValidatingObjectInputStream.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/ValidatingObjectInputStream.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/WildcardClassNameMatcher.class" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/WildcardClassNameMatcher.class" index 70816bbcd0971241aefec3113ac8b4361d264172..07265df426da8c4e493318ea8e38d5219304c0ec 100644 Binary files "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/WildcardClassNameMatcher.class" and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/commons-io-2.5/org/apache/commons/io/serialization/WildcardClassNameMatcher.class" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-frame.html" index b7970096251cea06b5c7b6bd698e29bec3ba9544..0061da0fde4ea80b5ee63c466735c18484fe9403 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-frame.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-frame.html" @@ -1,3 +1,125 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3da351ccd45f2e1ccaa9fe45fdf041e854c59ba1d30c7a47f9cefdd0bf36014f -size 17854 + + + + + +All Classes (Apache Commons IO 2.5 API) + + + +

All Classes

+
+ +
+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-noframe.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-noframe.html" index a11090d7a54171f37cde0511481ecb73fb989026..3772c420a2538e6b8abac650d1d6f4c0d778a880 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-noframe.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/allclasses-noframe.html" @@ -1,3 +1,125 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:03f82dc67d539bbe610afbd6604ba9294e04416021fa8d8d290fe01c15e193c8 -size 15674 + + + + + +All Classes (Apache Commons IO 2.5 API) + + + +

All Classes

+
+ +
+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/constant-values.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/constant-values.html" index f9ed844330f66f892f98e23815836a4c8500cbe5..4dc961cffb0fc8f270f7fa8fdd6b8a03c2dd412c 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/constant-values.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/constant-values.html" @@ -1,3 +1,264 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8b645e95471be5fc184b847befece9767610ff8ef23e3ce8b29cbd086af8df6b -size 10245 + + + + + +Constant Field Values (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Constant Field Values

+

Contents

+ +
+
+ + +

org.apache.*

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/deprecated-list.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/deprecated-list.html" index f38d576d852bb0181dfb5cb934c604d86ac0dc08..1122d4ffa53f2555c2d1f3563a8f21a083feb7ba 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/deprecated-list.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/deprecated-list.html" @@ -1,3 +1,473 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e274226a93f1a1b832b59c13b255a96575dfd73f6662ad09624c22af03beb1f5 -size 28186 + + + + + +Deprecated List (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/help-doc.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/help-doc.html" index 4c2d7fcfc0fcda9207322d041185a65fdfa469e7..dbcecf342273e413347da5a3fb7cc339d9934dae 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/help-doc.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/help-doc.html" @@ -1,3 +1,220 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:61d6c0d0d267a31ec1dd1ddc0546b978e053d8bba6b21cad4753e279be0ce67d -size 8701 + + + + + +API Help (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

How This API Document Is Organized

+
This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+
+
+
    +
  • +

    Overview

    +

    The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

    +
  • +
  • +

    Package

    +

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    +
      +
    • Interfaces (italic)
    • +
    • Classes
    • +
    • Enums
    • +
    • Exceptions
    • +
    • Errors
    • +
    • Annotation Types
    • +
    +
  • +
  • +

    Class/Interface

    +

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    +
      +
    • Class inheritance diagram
    • +
    • Direct Subclasses
    • +
    • All Known Subinterfaces
    • +
    • All Known Implementing Classes
    • +
    • Class/interface declaration
    • +
    • Class/interface description
    • +
    +
      +
    • Nested Class Summary
    • +
    • Field Summary
    • +
    • Constructor Summary
    • +
    • Method Summary
    • +
    +
      +
    • Field Detail
    • +
    • Constructor Detail
    • +
    • Method Detail
    • +
    +

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

    +
  • +
  • +

    Annotation Type

    +

    Each annotation type has its own separate page with the following sections:

    +
      +
    • Annotation Type declaration
    • +
    • Annotation Type description
    • +
    • Required Element Summary
    • +
    • Optional Element Summary
    • +
    • Element Detail
    • +
    +
  • +
  • +

    Enum

    +

    Each enum has its own separate page with the following sections:

    +
      +
    • Enum declaration
    • +
    • Enum description
    • +
    • Enum Constant Summary
    • +
    • Enum Constant Detail
    • +
    +
  • +
  • +

    Use

    +

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

    +
  • +
  • +

    Tree (Class Hierarchy)

    +

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    +
      +
    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • +
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
    • +
    +
  • +
  • +

    Deprecated API

    +

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

    +
  • +
  • +

    Index

    +

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

    +
  • +
  • +

    Prev/Next

    +

    These links take you to the next or previous class, interface, package, or related page.

    +
  • +
  • +

    Frames/No Frames

    +

    These links show and hide the HTML frames. All pages are available with or without frames.

    +
  • +
  • +

    All Classes

    +

    The All Classes link shows all classes and interfaces except non-static nested types.

    +
  • +
  • +

    Serialized Form

    +

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

    +
  • +
  • +

    Constant Field Values

    +

    The Constant Field Values page lists the static final fields and their values.

    +
  • +
+This help file applies to API documentation generated using the standard doclet.
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index-all.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index-all.html" index 312538529afc4176775b0d66664ec60a993d136a..33d4a840d48b1da56cbe0867a65d316d53e8587a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index-all.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index-all.html" @@ -1,3 +1,5802 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6cd410e94d7edd76dc706de04afe2a8b49aac898f5e0fbe202f5525f58105a82 -size 585930 + + + + + +Index (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
A B C D E F G H I L M N O P R S T U V W X  + + +

A

+
+
AbstractFileFilter - Class in org.apache.commons.io.filefilter
+
+
An abstract class which implements the Java FileFilter and FilenameFilter + interfaces via the IOFileFilter interface.
+
+
AbstractFileFilter() - Constructor for class org.apache.commons.io.filefilter.AbstractFileFilter
+
 
+
accept(File) - Method in class org.apache.commons.io.filefilter.AbstractFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.AbstractFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.AgeFileFilter
+
+
Checks to see if the last modification of the file matches cutoff + favorably.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.AndFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.AndFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.CanReadFileFilter
+
+
Checks to see if the file can be read.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.CanWriteFileFilter
+
+
Checks to see if the file can be written to.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.DelegateFileFilter
+
+
Checks the filter.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.DelegateFileFilter
+
+
Checks the filter.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.DirectoryFileFilter
+
+
Checks to see if the file is a directory.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.EmptyFileFilter
+
+
Checks to see if the file is empty.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.FalseFileFilter
+
+
Returns false.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.FalseFileFilter
+
+
Returns false.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.FileFileFilter
+
+
Checks to see if the file is a file.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.HiddenFileFilter
+
+
Checks to see if the file is hidden.
+
+
accept(File) - Method in interface org.apache.commons.io.filefilter.IOFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File, String) - Method in interface org.apache.commons.io.filefilter.IOFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.MagicNumberFileFilter
+
+
+ Accepts the provided file if the file contains the file filter's magic + number at the specified offset.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.NameFileFilter
+
+
Checks to see if the filename matches.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.NameFileFilter
+
+
Checks to see if the filename matches.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.NotFileFilter
+
+
Returns the logical NOT of the underlying filter's return value for the same File.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.NotFileFilter
+
+
Returns the logical NOT of the underlying filter's return value for the same arguments.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.OrFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.OrFileFilter
+
+
Checks to see if the File should be accepted by this filter.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Checks to see if the filename starts with the prefix.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Checks to see if the filename starts with the prefix.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.RegexFileFilter
+
+
Checks to see if the filename matches one of the regular expressions.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.SizeFileFilter
+
+
Checks to see if the size of the file is favorable.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Checks to see if the filename ends with the suffix.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Checks to see if the filename ends with the suffix.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.TrueFileFilter
+
+
Returns true.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.TrueFileFilter
+
+
Returns true.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Checks to see if the filename matches one of the wildcards.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Checks to see if the filename matches one of the wildcards.
+
+
accept(File, String) - Method in class org.apache.commons.io.filefilter.WildcardFilter
+
+
Deprecated.
+
Checks to see if the filename matches one of the wildcards.
+
+
accept(File) - Method in class org.apache.commons.io.filefilter.WildcardFilter
+
+
Deprecated.
+
Checks to see if the filename matches one of the wildcards.
+
+
accept(Class<?>...) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Accept the specified classes for deserialization, unless they + are otherwise rejected.
+
+
accept(String...) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Accept the wildcard specified classes for deserialization, + unless they are otherwise rejected.
+
+
accept(Pattern) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Accept class names that match the supplied pattern for + deserialization, unless they are otherwise rejected.
+
+
accept(ClassNameMatcher) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Accept class names where the supplied ClassNameMatcher matches for + deserialization, unless they are otherwise rejected.
+
+
addFileFilter(IOFileFilter) - Method in class org.apache.commons.io.filefilter.AndFileFilter
+
+
Adds the specified file filter to the list of file filters at the end of + the list.
+
+
addFileFilter(IOFileFilter) - Method in interface org.apache.commons.io.filefilter.ConditionalFileFilter
+
+
Adds the specified file filter to the list of file filters at the end of + the list.
+
+
addFileFilter(IOFileFilter) - Method in class org.apache.commons.io.filefilter.OrFileFilter
+
+
Adds the specified file filter to the list of file filters at the end of + the list.
+
+
addListener(FileAlterationListener) - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Add a file system listener.
+
+
addObserver(FileAlterationObserver) - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Add a file system observer to this monitor.
+
+
afterRead(int) - Method in class org.apache.commons.io.input.AutoCloseInputStream
+
+
Automatically closes the stream if the end of stream was reached.
+
+
afterRead(int) - Method in class org.apache.commons.io.input.CountingInputStream
+
+
Adds the number of read bytes to the count.
+
+
afterRead(int) - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invoked by the read methods after the proxied call has returned + successfully.
+
+
afterRead(int) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invoked by the read methods after the proxied call has returned + successfully.
+
+
afterWrite(int) - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Invoked by the write methods after the proxied call has returned + successfully.
+
+
afterWrite(int) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invoked by the write methods after the proxied call has returned + successfully.
+
+
AgeFileFilter - Class in org.apache.commons.io.filefilter
+
+
Filters files based on a cutoff time, can filter either newer + files or files equal to or older.
+
+
AgeFileFilter(long) - Constructor for class org.apache.commons.io.filefilter.AgeFileFilter
+
+
Constructs a new age file filter for files equal to or older than + a certain cutoff
+
+
AgeFileFilter(long, boolean) - Constructor for class org.apache.commons.io.filefilter.AgeFileFilter
+
+
Constructs a new age file filter for files on any one side + of a certain cutoff.
+
+
AgeFileFilter(Date) - Constructor for class org.apache.commons.io.filefilter.AgeFileFilter
+
+
Constructs a new age file filter for files older than (at or before) + a certain cutoff date.
+
+
AgeFileFilter(Date, boolean) - Constructor for class org.apache.commons.io.filefilter.AgeFileFilter
+
+
Constructs a new age file filter for files on any one side + of a certain cutoff date.
+
+
AgeFileFilter(File) - Constructor for class org.apache.commons.io.filefilter.AgeFileFilter
+
+
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).
+
+
AgeFileFilter(File, boolean) - Constructor for class org.apache.commons.io.filefilter.AgeFileFilter
+
+
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).
+
+
ageFileFilter(long) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the file was last modified after + the specified cutoff time.
+
+
ageFileFilter(long, boolean) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that filters files based on a cutoff time.
+
+
ageFileFilter(Date) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the file was last modified after + the specified cutoff date.
+
+
ageFileFilter(Date, boolean) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that filters files based on a cutoff date.
+
+
ageFileFilter(File) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the file was last modified after + the specified reference file.
+
+
ageFileFilter(File, boolean) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that filters files based on a cutoff reference file.
+
+
and(IOFileFilter...) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that ANDs the specified filters.
+
+
AndFileFilter - Class in org.apache.commons.io.filefilter
+
+
A FileFilter providing conditional AND logic across a list of + file filters.
+
+
AndFileFilter() - Constructor for class org.apache.commons.io.filefilter.AndFileFilter
+
+
Constructs a new instance of AndFileFilter.
+
+
AndFileFilter(List<IOFileFilter>) - Constructor for class org.apache.commons.io.filefilter.AndFileFilter
+
+
Constructs a new instance of AndFileFilter + with the specified list of filters.
+
+
AndFileFilter(IOFileFilter, IOFileFilter) - Constructor for class org.apache.commons.io.filefilter.AndFileFilter
+
+
Constructs a new file filter that ANDs the result of two other filters.
+
+
andFileFilter(IOFileFilter, IOFileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+ +
+
append(char) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
append(CharSequence, int, int) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
append(CharSequence) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
append(char) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's append(char) method.
+
+
append(CharSequence, int, int) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's append(CharSequence, int, int) method.
+
+
append(CharSequence) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's append(CharSequence) method.
+
+
append(char) - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Appends a single character to this Writer.
+
+
append(CharSequence) - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Appends a character sequence to this Writer.
+
+
append(CharSequence, int, int) - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Appends a portion of a character sequence to the StringBuilder.
+
+
AppendableOutputStream<T extends Appendable> - Class in org.apache.commons.io.output
+
+
OutputStream implementation that writes the data to an Appendable + Object.
+
+
AppendableOutputStream(T) - Constructor for class org.apache.commons.io.output.AppendableOutputStream
+
+
Construct a new instance with the specified appendable.
+
+
asFileFilter(FileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns an IOFileFilter that wraps the + FileFilter instance.
+
+
asFileFilter(FilenameFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns an IOFileFilter that wraps the + FilenameFilter instance.
+
+
AutoCloseInputStream - Class in org.apache.commons.io.input
+
+
Proxy stream that closes and discards the underlying stream as soon as the + end of input has been reached or when the stream is explicitly closed.
+
+
AutoCloseInputStream(InputStream) - Constructor for class org.apache.commons.io.input.AutoCloseInputStream
+
+
Creates an automatically closing proxy for the given input stream.
+
+
available() - Method in class org.apache.commons.io.input.BoundedInputStream
+
available() - Method in class org.apache.commons.io.input.BrokenInputStream
+
+
Throws the configured exception.
+
+
available() - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
+
Return an estimate of the number of bytes remaining in the byte stream.
+
+
available() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Return the number of bytes that can be read.
+
+
available() - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's available() method.
+
+
+ + + +

B

+
+
beforeRead(int) - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invoked by the read methods before the call is proxied.
+
+
beforeRead(int) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invoked by the read methods before the call is proxied.
+
+
beforeWrite(int) - Method in class org.apache.commons.io.output.CountingOutputStream
+
+
Updates the count with the number of bytes that are being written.
+
+
beforeWrite(int) - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Invoked by the write methods before the call is proxied.
+
+
beforeWrite(int) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invoked by the write methods before the call is proxied.
+
+
bindStream(InputStream) - Method in class org.apache.commons.io.input.DemuxInputStream
+
+
Bind the specified stream to the current thread.
+
+
bindStream(OutputStream) - Method in class org.apache.commons.io.output.DemuxOutputStream
+
+
Binds the specified stream to the current thread.
+
+
BOMInputStream - Class in org.apache.commons.io.input
+
+
This class is used to wrap a stream that includes an encoded ByteOrderMark as its first bytes.
+
+
BOMInputStream(InputStream) - Constructor for class org.apache.commons.io.input.BOMInputStream
+
+
Constructs a new BOM InputStream that excludes a ByteOrderMark.UTF_8 BOM.
+
+
BOMInputStream(InputStream, boolean) - Constructor for class org.apache.commons.io.input.BOMInputStream
+
+
Constructs a new BOM InputStream that detects a a ByteOrderMark.UTF_8 and optionally includes it.
+
+
BOMInputStream(InputStream, ByteOrderMark...) - Constructor for class org.apache.commons.io.input.BOMInputStream
+
+
Constructs a new BOM InputStream that excludes the specified BOMs.
+
+
BOMInputStream(InputStream, boolean, ByteOrderMark...) - Constructor for class org.apache.commons.io.input.BOMInputStream
+
+
Constructs a new BOM InputStream that detects the specified BOMs and optionally includes them.
+
+
BoundedInputStream - Class in org.apache.commons.io.input
+
+
This is a stream that will only supply bytes up to a certain length - if its + position goes above that, it will stop.
+
+
BoundedInputStream(InputStream, long) - Constructor for class org.apache.commons.io.input.BoundedInputStream
+
+
Creates a new BoundedInputStream that wraps the given input + stream and limits it to a certain size.
+
+
BoundedInputStream(InputStream) - Constructor for class org.apache.commons.io.input.BoundedInputStream
+
+
Creates a new BoundedInputStream that wraps the given input + stream and is unlimited.
+
+
BoundedReader - Class in org.apache.commons.io.input
+
+
A reader that imposes a limit to the number of characters that can be read from + an underlying reader, returning eof when this limit is reached -regardless of state of + underlying reader.
+
+
BoundedReader(Reader, int) - Constructor for class org.apache.commons.io.input.BoundedReader
+
+
Constructs a bounded reader
+
+
branch - Variable in class org.apache.commons.io.output.TeeOutputStream
+
+
the second OutputStream to write to
+
+
BrokenInputStream - Class in org.apache.commons.io.input
+
+
Broken input stream.
+
+
BrokenInputStream(IOException) - Constructor for class org.apache.commons.io.input.BrokenInputStream
+
+
Creates a new stream that always throws the given exception.
+
+
BrokenInputStream() - Constructor for class org.apache.commons.io.input.BrokenInputStream
+
+
Creates a new stream that always throws an IOException
+
+
BrokenOutputStream - Class in org.apache.commons.io.output
+
+
Broken output stream.
+
+
BrokenOutputStream(IOException) - Constructor for class org.apache.commons.io.output.BrokenOutputStream
+
+
Creates a new stream that always throws the given exception.
+
+
BrokenOutputStream() - Constructor for class org.apache.commons.io.output.BrokenOutputStream
+
+
Creates a new stream that always throws an IOException
+
+
buffer(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given reader if it is already a BufferedReader, otherwise creates a BufferedReader from + the given reader.
+
+
buffer(Reader, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given reader if it is already a BufferedReader, otherwise creates a BufferedReader from the + given reader.
+
+
buffer(Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given Writer if it is already a BufferedWriter, otherwise creates a BufferedWriter from the + given Writer.
+
+
buffer(Writer, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given Writer if it is already a BufferedWriter, otherwise creates a BufferedWriter from the + given Writer.
+
+
buffer(OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given OutputStream if it is already a BufferedOutputStream, otherwise creates a + BufferedOutputStream from the given OutputStream.
+
+
buffer(OutputStream, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given OutputStream if it is already a BufferedOutputStream, otherwise creates a + BufferedOutputStream from the given OutputStream.
+
+
buffer(InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given InputStream if it is already a BufferedInputStream, otherwise creates a + BufferedInputStream from the given InputStream.
+
+
buffer(InputStream, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given InputStream if it is already a BufferedInputStream, otherwise creates a + BufferedInputStream from the given InputStream.
+
+
ByteArrayOutputStream - Class in org.apache.commons.io.output
+
+
This class implements an output stream in which the data is + written into a byte array.
+
+
ByteArrayOutputStream() - Constructor for class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Creates a new byte array output stream.
+
+
ByteArrayOutputStream(int) - Constructor for class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Creates a new byte array output stream, with a buffer capacity of + the specified size, in bytes.
+
+
byteCountToDisplaySize(BigInteger) - Static method in class org.apache.commons.io.FileUtils
+
+
Returns a human-readable version of the file size, where the input represents a specific number of bytes.
+
+
byteCountToDisplaySize(long) - Static method in class org.apache.commons.io.FileUtils
+
+
Returns a human-readable version of the file size, where the input represents a specific number of bytes.
+
+
ByteOrderMark - Class in org.apache.commons.io
+
+
Byte Order Mark (BOM) representation - see BOMInputStream.
+
+
ByteOrderMark(String, int...) - Constructor for class org.apache.commons.io.ByteOrderMark
+
+
Construct a new BOM.
+
+
+ + + +

C

+
+
CAN_READ - Static variable in class org.apache.commons.io.filefilter.CanReadFileFilter
+
+
Singleton instance of readable filter
+
+
CAN_WRITE - Static variable in class org.apache.commons.io.filefilter.CanWriteFileFilter
+
+
Singleton instance of writable filter
+
+
CANNOT_READ - Static variable in class org.apache.commons.io.filefilter.CanReadFileFilter
+
+
Singleton instance of not readable filter
+
+
CANNOT_WRITE - Static variable in class org.apache.commons.io.filefilter.CanWriteFileFilter
+
+
Singleton instance of not writable filter
+
+
CanReadFileFilter - Class in org.apache.commons.io.filefilter
+
+
This filter accepts Files that can be read.
+
+
CanReadFileFilter() - Constructor for class org.apache.commons.io.filefilter.CanReadFileFilter
+
+
Restrictive consructor.
+
+
CanWriteFileFilter - Class in org.apache.commons.io.filefilter
+
+
This filter accepts Files that can be written to.
+
+
CanWriteFileFilter() - Constructor for class org.apache.commons.io.filefilter.CanWriteFileFilter
+
+
Restrictive consructor.
+
+
CharSequenceInputStream - Class in org.apache.commons.io.input
+
+
InputStream implementation that can read from String, StringBuffer, + StringBuilder or CharBuffer.
+
+
CharSequenceInputStream(CharSequence, Charset, int) - Constructor for class org.apache.commons.io.input.CharSequenceInputStream
+
+
Constructor.
+
+
CharSequenceInputStream(CharSequence, String, int) - Constructor for class org.apache.commons.io.input.CharSequenceInputStream
+
+ +
+
CharSequenceInputStream(CharSequence, Charset) - Constructor for class org.apache.commons.io.input.CharSequenceInputStream
+
+ +
+
CharSequenceInputStream(CharSequence, String) - Constructor for class org.apache.commons.io.input.CharSequenceInputStream
+
+ +
+
CharSequenceReader - Class in org.apache.commons.io.input
+
+
Reader implementation that can read from String, StringBuffer, + StringBuilder or CharBuffer.
+
+
CharSequenceReader(CharSequence) - Constructor for class org.apache.commons.io.input.CharSequenceReader
+
+
Construct a new instance with the specified character sequence.
+
+
Charsets - Class in org.apache.commons.io
+
+
Charsets required of every implementation of the Java platform.
+
+
Charsets() - Constructor for class org.apache.commons.io.Charsets
+
 
+
checkAndNotify() - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Check whether the file and its chlidren have been created, modified or deleted.
+
+
checkCompareTo(String, String) - Method in enum org.apache.commons.io.IOCase
+
+
Compares two strings using the case-sensitivity rule.
+
+
checkEndsWith(String, String) - Method in enum org.apache.commons.io.IOCase
+
+
Checks if one string ends with another using the case-sensitivity rule.
+
+
checkEquals(String, String) - Method in enum org.apache.commons.io.IOCase
+
+
Compares two strings using the case-sensitivity rule.
+
+
checkIfCancelled(File, int, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Checks whether the walk has been cancelled by calling DirectoryWalker.handleIsCancelled(java.io.File, int, java.util.Collection<T>), + throwing a CancelException if it has.
+
+
checkIndexOf(String, int, String) - Method in enum org.apache.commons.io.IOCase
+
+
Checks if one string contains another starting at a specific index using the + case-sensitivity rule.
+
+
checkRegionMatches(String, int, String) - Method in enum org.apache.commons.io.IOCase
+
+
Checks if one string contains another at a specific index using the case-sensitivity rule.
+
+
checkStartsWith(String, String) - Method in enum org.apache.commons.io.IOCase
+
+
Checks if one string starts with another using the case-sensitivity rule.
+
+
checksum(File, Checksum) - Static method in class org.apache.commons.io.FileUtils
+
+
Computes the checksum of a file using the specified checksum object.
+
+
checksumCRC32(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Computes the checksum of a file using the CRC32 checksum routine.
+
+
checkThreshold(int) - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Checks to see if writing the specified number of bytes would cause the + configured threshold to be exceeded.
+
+
ChunkedOutputStream - Class in org.apache.commons.io.output
+
+
OutputStream which breaks larger output blocks into chunks.
+
+
ChunkedOutputStream(OutputStream, int) - Constructor for class org.apache.commons.io.output.ChunkedOutputStream
+
+
Creates a new stream that uses the specified chunk size.
+
+
ChunkedOutputStream(OutputStream) - Constructor for class org.apache.commons.io.output.ChunkedOutputStream
+
+
Creates a new stream that uses a chunk size of DEFAULT_CHUNK_SIZE.
+
+
ChunkedWriter - Class in org.apache.commons.io.output
+
+
Writer which breaks larger output blocks into chunks.
+
+
ChunkedWriter(Writer, int) - Constructor for class org.apache.commons.io.output.ChunkedWriter
+
+
Creates a new writer that uses the specified chunk size.
+
+
ChunkedWriter(Writer) - Constructor for class org.apache.commons.io.output.ChunkedWriter
+
+
Creates a new writer that uses a chunk size of ChunkedWriter.DEFAULT_CHUNK_SIZE
+
+
ClassLoaderObjectInputStream - Class in org.apache.commons.io.input
+
+
A special ObjectInputStream that loads a class based on a specified + ClassLoader rather than the system default.
+
+
ClassLoaderObjectInputStream(ClassLoader, InputStream) - Constructor for class org.apache.commons.io.input.ClassLoaderObjectInputStream
+
+
Constructs a new ClassLoaderObjectInputStream.
+
+
ClassNameMatcher - Interface in org.apache.commons.io.serialization
+
+
An object that matches a Class name to a condition.
+
+
cleanDirectory(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Cleans a directory without deleting it.
+
+
close() - Method in class org.apache.commons.io.input.AutoCloseInputStream
+
+
Closes the underlying input stream and replaces the reference to it + with a ClosedInputStream instance.
+
+
close() - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's close() method + if BoundedInputStream.isPropagateClose() is true.
+
+
close() - Method in class org.apache.commons.io.input.BoundedReader
+
+
Closes the target
+
+
close() - Method in class org.apache.commons.io.input.BrokenInputStream
+
+
Throws the configured exception.
+
+
close() - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
 
+
close() - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Close resets the file back to the start and removes any marked position.
+
+
close() - Method in class org.apache.commons.io.input.CloseShieldInputStream
+
+
Replaces the underlying input stream with a ClosedInputStream + sentinel.
+
+
close() - Method in class org.apache.commons.io.input.DemuxInputStream
+
+
Closes stream associated with current thread.
+
+
close() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Close this input stream - resets the internal state to + the initial values.
+
+
close() - Method in class org.apache.commons.io.input.NullReader
+
+
Close this Reader - resets the internal state to + the initial values.
+
+
close() - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's close() method.
+
+
close() - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's close() method.
+
+
close() - Method in class org.apache.commons.io.input.ReaderInputStream
+
+
Close the stream.
+
+
close() - Method in class org.apache.commons.io.input.ReversedLinesFileReader
+
+
Closes underlying resources.
+
+
close() - Method in class org.apache.commons.io.input.TeeInputStream
+
+
Closes the proxied input stream and, if so configured, the associated + output stream.
+
+
close() - Method in class org.apache.commons.io.input.UnixLineEndingInputStream
+
+
Closes the stream.
+
+
close() - Method in class org.apache.commons.io.input.WindowsLineEndingInputStream
+
+
Closes the stream.
+
+
close() - Method in class org.apache.commons.io.input.XmlStreamReader
+
+
Closes the XmlStreamReader stream.
+
+
close(URLConnection) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes a URLConnection.
+
+
close() - Method in class org.apache.commons.io.LineIterator
+
+
Closes the underlying Reader quietly.
+
+
close() - Method in class org.apache.commons.io.output.BrokenOutputStream
+
+
Throws the configured exception.
+
+
close() - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Closing a ByteArrayOutputStream has no effect.
+
+
close() - Method in class org.apache.commons.io.output.CloseShieldOutputStream
+
+
Replaces the underlying output stream with a ClosedOutputStream + sentinel.
+
+
close() - Method in class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Closes underlying output stream, and mark this as closed
+
+
close() - Method in class org.apache.commons.io.output.DemuxOutputStream
+
+
Closes stream associated with current thread.
+
+
close() - Method in class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Close the stream.
+
+
close() - Method in class org.apache.commons.io.output.LockableFileWriter
+
+
Closes the file writer and deletes the lockfile (if possible).
+
+
close() - Method in class org.apache.commons.io.output.NullWriter
+
 
+
close() - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Invokes the delegate's close() method.
+
+
close() - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's close() method.
+
+
close() - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Closing this writer has no effect.
+
+
close() - Method in class org.apache.commons.io.output.TeeOutputStream
+
+
Closes both output streams.
+
+
close() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Closes this output stream and releases any system resources associated + with this stream.
+
+
close() - Method in class org.apache.commons.io.output.WriterOutputStream
+
+
Close the stream.
+
+
close() - Method in class org.apache.commons.io.output.XmlStreamWriter
+
+
Close the underlying writer.
+
+
CLOSED_INPUT_STREAM - Static variable in class org.apache.commons.io.input.ClosedInputStream
+
+
A singleton.
+
+
CLOSED_OUTPUT_STREAM - Static variable in class org.apache.commons.io.output.ClosedOutputStream
+
+
A singleton.
+
+
ClosedInputStream - Class in org.apache.commons.io.input
+
+
Closed input stream.
+
+
ClosedInputStream() - Constructor for class org.apache.commons.io.input.ClosedInputStream
+
 
+
ClosedOutputStream - Class in org.apache.commons.io.output
+
+
Closed output stream.
+
+
ClosedOutputStream() - Constructor for class org.apache.commons.io.output.ClosedOutputStream
+
 
+
closeQuietly(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes an Reader unconditionally.
+
+
closeQuietly(Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes an Writer unconditionally.
+
+
closeQuietly(InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes an InputStream unconditionally.
+
+
closeQuietly(OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes an OutputStream unconditionally.
+
+
closeQuietly(Closeable) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes a Closeable unconditionally.
+
+
closeQuietly(Closeable...) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes a Closeable unconditionally.
+
+
closeQuietly(Socket) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes a Socket unconditionally.
+
+
closeQuietly(Selector) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes a Selector unconditionally.
+
+
closeQuietly(ServerSocket) - Static method in class org.apache.commons.io.IOUtils
+
+
Closes a ServerSocket unconditionally.
+
+
closeQuietly(LineIterator) - Static method in class org.apache.commons.io.LineIterator
+
+
Closes the iterator, handling null and ignoring exceptions.
+
+
CloseShieldInputStream - Class in org.apache.commons.io.input
+
+
Proxy stream that prevents the underlying input stream from being closed.
+
+
CloseShieldInputStream(InputStream) - Constructor for class org.apache.commons.io.input.CloseShieldInputStream
+
+
Creates a proxy that shields the given input stream from being + closed.
+
+
CloseShieldOutputStream - Class in org.apache.commons.io.output
+
+
Proxy stream that prevents the underlying output stream from being closed.
+
+
CloseShieldOutputStream(OutputStream) - Constructor for class org.apache.commons.io.output.CloseShieldOutputStream
+
+
Creates a proxy that shields the given output stream from being + closed.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.CompositeFileComparator
+
+
Compare the two files using delegate comparators.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.DefaultFileComparator
+
+
Compare the two files using the File.compareTo(File) method.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.DirectoryFileComparator
+
+
Compare the two files using the File.isDirectory() method.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Compare the extensions of two files the specified case sensitivity.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.LastModifiedFileComparator
+
+
Compare the last the last modified date/time of two files.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.NameFileComparator
+
+
Compare the names of two files with the specified case sensitivity.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.PathFileComparator
+
+
Compare the paths of two files the specified case sensitivity.
+
+
compare(File, File) - Method in class org.apache.commons.io.comparator.SizeFileComparator
+
+
Compare the length of two files.
+
+
CompositeFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare two files using a set of delegate file Comparator.
+
+
CompositeFileComparator(Comparator<File>...) - Constructor for class org.apache.commons.io.comparator.CompositeFileComparator
+
+
Create a composite comparator for the set of delegate comparators.
+
+
CompositeFileComparator(Iterable<Comparator<File>>) - Constructor for class org.apache.commons.io.comparator.CompositeFileComparator
+
+
Create a composite comparator for the set of delegate comparators.
+
+
concat(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Concatenates a filename to a base path using normal command line style rules.
+
+
ConditionalFileFilter - Interface in org.apache.commons.io.filefilter
+
+
Defines operations for conditional file filters.
+
+
contentEquals(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Compares the contents of two files to determine if they are equal or not.
+
+
contentEquals(InputStream, InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Compares the contents of two Streams to determine if they are equal or + not.
+
+
contentEquals(Reader, Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Compares the contents of two Readers to determine if they are equal or + not.
+
+
contentEqualsIgnoreEOL(File, File, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Compares the contents of two files to determine if they are equal or not.
+
+
contentEqualsIgnoreEOL(Reader, Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Compares the contents of two Readers to determine if they are equal or + not, ignoring EOL characters.
+
+
convertFileCollectionToFileArray(Collection<File>) - Static method in class org.apache.commons.io.FileUtils
+
+
Converts a Collection containing java.io.File instanced into array + representation.
+
+
copy(byte[], OutputStream) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Copy bytes from a byte[] to an OutputStream.
+
+
copy(byte[], Writer) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated. + +
+
+
copy(byte[], Writer, String) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Copy and convert bytes from a byte[] to chars on a + Writer, using the specified encoding.
+
+
copy(InputStream, OutputStream) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Copy bytes from an InputStream to an + OutputStream.
+
+
copy(Reader, Writer) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Copy chars from a Reader to a Writer.
+
+
copy(InputStream, Writer) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated. + +
+
+
copy(InputStream, Writer, String) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Copy and convert bytes from an InputStream to chars on a + Writer, using the specified encoding.
+
+
copy(Reader, OutputStream) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated. + +
+
+
copy(Reader, OutputStream, String) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Serialize chars from a Reader to bytes on an + OutputStream, and flush the OutputStream.
+
+
copy(String, OutputStream) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated. + +
+
+
copy(String, OutputStream, String) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Serialize chars from a String to bytes on an + OutputStream, and + flush the OutputStream.
+
+
copy(String, Writer) - Static method in class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Copy chars from a String to a Writer.
+
+
copy(InputStream, OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies bytes from an InputStream to an + OutputStream.
+
+
copy(InputStream, OutputStream, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies bytes from an InputStream to an OutputStream using an internal buffer of the + given size.
+
+
copy(InputStream, Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
copy(InputStream, Writer, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies bytes from an InputStream to chars on a + Writer using the specified character encoding.
+
+
copy(InputStream, Writer, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies bytes from an InputStream to chars on a + Writer using the specified character encoding.
+
+
copy(Reader, Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies chars from a Reader to a Writer.
+
+
copy(Reader, OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
copy(Reader, OutputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies chars from a Reader to bytes on an + OutputStream using the specified character encoding, and + calling flush.
+
+
copy(Reader, OutputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies chars from a Reader to bytes on an + OutputStream using the specified character encoding, and + calling flush.
+
+
copyDirectory(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a whole directory to a new location preserving the file dates.
+
+
copyDirectory(File, File, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a whole directory to a new location.
+
+
copyDirectory(File, File, FileFilter) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a filtered directory to a new location preserving the file dates.
+
+
copyDirectory(File, File, FileFilter, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a filtered directory to a new location.
+
+
copyDirectoryToDirectory(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a directory to within another directory preserving the file dates.
+
+
copyFile(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a file to a new location preserving the file date.
+
+
copyFile(File, File, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a file to a new location.
+
+
copyFile(File, OutputStream) - Static method in class org.apache.commons.io.FileUtils
+
+
Copy bytes from a File to an OutputStream.
+
+
copyFileToDirectory(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a file to a directory preserving the file date.
+
+
copyFileToDirectory(File, File, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies a file to a directory optionally preserving the file date.
+
+
copyInputStreamToFile(InputStream, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies bytes from an InputStream source to a file + destination.
+
+
copyLarge(InputStream, OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies bytes from a large (over 2GB) InputStream to an + OutputStream.
+
+
copyLarge(InputStream, OutputStream, byte[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies bytes from a large (over 2GB) InputStream to an + OutputStream.
+
+
copyLarge(InputStream, OutputStream, long, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies some or all bytes from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input bytes.
+
+
copyLarge(InputStream, OutputStream, long, long, byte[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies some or all bytes from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input bytes.
+
+
copyLarge(Reader, Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies chars from a large (over 2GB) Reader to a Writer.
+
+
copyLarge(Reader, Writer, char[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies chars from a large (over 2GB) Reader to a Writer.
+
+
copyLarge(Reader, Writer, long, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies some or all chars from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input chars.
+
+
copyLarge(Reader, Writer, long, long, char[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Copies some or all chars from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input chars.
+
+
copyToFile(InputStream, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies bytes from an InputStream source to a file + destination.
+
+
copyURLToFile(URL, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies bytes from the URL source to a file + destination.
+
+
copyURLToFile(URL, File, int, int) - Static method in class org.apache.commons.io.FileUtils
+
+
Copies bytes from the URL source to a file + destination.
+
+
CopyUtils - Class in org.apache.commons.io
+
+
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).
+
+
+
CopyUtils() - Constructor for class org.apache.commons.io.CopyUtils
+
+
Deprecated.
+
Instances should NOT be constructed in standard programming.
+
+
CountingInputStream - Class in org.apache.commons.io.input
+
+
A decorating input stream that counts the number of bytes that have passed + through the stream so far.
+
+
CountingInputStream(InputStream) - Constructor for class org.apache.commons.io.input.CountingInputStream
+
+
Constructs a new CountingInputStream.
+
+
CountingOutputStream - Class in org.apache.commons.io.output
+
+
A decorating output stream that counts the number of bytes that have passed + through the stream so far.
+
+
CountingOutputStream(OutputStream) - Constructor for class org.apache.commons.io.output.CountingOutputStream
+
+
Constructs a new CountingOutputStream.
+
+
create(File, TailerListener, long, boolean, int) - Static method in class org.apache.commons.io.input.Tailer
+
+
Creates and starts a Tailer for the given file.
+
+
create(File, TailerListener, long, boolean, boolean, int) - Static method in class org.apache.commons.io.input.Tailer
+
+
Creates and starts a Tailer for the given file.
+
+
create(File, Charset, TailerListener, long, boolean, boolean, int) - Static method in class org.apache.commons.io.input.Tailer
+
+
Creates and starts a Tailer for the given file.
+
+
create(File, TailerListener, long, boolean) - Static method in class org.apache.commons.io.input.Tailer
+
+
Creates and starts a Tailer for the given file with default buffer size.
+
+
create(File, TailerListener, long, boolean, boolean) - Static method in class org.apache.commons.io.input.Tailer
+
+
Creates and starts a Tailer for the given file with default buffer size.
+
+
create(File, TailerListener, long) - Static method in class org.apache.commons.io.input.Tailer
+
+
Creates and starts a Tailer for the given file, starting at the beginning of the file
+
+
create(File, TailerListener) - Static method in class org.apache.commons.io.input.Tailer
+
+
Creates and starts a Tailer for the given file, starting at the beginning of the file + with the default delay of 1.0s
+
+
+ + + +

D

+
+
DEFAULT_COMPARATOR - Static variable in class org.apache.commons.io.comparator.DefaultFileComparator
+
+
Singleton default comparator instance
+
+
DEFAULT_REVERSE - Static variable in class org.apache.commons.io.comparator.DefaultFileComparator
+
+
Singleton reverse default comparator instance
+
+
DefaultFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare two files using the default File.compareTo(File) method.
+
+
DefaultFileComparator() - Constructor for class org.apache.commons.io.comparator.DefaultFileComparator
+
 
+
DeferredFileOutputStream - Class in org.apache.commons.io.output
+
+
An output stream which will retain data in memory until a specified + threshold is reached, and only then commit it to disk.
+
+
DeferredFileOutputStream(int, File) - Constructor for class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Constructs an instance of this class which will trigger an event at the + specified threshold, and save data to a file beyond that point.
+
+
DeferredFileOutputStream(int, String, String, File) - Constructor for class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Constructs an instance of this class which will trigger an event at the + specified threshold, and save data to a temporary file beyond that point.
+
+
DelegateFileFilter - Class in org.apache.commons.io.filefilter
+
+
This class turns a Java FileFilter or FilenameFilter into an IO FileFilter.
+
+
DelegateFileFilter(FilenameFilter) - Constructor for class org.apache.commons.io.filefilter.DelegateFileFilter
+
+
Constructs a delegate file filter around an existing FilenameFilter.
+
+
DelegateFileFilter(FileFilter) - Constructor for class org.apache.commons.io.filefilter.DelegateFileFilter
+
+
Constructs a delegate file filter around an existing FileFilter.
+
+
delete(File) - Method in class org.apache.commons.io.FileDeleteStrategy
+
+
Deletes the file object, which may be a file or a directory.
+
+
deleteDirectory(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Deletes a directory recursively.
+
+
deleteQuietly(File) - Method in class org.apache.commons.io.FileDeleteStrategy
+
+
Deletes the file object, which may be a file or a directory.
+
+
deleteQuietly(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Deletes a file, never throwing an exception.
+
+
DemuxInputStream - Class in org.apache.commons.io.input
+
+
Data written to this stream is forwarded to a stream that has been associated + with this thread.
+
+
DemuxInputStream() - Constructor for class org.apache.commons.io.input.DemuxInputStream
+
 
+
DemuxOutputStream - Class in org.apache.commons.io.output
+
+
Forwards data to a stream that has been associated with this thread.
+
+
DemuxOutputStream() - Constructor for class org.apache.commons.io.output.DemuxOutputStream
+
 
+
destroy() - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Final processing.
+
+
DIR_SEPARATOR - Static variable in class org.apache.commons.io.IOUtils
+
+
The system directory separator character.
+
+
DIR_SEPARATOR_UNIX - Static variable in class org.apache.commons.io.IOUtils
+
+
The Unix directory separator character.
+
+
DIR_SEPARATOR_WINDOWS - Static variable in class org.apache.commons.io.IOUtils
+
+
The Windows directory separator character.
+
+
DIRECTORY - Static variable in class org.apache.commons.io.filefilter.DirectoryFileFilter
+
+
Singleton instance of directory filter.
+
+
DIRECTORY_COMPARATOR - Static variable in class org.apache.commons.io.comparator.DirectoryFileComparator
+
+
Singleton default comparator instance
+
+
DIRECTORY_REVERSE - Static variable in class org.apache.commons.io.comparator.DirectoryFileComparator
+
+
Singleton reverse default comparator instance
+
+
directoryContains(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Determines whether the parent directory contains the child element (a file or directory).
+
+
directoryContains(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Determines whether the parent directory contains the child element (a file or directory).
+
+
DirectoryFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare two files using the File.isDirectory() method.
+
+
DirectoryFileComparator() - Constructor for class org.apache.commons.io.comparator.DirectoryFileComparator
+
 
+
DirectoryFileFilter - Class in org.apache.commons.io.filefilter
+
+
This filter accepts Files that are directories.
+
+
DirectoryFileFilter() - Constructor for class org.apache.commons.io.filefilter.DirectoryFileFilter
+
+
Restrictive consructor.
+
+
directoryFileFilter() - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that checks if the file is a directory.
+
+
DirectoryWalker<T> - Class in org.apache.commons.io
+
+
Abstract class that walks through a directory hierarchy and provides + subclasses with convenient hooks to add specific behaviour.
+
+
DirectoryWalker() - Constructor for class org.apache.commons.io.DirectoryWalker
+
+
Construct an instance with no filtering and unlimited depth.
+
+
DirectoryWalker(FileFilter, int) - Constructor for class org.apache.commons.io.DirectoryWalker
+
+
Construct an instance with a filter and limit the depth navigated to.
+
+
DirectoryWalker(IOFileFilter, IOFileFilter, int) - Constructor for class org.apache.commons.io.DirectoryWalker
+
+
Construct an instance with a directory and a file filter and an optional + limit on the depth navigated to.
+
+
DirectoryWalker.CancelException - Exception in org.apache.commons.io
+
+
CancelException is thrown in DirectoryWalker to cancel the current + processing.
+
+
DirectoryWalker.CancelException(File, int) - Constructor for exception org.apache.commons.io.DirectoryWalker.CancelException
+
+
Constructs a CancelException with + the file and depth when cancellation occurred.
+
+
DirectoryWalker.CancelException(String, File, int) - Constructor for exception org.apache.commons.io.DirectoryWalker.CancelException
+
+
Constructs a CancelException with + an appropriate message and the file and depth when + cancellation occurred.
+
+
doDelete(File) - Method in class org.apache.commons.io.FileDeleteStrategy
+
+
Actually deletes the file object, which may be a file or a directory.
+
+
dump(byte[], long, OutputStream, int) - Static method in class org.apache.commons.io.HexDump
+
+
Dump an array of bytes to an OutputStream.
+
+
+ + + +

E

+
+
EMPTY - Static variable in class org.apache.commons.io.filefilter.EmptyFileFilter
+
+
Singleton instance of empty filter
+
+
EMPTY_FILE_ARRAY - Static variable in class org.apache.commons.io.FileUtils
+
+
An empty array of type File.
+
+
EmptyFileFilter - Class in org.apache.commons.io.filefilter
+
+
This filter accepts files or directories that are empty.
+
+
EmptyFileFilter() - Constructor for class org.apache.commons.io.filefilter.EmptyFileFilter
+
+
Restrictive consructor.
+
+
ENCODING_PATTERN - Static variable in class org.apache.commons.io.input.XmlStreamReader
+
 
+
EndianUtils - Class in org.apache.commons.io
+
+
Utility code for dealing with different endian systems.
+
+
EndianUtils() - Constructor for class org.apache.commons.io.EndianUtils
+
+
Instances should NOT be constructed in standard programming.
+
+
endOfFileReached() - Method in class org.apache.commons.io.input.TailerListenerAdapter
+
+
Called each time the Tailer reaches the end of the file.
+
+
EOF - Static variable in class org.apache.commons.io.IOUtils
+
+
Represents the end-of-file (or stream).
+
+
EOL - Static variable in class org.apache.commons.io.HexDump
+
+
The line-separator (initializes to "line.separator" system property.
+
+
equals(Object) - Method in class org.apache.commons.io.ByteOrderMark
+
+
Indicates if this BOM's bytes equals another.
+
+
equals(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether two filenames are equal exactly.
+
+
equals(String, String, boolean, IOCase) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether two filenames are equal, optionally normalizing and providing + control over the case-sensitivity.
+
+
equalsNormalized(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether two filenames are equal after both have been normalized.
+
+
equalsNormalizedOnSystem(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether two filenames are equal after both have been normalized + and using the case rules of the system.
+
+
equalsOnSystem(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether two filenames are equal using the case rules of the system.
+
+
exitWhenFinished() - Static method in class org.apache.commons.io.FileCleaner
+
+ +
+
exitWhenFinished() - Method in class org.apache.commons.io.FileCleaningTracker
+
+
Call this method to cause the file cleaner thread to terminate when + there are no more objects being tracked for deletion.
+
+
EXTENSION_COMPARATOR - Static variable in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Case-sensitive extension comparator instance (see IOCase.SENSITIVE)
+
+
EXTENSION_INSENSITIVE_COMPARATOR - Static variable in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Case-insensitive extension comparator instance (see IOCase.INSENSITIVE)
+
+
EXTENSION_INSENSITIVE_REVERSE - Static variable in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Reverse case-insensitive extension comparator instance (see IOCase.INSENSITIVE)
+
+
EXTENSION_REVERSE - Static variable in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Reverse case-sensitive extension comparator instance (see IOCase.SENSITIVE)
+
+
EXTENSION_SEPARATOR - Static variable in class org.apache.commons.io.FilenameUtils
+
+
The extension separator character.
+
+
EXTENSION_SEPARATOR_STR - Static variable in class org.apache.commons.io.FilenameUtils
+
+
The extension separator String.
+
+
EXTENSION_SYSTEM_COMPARATOR - Static variable in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
System sensitive extension comparator instance (see IOCase.SYSTEM)
+
+
EXTENSION_SYSTEM_REVERSE - Static variable in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Reverse system sensitive path comparator instance (see IOCase.SYSTEM)
+
+
ExtensionFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare the file name extensions for order + (see FilenameUtils.getExtension(String)).
+
+
ExtensionFileComparator() - Constructor for class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Construct a case sensitive file extension comparator instance.
+
+
ExtensionFileComparator(IOCase) - Constructor for class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
Construct a file extension comparator instance with the specified case-sensitivity.
+
+
+ + + +

F

+
+
FALSE - Static variable in class org.apache.commons.io.filefilter.FalseFileFilter
+
+
Singleton instance of false filter.
+
+
FalseFileFilter - Class in org.apache.commons.io.filefilter
+
+
A file filter that always returns false.
+
+
FalseFileFilter() - Constructor for class org.apache.commons.io.filefilter.FalseFileFilter
+
+
Restrictive consructor.
+
+
falseFileFilter() - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that always returns false.
+
+
FILE - Static variable in class org.apache.commons.io.filefilter.FileFileFilter
+
+
Singleton instance of file filter
+
+
FileAlterationListener - Interface in org.apache.commons.io.monitor
+
+
A listener that receives events of file system modifications.
+
+
FileAlterationListenerAdaptor - Class in org.apache.commons.io.monitor
+
+
Convenience FileAlterationListener implementation that does nothing.
+
+
FileAlterationListenerAdaptor() - Constructor for class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
 
+
FileAlterationMonitor - Class in org.apache.commons.io.monitor
+
+
A runnable that spawns a monitoring thread triggering any + registered FileAlterationObserver at a specified interval.
+
+
FileAlterationMonitor() - Constructor for class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Construct a monitor with a default interval of 10 seconds.
+
+
FileAlterationMonitor(long) - Constructor for class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Construct a monitor with the specified interval.
+
+
FileAlterationMonitor(long, FileAlterationObserver...) - Constructor for class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Construct a monitor with the specified interval and set of observers.
+
+
FileAlterationObserver - Class in org.apache.commons.io.monitor
+
+
FileAlterationObserver represents the state of files below a root directory, + checking the filesystem and notifying listeners of create, change or + delete events.
+
+
FileAlterationObserver(String) - Constructor for class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Construct an observer for the specified directory.
+
+
FileAlterationObserver(String, FileFilter) - Constructor for class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Construct an observer for the specified directory and file filter.
+
+
FileAlterationObserver(String, FileFilter, IOCase) - Constructor for class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Construct an observer for the specified directory, file filter and + file comparator.
+
+
FileAlterationObserver(File) - Constructor for class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Construct an observer for the specified directory.
+
+
FileAlterationObserver(File, FileFilter) - Constructor for class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Construct an observer for the specified directory and file filter.
+
+
FileAlterationObserver(File, FileFilter, IOCase) - Constructor for class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Construct an observer for the specified directory, file filter and + file comparator.
+
+
FileAlterationObserver(FileEntry, FileFilter, IOCase) - Constructor for class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Construct an observer for the specified directory, file filter and + file comparator.
+
+
FileCleaner - Class in org.apache.commons.io
+
+
Deprecated. + +
+
+
FileCleaner() - Constructor for class org.apache.commons.io.FileCleaner
+
+
Deprecated.
+ 
+
FileCleaningTracker - Class in org.apache.commons.io
+
+
Keeps track of files awaiting deletion, and deletes them when an associated + marker object is reclaimed by the garbage collector.
+
+
FileCleaningTracker() - Constructor for class org.apache.commons.io.FileCleaningTracker
+
 
+
FileDeleteStrategy - Class in org.apache.commons.io
+
+
Strategy for deleting files.
+
+
FileDeleteStrategy(String) - Constructor for class org.apache.commons.io.FileDeleteStrategy
+
+
Restricted constructor.
+
+
FileEntry - Class in org.apache.commons.io.monitor
+
+
The state of a file or directory, capturing the following File attributes at a point in time.
+
+
FileEntry(File) - Constructor for class org.apache.commons.io.monitor.FileEntry
+
+
Construct a new monitor for a specified File.
+
+
FileEntry(FileEntry, File) - Constructor for class org.apache.commons.io.monitor.FileEntry
+
+
Construct a new monitor for a specified File.
+
+
FileExistsException - Exception in org.apache.commons.io
+
+
Indicates that a file already exists.
+
+
FileExistsException() - Constructor for exception org.apache.commons.io.FileExistsException
+
+
Default Constructor.
+
+
FileExistsException(String) - Constructor for exception org.apache.commons.io.FileExistsException
+
+
Construct an instance with the specified message.
+
+
FileExistsException(File) - Constructor for exception org.apache.commons.io.FileExistsException
+
+
Construct an instance with the specified file.
+
+
FileFileFilter - Class in org.apache.commons.io.filefilter
+
+
This filter accepts Files that are files (not directories).
+
+
FileFileFilter() - Constructor for class org.apache.commons.io.filefilter.FileFileFilter
+
+
Restrictive consructor.
+
+
fileFileFilter() - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that checks if the file is a file (and not a directory).
+
+
FileFilterUtils - Class in org.apache.commons.io.filefilter
+
+
Useful utilities for working with file filters.
+
+
FileFilterUtils() - Constructor for class org.apache.commons.io.filefilter.FileFilterUtils
+
+
FileFilterUtils is not normally instantiated.
+
+
FilenameUtils - Class in org.apache.commons.io
+
+
General filename and filepath manipulation utilities.
+
+
FilenameUtils() - Constructor for class org.apache.commons.io.FilenameUtils
+
+
Instances should NOT be constructed in standard programming.
+
+
fileNotFound() - Method in interface org.apache.commons.io.input.TailerListener
+
+
This method is called if the tailed file is not found.
+
+
fileNotFound() - Method in class org.apache.commons.io.input.TailerListenerAdapter
+
+
This method is called if the tailed file is not found.
+
+
fileRotated() - Method in interface org.apache.commons.io.input.TailerListener
+
+
Called if a file rotation is detected.
+
+
fileRotated() - Method in class org.apache.commons.io.input.TailerListenerAdapter
+
+
Called if a file rotation is detected.
+
+
FileSystemUtils - Class in org.apache.commons.io
+
+
General File System utilities.
+
+
FileSystemUtils() - Constructor for class org.apache.commons.io.FileSystemUtils
+
+
Instances should NOT be constructed in standard programming.
+
+
FileUtils - Class in org.apache.commons.io
+
+
General file manipulation utilities.
+
+
FileUtils() - Constructor for class org.apache.commons.io.FileUtils
+
+
Instances should NOT be constructed in standard programming.
+
+
FileWriterWithEncoding - Class in org.apache.commons.io.output
+
+
Writer of files that allows the encoding to be set.
+
+
FileWriterWithEncoding(String, String) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(String, String, boolean) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(String, Charset) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(String, Charset, boolean) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(String, CharsetEncoder) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(String, CharsetEncoder, boolean) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(File, String) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(File, String, boolean) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(File, Charset) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(File, Charset, boolean) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(File, CharsetEncoder) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
FileWriterWithEncoding(File, CharsetEncoder, boolean) - Constructor for class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Constructs a FileWriterWithEncoding with a file encoding.
+
+
filter(IOFileFilter, File...) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
+ Applies an IOFileFilter to the provided File + objects.
+
+
filter(IOFileFilter, Iterable<File>) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
+ Applies an IOFileFilter to the provided File + objects.
+
+
filterDirectoryContents(File, int, File[]) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked with the contents of each directory.
+
+
filterList(IOFileFilter, Iterable<File>) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
+ Applies an IOFileFilter to the provided File + objects.
+
+
filterList(IOFileFilter, File...) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
+ Applies an IOFileFilter to the provided File + objects.
+
+
filterSet(IOFileFilter, File...) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
+ Applies an IOFileFilter to the provided File + objects.
+
+
filterSet(IOFileFilter, Iterable<File>) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
+ Applies an IOFileFilter to the provided File + objects.
+
+
finalize() - Method in class org.apache.commons.io.input.AutoCloseInputStream
+
+
Ensures that the stream is closed before it gets garbage-collected.
+
+
flush() - Method in class org.apache.commons.io.output.BrokenOutputStream
+
+
Throws the configured exception.
+
+
flush() - Method in class org.apache.commons.io.output.DemuxOutputStream
+
+
Flushes stream associated with current thread.
+
+
flush() - Method in class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Flush the stream.
+
+
flush() - Method in class org.apache.commons.io.output.LockableFileWriter
+
+
Flush the stream.
+
+
flush() - Method in class org.apache.commons.io.output.NullWriter
+
 
+
flush() - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Invokes the delegate's flush() method.
+
+
flush() - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's flush() method.
+
+
flush() - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Flushing this writer has no effect.
+
+
flush() - Method in class org.apache.commons.io.output.TeeOutputStream
+
+
Flushes both streams.
+
+
flush() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Flushes this output stream and forces any buffered output bytes to be + written out.
+
+
flush() - Method in class org.apache.commons.io.output.WriterOutputStream
+
+
Flush the stream.
+
+
flush() - Method in class org.apache.commons.io.output.XmlStreamWriter
+
+
Flush the underlying writer.
+
+
FORCE - Static variable in class org.apache.commons.io.FileDeleteStrategy
+
+
The singleton instance for forced file deletion, which always deletes, + even if the file represents a non-empty directory.
+
+
forceDelete(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Deletes a file.
+
+
forceDeleteOnExit(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Schedules a file to be deleted when JVM exits.
+
+
forceMkdir(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Makes a directory, including any necessary but nonexistent parent + directories.
+
+
forceMkdirParent(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Makes any necessary but nonexistent parent directories for a given File.
+
+
forName(String) - Static method in enum org.apache.commons.io.IOCase
+
+
Factory method to create an IOCase from a name.
+
+
freeSpace(String) - Static method in class org.apache.commons.io.FileSystemUtils
+
+
Deprecated. +
Use freeSpaceKb(String) + Deprecated from 1.3, may be removed in 2.0
+
+
+
freeSpaceKb(String) - Static method in class org.apache.commons.io.FileSystemUtils
+
+
Returns the free space on a drive or volume in kilobytes by invoking + the command line.
+
+
freeSpaceKb(String, long) - Static method in class org.apache.commons.io.FileSystemUtils
+
+
Returns the free space on a drive or volume in kilobytes by invoking + the command line.
+
+
freeSpaceKb() - Static method in class org.apache.commons.io.FileSystemUtils
+
+
Returns the disk size of the volume which holds the working directory.
+
+
freeSpaceKb(long) - Static method in class org.apache.commons.io.FileSystemUtils
+
+
Returns the disk size of the volume which holds the working directory.
+
+
+ + + +

G

+
+
get(int) - Method in class org.apache.commons.io.ByteOrderMark
+
+
The byte at the specified position.
+
+
getAppendable() - Method in class org.apache.commons.io.output.AppendableOutputStream
+
+
Return the target appendable.
+
+
getBaseName(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the base name, minus the full path and extension, from a full filename.
+
+
getBOM() - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Return the BOM (Byte Order Mark).
+
+
getBOMCharsetName() - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Return the BOM charset Name - ByteOrderMark.getCharsetName().
+
+
getBomEncoding() - Method in exception org.apache.commons.io.input.XmlStreamReaderException
+
+
Returns the BOM encoding found in the InputStream.
+
+
getBuilder() - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Returns the underlying builder.
+
+
getByteCount() - Method in class org.apache.commons.io.input.CountingInputStream
+
+
The number of bytes that have passed through this stream.
+
+
getByteCount() - Method in class org.apache.commons.io.output.CountingOutputStream
+
+
The number of bytes that have passed through this stream.
+
+
getByteCount() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Returns the number of bytes that have been written to this output stream.
+
+
getBytes() - Method in class org.apache.commons.io.ByteOrderMark
+
+
Return a copy of the BOM's bytes.
+
+
getCause() - Method in exception org.apache.commons.io.TaggedIOException
+
+
Returns the wrapped exception.
+
+
getCharsetName() - Method in class org.apache.commons.io.ByteOrderMark
+
+
Return the name of the Charset the BOM represents.
+
+
getChildren() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the directory's files.
+
+
getContentTypeEncoding() - Method in exception org.apache.commons.io.input.XmlStreamReaderException
+
+
Returns the encoding in the content-type used to attempt determining the + encoding.
+
+
getContentTypeMime() - Method in exception org.apache.commons.io.input.XmlStreamReaderException
+
+
Returns the MIME type in the content-type used to attempt determining the + encoding.
+
+
getCount() - Method in class org.apache.commons.io.input.CountingInputStream
+
+
The number of bytes that have passed through this stream.
+
+
getCount() - Method in class org.apache.commons.io.output.CountingOutputStream
+
+
The number of bytes that have passed through this stream.
+
+
getData() - Method in class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Returns the data for this output stream as an array of bytes, assuming + that the data has been retained in memory.
+
+
getDefaultEncoding() - Method in class org.apache.commons.io.input.XmlStreamReader
+
+
Returns the default encoding to use if none is set in HTTP content-type, + XML prolog and the rules based on content-type are not adequate.
+
+
getDefaultEncoding() - Method in class org.apache.commons.io.output.XmlStreamWriter
+
+
Return the default encoding.
+
+
getDelay() - Method in class org.apache.commons.io.input.Tailer
+
+
Return the delay in milliseconds.
+
+
getDeleteFailures() - Method in class org.apache.commons.io.FileCleaningTracker
+
+
Return the file paths that failed to delete.
+
+
getDepth() - Method in exception org.apache.commons.io.DirectoryWalker.CancelException
+
+
Return the depth when the operation was cancelled.
+
+
getDirectory() - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Return the directory being observed.
+
+
getEncoding() - Method in class org.apache.commons.io.input.XmlStreamReader
+
+
Returns the charset encoding of the XmlStreamReader.
+
+
getEncoding() - Method in class org.apache.commons.io.output.XmlStreamWriter
+
+
Return the detected encoding.
+
+
getExtension(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the extension of a filename.
+
+
getFile() - Method in exception org.apache.commons.io.DirectoryWalker.CancelException
+
+
Return the file when the operation was cancelled.
+
+
getFile(File, String...) - Static method in class org.apache.commons.io.FileUtils
+
+
Construct a file from the set of name elements.
+
+
getFile(String...) - Static method in class org.apache.commons.io.FileUtils
+
+
Construct a file from the set of name elements.
+
+
getFile() - Method in class org.apache.commons.io.input.Tailer
+
+
Return the file.
+
+
getFile() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the file being monitored.
+
+
getFile() - Method in class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Returns either the output file specified in the constructor or + the temporary file created or null.
+
+
getFileFilter() - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Return the fileFilter.
+
+
getFileFilters() - Method in class org.apache.commons.io.filefilter.AndFileFilter
+
+
Returns this conditional file filter's list of file filters.
+
+
getFileFilters() - Method in interface org.apache.commons.io.filefilter.ConditionalFileFilter
+
+
Returns this conditional file filter's list of file filters.
+
+
getFileFilters() - Method in class org.apache.commons.io.filefilter.OrFileFilter
+
+
Returns this conditional file filter's list of file filters.
+
+
getFullPath(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the full path from a full filename, which is the prefix + path.
+
+
getFullPathNoEndSeparator(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the full path from a full filename, which is the prefix + path, + and also excluding the final directory separator.
+
+
getInstance() - Static method in class org.apache.commons.io.FileCleaner
+
+
Deprecated.
+
Returns the singleton instance, which is used by the deprecated, static methods.
+
+
getInterval() - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Return the interval.
+
+
getLastModified() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the last modified time from the last time it + was checked.
+
+
getLength() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the length.
+
+
getLevel() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the level
+
+
getListeners() - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Returns the set of registered file system listeners.
+
+
getName(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the name minus the path from a full filename.
+
+
getName() - Method in enum org.apache.commons.io.IOCase
+
+
Gets the name of the constant.
+
+
getName() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the file name.
+
+
getObservers() - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Returns the set of FileAlterationObserver registered with + this monitor.
+
+
getParent() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the parent entry.
+
+
getPath(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the path from a full filename, which excludes the prefix.
+
+
getPathNoEndSeparator(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the path from a full filename, which excludes the prefix, and + also excluding the final directory separator.
+
+
getPosition() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Return the current position.
+
+
getPosition() - Method in class org.apache.commons.io.input.NullReader
+
+
Return the current position.
+
+
getPrefix(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Gets the prefix from a full filename, such as C:/ + or ~/.
+
+
getPrefixLength(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Returns the length of the filename prefix, such as C:/ or ~/.
+
+
getRun() - Method in class org.apache.commons.io.input.Tailer
+
+
Gets whether to keep on running.
+
+
getSize() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Return the size this InputStream emulates.
+
+
getSize() - Method in class org.apache.commons.io.input.NullReader
+
+
Return the size this Reader emulates.
+
+
getStream() - Method in class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Returns the current output stream.
+
+
getStream() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Returns the underlying output stream, to which the corresponding + OutputStream methods in this class will ultimately delegate.
+
+
getTag() - Method in exception org.apache.commons.io.TaggedIOException
+
+
Returns the serializable tag object.
+
+
getTempDirectory() - Static method in class org.apache.commons.io.FileUtils
+
+
Returns a File representing the system temporary directory.
+
+
getTempDirectoryPath() - Static method in class org.apache.commons.io.FileUtils
+
+
Returns the path to the system temporary directory.
+
+
getThreshold() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Returns the threshold, in bytes, at which an event will be triggered.
+
+
getTrackCount() - Static method in class org.apache.commons.io.FileCleaner
+
+ +
+
getTrackCount() - Method in class org.apache.commons.io.FileCleaningTracker
+
+
Retrieve the number of files currently being tracked, and therefore + awaiting deletion.
+
+
getUserDirectory() - Static method in class org.apache.commons.io.FileUtils
+
+
Returns a File representing the user's home directory.
+
+
getUserDirectoryPath() - Static method in class org.apache.commons.io.FileUtils
+
+
Returns the path to the user's home directory.
+
+
getXmlEncoding() - Method in exception org.apache.commons.io.input.XmlStreamReaderException
+
+
Returns the encoding found in the XML prolog of the InputStream.
+
+
getXmlGuessEncoding() - Method in exception org.apache.commons.io.input.XmlStreamReaderException
+
+
Returns the encoding guess based on the first bytes of the InputStream.
+
+
+ + + +

H

+
+
handle(String) - Method in interface org.apache.commons.io.input.TailerListener
+
+
Handles a line from a Tailer.
+
+
handle(Exception) - Method in interface org.apache.commons.io.input.TailerListener
+
+
Handles an Exception .
+
+
handle(String) - Method in class org.apache.commons.io.input.TailerListenerAdapter
+
+
Handles a line from a Tailer.
+
+
handle(Exception) - Method in class org.apache.commons.io.input.TailerListenerAdapter
+
+
Handles an Exception .
+
+
handleCancelled(File, Collection<T>, DirectoryWalker.CancelException) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked when the operation is cancelled.
+
+
handleDirectory(File, int, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked to determine if a directory should be processed.
+
+
handleDirectoryEnd(File, int, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked at the end of processing each directory.
+
+
handleDirectoryStart(File, int, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked at the start of processing each directory.
+
+
handleEnd(Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked at the end of processing.
+
+
handleFile(File, int, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked for each (non-directory) file.
+
+
handleIOException(IOException) - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Handle any IOExceptions thrown.
+
+
handleIOException(IOException) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Handle any IOExceptions thrown.
+
+
handleIOException(IOException) - Method in class org.apache.commons.io.input.TaggedInputStream
+
+
Tags any IOExceptions thrown, wrapping and re-throwing.
+
+
handleIOException(IOException) - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Handle any IOExceptions thrown.
+
+
handleIOException(IOException) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Handle any IOExceptions thrown.
+
+
handleIOException(IOException) - Method in class org.apache.commons.io.output.TaggedOutputStream
+
+
Tags any IOExceptions thrown, wrapping and re-throwing.
+
+
handleIsCancelled(File, int, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked to determine if the entire walk + operation should be immediately cancelled.
+
+
handleRestricted(File, int, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked for each restricted directory.
+
+
handleStart(File, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Overridable callback method invoked at the start of processing.
+
+
hasBOM() - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Indicates whether the stream contains one of the specified BOMs.
+
+
hasBOM(ByteOrderMark) - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Indicates whether the stream contains the specified BOM.
+
+
hashCode() - Method in class org.apache.commons.io.ByteOrderMark
+
+
Return the hashcode for this BOM.
+
+
hasNext() - Method in class org.apache.commons.io.LineIterator
+
+
Indicates whether the Reader has more lines.
+
+
HexDump - Class in org.apache.commons.io
+
+
Dumps data in hexadecimal format.
+
+
HexDump() - Constructor for class org.apache.commons.io.HexDump
+
+
Instances should NOT be constructed in standard programming.
+
+
HIDDEN - Static variable in class org.apache.commons.io.filefilter.HiddenFileFilter
+
+
Singleton instance of hidden filter
+
+
HiddenFileFilter - Class in org.apache.commons.io.filefilter
+
+
This filter accepts Files that are hidden.
+
+
HiddenFileFilter() - Constructor for class org.apache.commons.io.filefilter.HiddenFileFilter
+
+
Restrictive consructor.
+
+
+ + + +

I

+
+
indexOfExtension(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Returns the index of the last extension separator character, which is a dot.
+
+
indexOfLastSeparator(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Returns the index of the last directory separator character.
+
+
init(Tailer) - Method in interface org.apache.commons.io.input.TailerListener
+
+
The tailer will call this method during construction, + giving the listener a method of stopping the tailer.
+
+
init(Tailer) - Method in class org.apache.commons.io.input.TailerListenerAdapter
+
+
The tailer will call this method during construction, + giving the listener a method of stopping the tailer.
+
+
initialize() - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Initialize the observer.
+
+
INSTANCE - Static variable in class org.apache.commons.io.filefilter.DirectoryFileFilter
+
+
Singleton instance of directory filter.
+
+
INSTANCE - Static variable in class org.apache.commons.io.filefilter.FalseFileFilter
+
+
Singleton instance of false filter.
+
+
INSTANCE - Static variable in class org.apache.commons.io.filefilter.TrueFileFilter
+
+
Singleton instance of true filter.
+
+
invalidClassNameFound(String) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Called to throw InvalidClassException if an invalid + class name is found during deserialization.
+
+
IOCase - Enum in org.apache.commons.io
+
+
Enumeration of IO case sensitivity.
+
+
IOExceptionWithCause - Exception in org.apache.commons.io
+
+
Deprecated. +
(since 2.5) use IOException instead
+
+
+
IOExceptionWithCause(String, Throwable) - Constructor for exception org.apache.commons.io.IOExceptionWithCause
+
+
Deprecated.
+
Constructs a new instance with the given message and cause.
+
+
IOExceptionWithCause(Throwable) - Constructor for exception org.apache.commons.io.IOExceptionWithCause
+
+
Deprecated.
+
Constructs a new instance with the given cause.
+
+
IOFileFilter - Interface in org.apache.commons.io.filefilter
+
+
An interface which brings the FileFilter and FilenameFilter + interfaces together.
+
+
IOUtils - Class in org.apache.commons.io
+
+
General IO stream manipulation utilities.
+
+
IOUtils() - Constructor for class org.apache.commons.io.IOUtils
+
+
Instances should NOT be constructed in standard programming.
+
+
isCaseSensitive() - Method in enum org.apache.commons.io.IOCase
+
+
Does the object represent case sensitive comparison.
+
+
isCauseOf(Throwable) - Method in class org.apache.commons.io.input.TaggedInputStream
+
+
Tests if the given exception was caused by this stream.
+
+
isCauseOf(Exception) - Method in class org.apache.commons.io.output.TaggedOutputStream
+
+
Tests if the given exception was caused by this stream.
+
+
isDirectory() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Indicate whether the file is a directory or not.
+
+
isExists() - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Indicate whether the file existed the last time it + was checked.
+
+
isExtension(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether the extension of the filename is that specified.
+
+
isExtension(String, String[]) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether the extension of the filename is one of those specified.
+
+
isExtension(String, Collection<String>) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks whether the extension of the filename is one of those specified.
+
+
isFileNewer(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Tests if the specified File is newer than the reference + File.
+
+
isFileNewer(File, Date) - Static method in class org.apache.commons.io.FileUtils
+
+
Tests if the specified File is newer than the specified + Date.
+
+
isFileNewer(File, long) - Static method in class org.apache.commons.io.FileUtils
+
+
Tests if the specified File is newer than the specified + time reference.
+
+
isFileOlder(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Tests if the specified File is older than the reference + File.
+
+
isFileOlder(File, Date) - Static method in class org.apache.commons.io.FileUtils
+
+
Tests if the specified File is older than the specified + Date.
+
+
isFileOlder(File, long) - Static method in class org.apache.commons.io.FileUtils
+
+
Tests if the specified File is older than the specified + time reference.
+
+
isInMemory() - Method in class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Determines whether or not the data for this output stream has been + retained in memory.
+
+
ISO_8859_1 - Static variable in class org.apache.commons.io.Charsets
+
+
Deprecated. +
Use Java 7's StandardCharsets
+
+
+
isPropagateClose() - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Indicates whether the BoundedInputStream.close() method + should propagate to the underling InputStream.
+
+
isSymlink(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Determines whether the specified file is a Symbolic Link rather than an actual file.
+
+
isTaggedWith(Throwable, Object) - Static method in exception org.apache.commons.io.TaggedIOException
+
+
Checks whether the given throwable is tagged with the given tag.
+
+
isThresholdExceeded() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Determines whether or not the configured threshold has been exceeded for + this output stream.
+
+
isValidLine(String) - Method in class org.apache.commons.io.LineIterator
+
+
Overridable method to validate each line that is returned.
+
+
iterateFiles(File, IOFileFilter, IOFileFilter) - Static method in class org.apache.commons.io.FileUtils
+
+
Allows iteration over the files in given directory (and optionally + its subdirectories).
+
+
iterateFiles(File, String[], boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Allows iteration over the files in a given directory (and optionally + its subdirectories) which match an array of extensions.
+
+
iterateFilesAndDirs(File, IOFileFilter, IOFileFilter) - Static method in class org.apache.commons.io.FileUtils
+
+
Allows iteration over the files in given directory (and optionally + its subdirectories).
+
+
+ + + +

L

+
+
LASTMODIFIED_COMPARATOR - Static variable in class org.apache.commons.io.comparator.LastModifiedFileComparator
+
+
Last modified comparator instance
+
+
LASTMODIFIED_REVERSE - Static variable in class org.apache.commons.io.comparator.LastModifiedFileComparator
+
+
Reverse last modified comparator instance
+
+
LastModifiedFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare the last modified date/time of two files for order + (see File.lastModified()).
+
+
LastModifiedFileComparator() - Constructor for class org.apache.commons.io.comparator.LastModifiedFileComparator
+
 
+
length() - Method in class org.apache.commons.io.ByteOrderMark
+
+
Return the length of the BOM's bytes.
+
+
LINE_SEPARATOR - Static variable in class org.apache.commons.io.IOUtils
+
+
The system line separator string.
+
+
LINE_SEPARATOR_UNIX - Static variable in class org.apache.commons.io.IOUtils
+
+
The Unix line separator string.
+
+
LINE_SEPARATOR_WINDOWS - Static variable in class org.apache.commons.io.IOUtils
+
+
The Windows line separator string.
+
+
lineIterator(File, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Returns an Iterator for the lines in a File.
+
+
lineIterator(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Returns an Iterator for the lines in a File using the default encoding for the VM.
+
+
lineIterator(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns an Iterator for the lines in a Reader.
+
+
lineIterator(InputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns an Iterator for the lines in an InputStream, using + the character encoding specified (or default encoding if null).
+
+
lineIterator(InputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns an Iterator for the lines in an InputStream, using + the character encoding specified (or default encoding if null).
+
+
LineIterator - Class in org.apache.commons.io
+
+
An Iterator over the lines in a Reader.
+
+
LineIterator(Reader) - Constructor for class org.apache.commons.io.LineIterator
+
+
Constructs an iterator of the lines for a Reader.
+
+
listFiles(File, IOFileFilter, IOFileFilter) - Static method in class org.apache.commons.io.FileUtils
+
+
Finds files within a given directory (and optionally its + subdirectories).
+
+
listFiles(File, String[], boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Finds files within a given directory (and optionally its subdirectories) + which match an array of extensions.
+
+
listFilesAndDirs(File, IOFileFilter, IOFileFilter) - Static method in class org.apache.commons.io.FileUtils
+
+
Finds files within a given directory (and optionally its + subdirectories).
+
+
LockableFileWriter - Class in org.apache.commons.io.output
+
+
FileWriter that will create and honor lock files to allow simple + cross thread file lock handling.
+
+
LockableFileWriter(String) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter.
+
+
LockableFileWriter(String, boolean) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter.
+
+
LockableFileWriter(String, boolean, String) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter.
+
+
LockableFileWriter(File) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter.
+
+
LockableFileWriter(File, boolean) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter.
+
+
LockableFileWriter(File, boolean, String) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+ +
+
LockableFileWriter(File, Charset) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter with a file encoding.
+
+
LockableFileWriter(File, String) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter with a file encoding.
+
+
LockableFileWriter(File, Charset, boolean, String) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter with a file encoding.
+
+
LockableFileWriter(File, String, boolean, String) - Constructor for class org.apache.commons.io.output.LockableFileWriter
+
+
Constructs a LockableFileWriter with a file encoding.
+
+
+ + + +

M

+
+
magicNumberFileFilter(String) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that accepts files that begin with the provided magic + number.
+
+
magicNumberFileFilter(String, long) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that accepts files that contains the provided magic + number at a specified offset within the file.
+
+
magicNumberFileFilter(byte[]) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that accepts files that begin with the provided magic + number.
+
+
magicNumberFileFilter(byte[], long) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that accepts files that contains the provided magic + number at a specified offset within the file.
+
+
MagicNumberFileFilter - Class in org.apache.commons.io.filefilter
+
+
+ File filter for matching files containing a "magic number".
+
+
MagicNumberFileFilter(byte[]) - Constructor for class org.apache.commons.io.filefilter.MagicNumberFileFilter
+
+
+ Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files.
+
+
MagicNumberFileFilter(String) - Constructor for class org.apache.commons.io.filefilter.MagicNumberFileFilter
+
+
+ Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files.
+
+
MagicNumberFileFilter(String, long) - Constructor for class org.apache.commons.io.filefilter.MagicNumberFileFilter
+
+
+ Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files and the byte offset location in the file to + to look for that magic number.
+
+
MagicNumberFileFilter(byte[], long) - Constructor for class org.apache.commons.io.filefilter.MagicNumberFileFilter
+
+
+ Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files and the byte offset location in the file to + to look for that magic number.
+
+
makeCVSAware(IOFileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Decorates a filter to make it ignore CVS directories.
+
+
makeDirectoryOnly(IOFileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Decorates a filter so that it only applies to directories and not to files.
+
+
makeFileOnly(IOFileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Decorates a filter so that it only applies to files and not to directories.
+
+
makeSVNAware(IOFileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Decorates a filter to make it ignore SVN directories.
+
+
mark(int) - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Invokes the delegate's mark(int) method.
+
+
mark(int) - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's mark(int) method.
+
+
mark(int) - Method in class org.apache.commons.io.input.BoundedReader
+
+
marks the target stream, @see java.io.Reader#mark(int).
+
+
mark(int) - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
mark(int) - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Mark the current position.
+
+
mark(int) - Method in class org.apache.commons.io.input.NullInputStream
+
+
Mark the current position.
+
+
mark(int) - Method in class org.apache.commons.io.input.NullReader
+
+
Mark the current position.
+
+
mark(int) - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's mark(int) method.
+
+
mark(int) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's mark(int) method.
+
+
mark(int) - Method in class org.apache.commons.io.input.UnixLineEndingInputStream
+
mark(int) - Method in class org.apache.commons.io.input.WindowsLineEndingInputStream
+
markSupported() - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's markSupported() method.
+
+
markSupported() - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
 
+
markSupported() - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Mark is supported (returns true).
+
+
markSupported() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Indicates whether mark is supported.
+
+
markSupported() - Method in class org.apache.commons.io.input.NullReader
+
+
Indicates whether mark is supported.
+
+
markSupported() - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's markSupported() method.
+
+
markSupported() - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's markSupported() method.
+
+
matches(String) - Method in interface org.apache.commons.io.serialization.ClassNameMatcher
+
+
Returns true if the supplied class name matches this object's condition.
+
+
moveDirectory(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Moves a directory.
+
+
moveDirectoryToDirectory(File, File, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Moves a directory to another directory.
+
+
moveFile(File, File) - Static method in class org.apache.commons.io.FileUtils
+
+
Moves a file.
+
+
moveFileToDirectory(File, File, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Moves a file to a directory.
+
+
moveToDirectory(File, File, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Moves a file or directory to the destination directory.
+
+
+ + + +

N

+
+
NAME_COMPARATOR - Static variable in class org.apache.commons.io.comparator.NameFileComparator
+
+
Case-sensitive name comparator instance (see IOCase.SENSITIVE)
+
+
NAME_INSENSITIVE_COMPARATOR - Static variable in class org.apache.commons.io.comparator.NameFileComparator
+
+
Case-insensitive name comparator instance (see IOCase.INSENSITIVE)
+
+
NAME_INSENSITIVE_REVERSE - Static variable in class org.apache.commons.io.comparator.NameFileComparator
+
+
Reverse case-insensitive name comparator instance (see IOCase.INSENSITIVE)
+
+
NAME_REVERSE - Static variable in class org.apache.commons.io.comparator.NameFileComparator
+
+
Reverse case-sensitive name comparator instance (see IOCase.SENSITIVE)
+
+
NAME_SYSTEM_COMPARATOR - Static variable in class org.apache.commons.io.comparator.NameFileComparator
+
+
System sensitive name comparator instance (see IOCase.SYSTEM)
+
+
NAME_SYSTEM_REVERSE - Static variable in class org.apache.commons.io.comparator.NameFileComparator
+
+
Reverse system sensitive name comparator instance (see IOCase.SYSTEM)
+
+
NameFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare the names of two files for order (see File.getName()).
+
+
NameFileComparator() - Constructor for class org.apache.commons.io.comparator.NameFileComparator
+
+
Construct a case sensitive file name comparator instance.
+
+
NameFileComparator(IOCase) - Constructor for class org.apache.commons.io.comparator.NameFileComparator
+
+
Construct a file name comparator instance with the specified case-sensitivity.
+
+
nameFileFilter(String) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the filename matches the specified text.
+
+
nameFileFilter(String, IOCase) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the filename matches the specified text.
+
+
NameFileFilter - Class in org.apache.commons.io.filefilter
+
+
Filters filenames for a certain name.
+
+
NameFileFilter(String) - Constructor for class org.apache.commons.io.filefilter.NameFileFilter
+
+
Constructs a new case-sensitive name file filter for a single name.
+
+
NameFileFilter(String, IOCase) - Constructor for class org.apache.commons.io.filefilter.NameFileFilter
+
+
Construct a new name file filter specifying case-sensitivity.
+
+
NameFileFilter(String[]) - Constructor for class org.apache.commons.io.filefilter.NameFileFilter
+
+
Constructs a new case-sensitive name file filter for an array of names.
+
+
NameFileFilter(String[], IOCase) - Constructor for class org.apache.commons.io.filefilter.NameFileFilter
+
+
Constructs a new name file filter for an array of names specifying case-sensitivity.
+
+
NameFileFilter(List<String>) - Constructor for class org.apache.commons.io.filefilter.NameFileFilter
+
+
Constructs a new case-sensitive name file filter for a list of names.
+
+
NameFileFilter(List<String>, IOCase) - Constructor for class org.apache.commons.io.filefilter.NameFileFilter
+
+
Constructs a new name file filter for a list of names specifying case-sensitivity.
+
+
newChildInstance(File) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Create a new child instance.
+
+
next() - Method in class org.apache.commons.io.LineIterator
+
+
Returns the next line in the wrapped Reader.
+
+
nextLine() - Method in class org.apache.commons.io.LineIterator
+
+
Returns the next line in the wrapped Reader.
+
+
NORMAL - Static variable in class org.apache.commons.io.FileDeleteStrategy
+
+
The singleton instance for normal file deletion, which does not permit + the deletion of directories that are not empty.
+
+
normalize(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Normalizes a path, removing double and single dot path steps.
+
+
normalize(String, boolean) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Normalizes a path, removing double and single dot path steps.
+
+
normalizeNoEndSeparator(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Normalizes a path, removing double and single dot path steps, + and removing any final directory separator.
+
+
normalizeNoEndSeparator(String, boolean) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Normalizes a path, removing double and single dot path steps, + and removing any final directory separator.
+
+
NOT_EMPTY - Static variable in class org.apache.commons.io.filefilter.EmptyFileFilter
+
+
Singleton instance of not-empty filter
+
+
notFileFilter(IOFileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that NOTs the specified filter.
+
+
NotFileFilter - Class in org.apache.commons.io.filefilter
+
+
This filter produces a logical NOT of the filters specified.
+
+
NotFileFilter(IOFileFilter) - Constructor for class org.apache.commons.io.filefilter.NotFileFilter
+
+
Constructs a new file filter that NOTs the result of another filter.
+
+
NULL_OUTPUT_STREAM - Static variable in class org.apache.commons.io.output.NullOutputStream
+
+
A singleton.
+
+
NULL_WRITER - Static variable in class org.apache.commons.io.output.NullWriter
+
+
A singleton.
+
+
NullInputStream - Class in org.apache.commons.io.input
+
+
A functional, light weight InputStream that emulates + a stream of a specified size.
+
+
NullInputStream(long) - Constructor for class org.apache.commons.io.input.NullInputStream
+
+
Create an InputStream that emulates a specified size + which supports marking and does not throw EOFException.
+
+
NullInputStream(long, boolean, boolean) - Constructor for class org.apache.commons.io.input.NullInputStream
+
+
Create an InputStream that emulates a specified + size with option settings.
+
+
NullOutputStream - Class in org.apache.commons.io.output
+
+
This OutputStream writes all data to the famous /dev/null.
+
+
NullOutputStream() - Constructor for class org.apache.commons.io.output.NullOutputStream
+
 
+
NullReader - Class in org.apache.commons.io.input
+
+
A functional, light weight Reader that emulates + a reader of a specified size.
+
+
NullReader(long) - Constructor for class org.apache.commons.io.input.NullReader
+
+
Create a Reader that emulates a specified size + which supports marking and does not throw EOFException.
+
+
NullReader(long, boolean, boolean) - Constructor for class org.apache.commons.io.input.NullReader
+
+
Create a Reader that emulates a specified + size with option settings.
+
+
NullWriter - Class in org.apache.commons.io.output
+
+
This Writer writes all data to the famous /dev/null.
+
+
NullWriter() - Constructor for class org.apache.commons.io.output.NullWriter
+
+
Constructs a new NullWriter.
+
+
+ + + +

O

+
+
onDirectoryChange(File) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
Directory changed Event.
+
+
onDirectoryChange(File) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
Directory changed Event.
+
+
onDirectoryCreate(File) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
Directory created Event.
+
+
onDirectoryCreate(File) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
Directory created Event.
+
+
onDirectoryDelete(File) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
Directory deleted Event.
+
+
onDirectoryDelete(File) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
Directory deleted Event.
+
+
ONE_EB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in an exabyte.
+
+
ONE_EB_BI - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in an exabyte.
+
+
ONE_GB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a gigabyte.
+
+
ONE_GB_BI - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a gigabyte.
+
+
ONE_KB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a kilobyte.
+
+
ONE_KB_BI - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a kilobyte.
+
+
ONE_MB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a megabyte.
+
+
ONE_MB_BI - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a megabyte.
+
+
ONE_PB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a petabyte.
+
+
ONE_PB_BI - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a petabyte.
+
+
ONE_TB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a terabyte.
+
+
ONE_TB_BI - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a terabyte.
+
+
ONE_YB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a yottabyte.
+
+
ONE_ZB - Static variable in class org.apache.commons.io.FileUtils
+
+
The number of bytes in a zettabyte.
+
+
onFileChange(File) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
File changed Event.
+
+
onFileChange(File) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
File changed Event.
+
+
onFileCreate(File) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
File created Event.
+
+
onFileCreate(File) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
File created Event.
+
+
onFileDelete(File) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
File deleted Event.
+
+
onFileDelete(File) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
File deleted Event.
+
+
onStart(FileAlterationObserver) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
File system observer started checking event.
+
+
onStart(FileAlterationObserver) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
File system observer started checking event.
+
+
onStop(FileAlterationObserver) - Method in interface org.apache.commons.io.monitor.FileAlterationListener
+
+
File system observer finished checking event.
+
+
onStop(FileAlterationObserver) - Method in class org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+
+
File system observer finished checking event.
+
+
openInputStream(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Opens a FileInputStream for the specified file, providing better + error messages than simply calling new FileInputStream(file).
+
+
openOutputStream(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Opens a FileOutputStream for the specified file, checking and + creating the parent directory if it does not exist.
+
+
openOutputStream(File, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Opens a FileOutputStream for the specified file, checking and + creating the parent directory if it does not exist.
+
+
or(IOFileFilter...) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that ORs the specified filters.
+
+
orFileFilter(IOFileFilter, IOFileFilter) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+ +
+
OrFileFilter - Class in org.apache.commons.io.filefilter
+
+
A FileFilter providing conditional OR logic across a list of + file filters.
+
+
OrFileFilter() - Constructor for class org.apache.commons.io.filefilter.OrFileFilter
+
+
Constructs a new instance of OrFileFilter.
+
+
OrFileFilter(List<IOFileFilter>) - Constructor for class org.apache.commons.io.filefilter.OrFileFilter
+
+
Constructs a new instance of OrFileFilter + with the specified filters.
+
+
OrFileFilter(IOFileFilter, IOFileFilter) - Constructor for class org.apache.commons.io.filefilter.OrFileFilter
+
+
Constructs a new file filter that ORs the result of two other filters.
+
+
org.apache.commons.io - package org.apache.commons.io
+
+
+This package defines utility classes for working with streams, readers, +writers and files.
+
+
org.apache.commons.io.comparator - package org.apache.commons.io.comparator
+
+
This package provides various Comparator implementations +for Files.
+
+
org.apache.commons.io.filefilter - package org.apache.commons.io.filefilter
+
+
This package defines an interface (IOFileFilter) that combines both +FileFilter and FilenameFilter.
+
+
org.apache.commons.io.input - package org.apache.commons.io.input
+
+
+This package provides implementations of input classes, such as +InputStream and Reader.
+
+
org.apache.commons.io.monitor - package org.apache.commons.io.monitor
+
+
+This package provides a component for monitoring file system events +(directory and file create, update and delete events).
+
+
org.apache.commons.io.output - package org.apache.commons.io.output
+
+
+This package provides implementations of output classes, such as +OutputStream and Writer.
+
+
org.apache.commons.io.serialization - package org.apache.commons.io.serialization
+
+
+This package provides a framework for controlling the deserialization of classes.
+
+
+ + + +

P

+
+
PATH_COMPARATOR - Static variable in class org.apache.commons.io.comparator.PathFileComparator
+
+
Case-sensitive path comparator instance (see IOCase.SENSITIVE)
+
+
PATH_INSENSITIVE_COMPARATOR - Static variable in class org.apache.commons.io.comparator.PathFileComparator
+
+
Case-insensitive path comparator instance (see IOCase.INSENSITIVE)
+
+
PATH_INSENSITIVE_REVERSE - Static variable in class org.apache.commons.io.comparator.PathFileComparator
+
+
Reverse case-insensitive path comparator instance (see IOCase.INSENSITIVE)
+
+
PATH_REVERSE - Static variable in class org.apache.commons.io.comparator.PathFileComparator
+
+
Reverse case-sensitive path comparator instance (see IOCase.SENSITIVE)
+
+
PATH_SYSTEM_COMPARATOR - Static variable in class org.apache.commons.io.comparator.PathFileComparator
+
+
System sensitive path comparator instance (see IOCase.SYSTEM)
+
+
PATH_SYSTEM_REVERSE - Static variable in class org.apache.commons.io.comparator.PathFileComparator
+
+
Reverse system sensitive path comparator instance (see IOCase.SYSTEM)
+
+
PathFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare the path of two files for order (see File.getPath()).
+
+
PathFileComparator() - Constructor for class org.apache.commons.io.comparator.PathFileComparator
+
+
Construct a case sensitive file path comparator instance.
+
+
PathFileComparator(IOCase) - Constructor for class org.apache.commons.io.comparator.PathFileComparator
+
+
Construct a file path comparator instance with the specified case-sensitivity.
+
+
prefixFileFilter(String) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the filename starts with the specified text.
+
+
prefixFileFilter(String, IOCase) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the filename starts with the specified text.
+
+
PrefixFileFilter - Class in org.apache.commons.io.filefilter
+
+
Filters filenames for a certain prefix.
+
+
PrefixFileFilter(String) - Constructor for class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Constructs a new Prefix file filter for a single prefix.
+
+
PrefixFileFilter(String, IOCase) - Constructor for class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Constructs a new Prefix file filter for a single prefix + specifying case-sensitivity.
+
+
PrefixFileFilter(String[]) - Constructor for class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Constructs a new Prefix file filter for any of an array of prefixes.
+
+
PrefixFileFilter(String[], IOCase) - Constructor for class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Constructs a new Prefix file filter for any of an array of prefixes + specifying case-sensitivity.
+
+
PrefixFileFilter(List<String>) - Constructor for class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Constructs a new Prefix file filter for a list of prefixes.
+
+
PrefixFileFilter(List<String>, IOCase) - Constructor for class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Constructs a new Prefix file filter for a list of prefixes + specifying case-sensitivity.
+
+
processByte() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Return a byte value for the read() method.
+
+
processBytes(byte[], int, int) - Method in class org.apache.commons.io.input.NullInputStream
+
+
Process the bytes for the read(byte[], offset, length) + method.
+
+
processChar() - Method in class org.apache.commons.io.input.NullReader
+
+
Return a character value for the read() method.
+
+
processChars(char[], int, int) - Method in class org.apache.commons.io.input.NullReader
+
+
Process the characters for the read(char[], offset, length) + method.
+
+
ProxyInputStream - Class in org.apache.commons.io.input
+
+
A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
+
+
ProxyInputStream(InputStream) - Constructor for class org.apache.commons.io.input.ProxyInputStream
+
+
Constructs a new ProxyInputStream.
+
+
ProxyOutputStream - Class in org.apache.commons.io.output
+
+
A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
+
+
ProxyOutputStream(OutputStream) - Constructor for class org.apache.commons.io.output.ProxyOutputStream
+
+
Constructs a new ProxyOutputStream.
+
+
ProxyReader - Class in org.apache.commons.io.input
+
+
A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
+
+
ProxyReader(Reader) - Constructor for class org.apache.commons.io.input.ProxyReader
+
+
Constructs a new ProxyReader.
+
+
ProxyWriter - Class in org.apache.commons.io.output
+
+
A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
+
+
ProxyWriter(Writer) - Constructor for class org.apache.commons.io.output.ProxyWriter
+
+
Constructs a new ProxyWriter.
+
+
+ + + +

R

+
+
read() - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Invokes the delegate's read() method, detecting and optionally skipping BOM.
+
+
read(byte[], int, int) - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Invokes the delegate's read(byte[], int, int) method, detecting and optionally skipping BOM.
+
+
read(byte[]) - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Invokes the delegate's read(byte[]) method, detecting and optionally skipping BOM.
+
+
read() - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's read() method if + the current position is less than the limit.
+
+
read(byte[]) - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's read(byte[]) method.
+
+
read(byte[], int, int) - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's read(byte[], int, int) method.
+
+
read() - Method in class org.apache.commons.io.input.BoundedReader
+
+
Reads a single character, @see java.io.Reader#read()
+
+
read(char[], int, int) - Method in class org.apache.commons.io.input.BoundedReader
+
+
Reads into an array, @see java.io.Reader#read(char[], int, int)
+
+
read() - Method in class org.apache.commons.io.input.BrokenInputStream
+
+
Throws the configured exception.
+
+
read(byte[], int, int) - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
 
+
read() - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
 
+
read(byte[]) - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
 
+
read() - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Read a single character.
+
+
read(char[], int, int) - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Read the sepcified number of characters into the array.
+
+
read() - Method in class org.apache.commons.io.input.ClosedInputStream
+
+
Returns -1 to indicate that the stream is closed.
+
+
read() - Method in class org.apache.commons.io.input.DemuxInputStream
+
+
Read byte from stream associated with current thread.
+
+
read() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Read a byte.
+
+
read(byte[]) - Method in class org.apache.commons.io.input.NullInputStream
+
+
Read some bytes into the specified array.
+
+
read(byte[], int, int) - Method in class org.apache.commons.io.input.NullInputStream
+
+
Read the specified number bytes into an array.
+
+
read() - Method in class org.apache.commons.io.input.NullReader
+
+
Read a character.
+
+
read(char[]) - Method in class org.apache.commons.io.input.NullReader
+
+
Read some characters into the specified array.
+
+
read(char[], int, int) - Method in class org.apache.commons.io.input.NullReader
+
+
Read the specified number characters into an array.
+
+
read() - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's read() method.
+
+
read(byte[]) - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's read(byte[]) method.
+
+
read(byte[], int, int) - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's read(byte[], int, int) method.
+
+
read() - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's read() method.
+
+
read(char[]) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's read(char[]) method.
+
+
read(char[], int, int) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's read(char[], int, int) method.
+
+
read(CharBuffer) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's read(CharBuffer) method.
+
+
read(byte[], int, int) - Method in class org.apache.commons.io.input.ReaderInputStream
+
+
Read the specified number of bytes into an array.
+
+
read(byte[]) - Method in class org.apache.commons.io.input.ReaderInputStream
+
+
Read the specified number of bytes into an array.
+
+
read() - Method in class org.apache.commons.io.input.ReaderInputStream
+
+
Read a single byte.
+
+
read() - Method in class org.apache.commons.io.input.TeeInputStream
+
+
Reads a single byte from the proxied input stream and writes it to + the associated output stream.
+
+
read(byte[], int, int) - Method in class org.apache.commons.io.input.TeeInputStream
+
+
Reads bytes from the proxied input stream and writes the read bytes + to the associated output stream.
+
+
read(byte[]) - Method in class org.apache.commons.io.input.TeeInputStream
+
+
Reads bytes from the proxied input stream and writes the read bytes + to the associated output stream.
+
+
read() - Method in class org.apache.commons.io.input.UnixLineEndingInputStream
+
read() - Method in class org.apache.commons.io.input.WindowsLineEndingInputStream
+
read(char[], int, int) - Method in class org.apache.commons.io.input.XmlStreamReader
+
+
Invokes the underlying reader's read(char[], int, int) method.
+
+
read(Reader, char[], int, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads characters from an input character stream.
+
+
read(Reader, char[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads characters from an input character stream.
+
+
read(InputStream, byte[], int, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads bytes from an input stream.
+
+
read(InputStream, byte[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads bytes from an input stream.
+
+
read(ReadableByteChannel, ByteBuffer) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads bytes from a ReadableByteChannel.
+
+
READ_ONLY - Static variable in class org.apache.commons.io.filefilter.CanReadFileFilter
+
+
Singleton instance of read-only filter
+
+
readBoolean() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+ +
+
readByte() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Invokes the delegate's read() method.
+
+
readChar() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Reads a character delegating to SwappedDataInputStream.readShort().
+
+
readDouble() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+ +
+
ReaderInputStream - Class in org.apache.commons.io.input
+
+
InputStream implementation that reads a character stream from a Reader + and transforms it to a byte stream using a specified charset encoding.
+
+
ReaderInputStream(Reader, CharsetEncoder) - Constructor for class org.apache.commons.io.input.ReaderInputStream
+
+
Construct a new ReaderInputStream.
+
+
ReaderInputStream(Reader, CharsetEncoder, int) - Constructor for class org.apache.commons.io.input.ReaderInputStream
+
+
Construct a new ReaderInputStream.
+
+
ReaderInputStream(Reader, Charset, int) - Constructor for class org.apache.commons.io.input.ReaderInputStream
+
+
Construct a new ReaderInputStream.
+
+
ReaderInputStream(Reader, Charset) - Constructor for class org.apache.commons.io.input.ReaderInputStream
+
+
Construct a new ReaderInputStream with a default input buffer size of + 1024 characters.
+
+
ReaderInputStream(Reader, String, int) - Constructor for class org.apache.commons.io.input.ReaderInputStream
+
+
Construct a new ReaderInputStream.
+
+
ReaderInputStream(Reader, String) - Constructor for class org.apache.commons.io.input.ReaderInputStream
+
+
Construct a new ReaderInputStream with a default input buffer size of + 1024 characters.
+
+
ReaderInputStream(Reader) - Constructor for class org.apache.commons.io.input.ReaderInputStream
+
+ +
+
readFileToByteArray(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Reads the contents of a file into a byte array.
+
+
readFileToString(File, Charset) - Static method in class org.apache.commons.io.FileUtils
+
+
Reads the contents of a file into a String.
+
+
readFileToString(File, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Reads the contents of a file into a String.
+
+
readFileToString(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Deprecated. + +
+
+
readFloat() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+ +
+
readFully(byte[]) - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Invokes the delegate's read(byte[] data, int, int) method.
+
+
readFully(byte[], int, int) - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Invokes the delegate's read(byte[] data, int, int) method.
+
+
readFully(Reader, char[], int, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads the requested number of characters or fail if there are not enough left.
+
+
readFully(Reader, char[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads the requested number of characters or fail if there are not enough left.
+
+
readFully(InputStream, byte[], int, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads the requested number of bytes or fail if there are not enough left.
+
+
readFully(InputStream, byte[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads the requested number of bytes or fail if there are not enough left.
+
+
readFully(InputStream, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads the requested number of bytes or fail if there are not enough left.
+
+
readFully(ReadableByteChannel, ByteBuffer) - Static method in class org.apache.commons.io.IOUtils
+
+
Reads the requested number of bytes or fail if there are not enough left.
+
+
readInt() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+ +
+
readLine() - Method in class org.apache.commons.io.input.ReversedLinesFileReader
+
+
Returns the lines of the file from bottom to top.
+
+
readLine() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Not currently supported - throws UnsupportedOperationException.
+
+
readLines(File, Charset) - Static method in class org.apache.commons.io.FileUtils
+
+
Reads the contents of a file line by line to a List of Strings.
+
+
readLines(File, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Reads the contents of a file line by line to a List of Strings.
+
+
readLines(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Deprecated. + +
+
+
readLines(InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
readLines(InputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a list of Strings, + one entry per line, using the specified character encoding.
+
+
readLines(InputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a list of Strings, + one entry per line, using the specified character encoding.
+
+
readLines(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a Reader as a list of Strings, + one entry per line.
+
+
readLong() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+ +
+
readShort() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+ +
+
readSwappedDouble(byte[], int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "double" value from a byte array at a given offset.
+
+
readSwappedDouble(InputStream) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "double" value from an InputStream.
+
+
readSwappedFloat(byte[], int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "float" value from a byte array at a given offset.
+
+
readSwappedFloat(InputStream) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "float" value from an InputStream.
+
+
readSwappedInteger(byte[], int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "int" value from a byte array at a given offset.
+
+
readSwappedInteger(InputStream) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "int" value from an InputStream.
+
+
readSwappedLong(byte[], int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "long" value from a byte array at a given offset.
+
+
readSwappedLong(InputStream) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "long" value from an InputStream.
+
+
readSwappedShort(byte[], int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "short" value from a byte array at a given offset.
+
+
readSwappedShort(InputStream) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a "short" value from an InputStream.
+
+
readSwappedUnsignedInteger(byte[], int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads an unsigned integer (32-bit) value from a byte array at a given + offset.
+
+
readSwappedUnsignedInteger(InputStream) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a unsigned integer (32-bit) from an InputStream.
+
+
readSwappedUnsignedShort(byte[], int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads an unsigned short (16-bit) value from a byte array at a given + offset.
+
+
readSwappedUnsignedShort(InputStream) - Static method in class org.apache.commons.io.EndianUtils
+
+
Reads a unsigned short (16-bit) from an InputStream.
+
+
readUnsignedByte() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Invokes the delegate's read() method.
+
+
readUnsignedShort() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+ +
+
readUTF() - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Not currently supported - throws UnsupportedOperationException.
+
+
ready() - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's ready() method.
+
+
refresh(File) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Refresh the attributes from the File, indicating + whether the file has changed.
+
+
RegexFileFilter - Class in org.apache.commons.io.filefilter
+
+
Filters files using supplied regular expression(s).
+
+
RegexFileFilter(String) - Constructor for class org.apache.commons.io.filefilter.RegexFileFilter
+
+
Construct a new regular expression filter.
+
+
RegexFileFilter(String, IOCase) - Constructor for class org.apache.commons.io.filefilter.RegexFileFilter
+
+
Construct a new regular expression filter with the specified flags case sensitivity.
+
+
RegexFileFilter(String, int) - Constructor for class org.apache.commons.io.filefilter.RegexFileFilter
+
+
Construct a new regular expression filter with the specified flags.
+
+
RegexFileFilter(Pattern) - Constructor for class org.apache.commons.io.filefilter.RegexFileFilter
+
+
Construct a new regular expression filter for a compiled regular expression
+
+
reject(Class<?>...) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Reject the specified classes for deserialization, even if they + are otherwise accepted.
+
+
reject(String...) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Reject the wildcard specified classes for deserialization, + even if they are otherwise accepted.
+
+
reject(Pattern) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Reject class names that match the supplied pattern for + deserialization, even if they are otherwise accepted.
+
+
reject(ClassNameMatcher) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Reject class names where the supplied ClassNameMatcher matches for + deserialization, even if they are otherwise accepted.
+
+
remove() - Method in class org.apache.commons.io.LineIterator
+
+
Unsupported.
+
+
removeExtension(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Removes the extension from a filename.
+
+
removeFileFilter(IOFileFilter) - Method in class org.apache.commons.io.filefilter.AndFileFilter
+
+
Removes the specified file filter.
+
+
removeFileFilter(IOFileFilter) - Method in interface org.apache.commons.io.filefilter.ConditionalFileFilter
+
+
Removes the specified file filter.
+
+
removeFileFilter(IOFileFilter) - Method in class org.apache.commons.io.filefilter.OrFileFilter
+
+
Removes the specified file filter.
+
+
removeListener(FileAlterationListener) - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Remove a file system listener.
+
+
removeObserver(FileAlterationObserver) - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Remove a file system observer from this monitor.
+
+
requiredCharsets() - Static method in class org.apache.commons.io.Charsets
+
+
Constructs a sorted map from canonical charset names to charset objects required of every implementation of the + Java platform.
+
+
reset() - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Invokes the delegate's reset() method.
+
+
reset() - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's reset() method.
+
+
reset() - Method in class org.apache.commons.io.input.BoundedReader
+
+
Resets the target to the latest mark, @see java.io.Reader#reset()
+
+
reset() - Method in class org.apache.commons.io.input.BrokenInputStream
+
+
Throws the configured exception.
+
+
reset() - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
 
+
reset() - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Reset the reader to the last marked position (or the beginning if + mark has not been called).
+
+
reset() - Method in class org.apache.commons.io.input.NullInputStream
+
+
Reset the stream to the point when mark was last called.
+
+
reset() - Method in class org.apache.commons.io.input.NullReader
+
+
Reset the stream to the point when mark was last called.
+
+
reset() - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's reset() method.
+
+
reset() - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's reset() method.
+
+
reset() - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
 
+
resetByteCount() - Method in class org.apache.commons.io.input.CountingInputStream
+
+
Set the byte count back to 0.
+
+
resetByteCount() - Method in class org.apache.commons.io.output.CountingOutputStream
+
+
Set the byte count back to 0.
+
+
resetByteCount() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Resets the byteCount to zero.
+
+
resetCount() - Method in class org.apache.commons.io.input.CountingInputStream
+
+
Set the byte count back to 0.
+
+
resetCount() - Method in class org.apache.commons.io.output.CountingOutputStream
+
+
Set the byte count back to 0.
+
+
resolveClass(ObjectStreamClass) - Method in class org.apache.commons.io.input.ClassLoaderObjectInputStream
+
+
Resolve a class specified by the descriptor using the + specified ClassLoader or the super ClassLoader.
+
+
resolveClass(ObjectStreamClass) - Method in class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
 
+
resolveProxyClass(String[]) - Method in class org.apache.commons.io.input.ClassLoaderObjectInputStream
+
+
Create a proxy class that implements the specified interfaces using + the specified ClassLoader or the super ClassLoader.
+
+
ReversedLinesFileReader - Class in org.apache.commons.io.input
+
+
Reads lines in a file reversely (similar to a BufferedReader, but starting at + the last line).
+
+
ReversedLinesFileReader(File) - Constructor for class org.apache.commons.io.input.ReversedLinesFileReader
+
+ +
+
ReversedLinesFileReader(File, Charset) - Constructor for class org.apache.commons.io.input.ReversedLinesFileReader
+
+
Creates a ReversedLinesFileReader with default block size of 4KB and the + specified encoding.
+
+
ReversedLinesFileReader(File, int, Charset) - Constructor for class org.apache.commons.io.input.ReversedLinesFileReader
+
+
Creates a ReversedLinesFileReader with the given block size and encoding.
+
+
ReversedLinesFileReader(File, int, String) - Constructor for class org.apache.commons.io.input.ReversedLinesFileReader
+
+
Creates a ReversedLinesFileReader with the given block size and encoding.
+
+
run() - Method in class org.apache.commons.io.input.Tailer
+
+
Follows changes in the file, calling the TailerListener's handle method for each new line.
+
+
run() - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Run.
+
+
+ + + +

S

+
+
separatorsToSystem(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Converts all separators to the system separator.
+
+
separatorsToUnix(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Converts all separators to the Unix separator of forward slash.
+
+
separatorsToWindows(String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Converts all separators to the Windows separator of backslash.
+
+
setByteCount(long) - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Sets the byteCount to count.
+
+
setChildren(FileEntry[]) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Set the directory's files.
+
+
setDirectory(boolean) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Set whether the file is a directory or not.
+
+
setExists(boolean) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Set whether the file existed the last time it + was checked.
+
+
setFileFilters(List<IOFileFilter>) - Method in class org.apache.commons.io.filefilter.AndFileFilter
+
+
Sets the list of file filters, replacing any previously configured + file filters on this filter.
+
+
setFileFilters(List<IOFileFilter>) - Method in interface org.apache.commons.io.filefilter.ConditionalFileFilter
+
+
Sets the list of file filters, replacing any previously configured + file filters on this filter.
+
+
setFileFilters(List<IOFileFilter>) - Method in class org.apache.commons.io.filefilter.OrFileFilter
+
+
Sets the list of file filters, replacing any previously configured + file filters on this filter.
+
+
setLastModified(long) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Return the last modified time from the last time it + was checked.
+
+
setLength(long) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Set the length.
+
+
setName(String) - Method in class org.apache.commons.io.monitor.FileEntry
+
+
Set the file name.
+
+
setPropagateClose(boolean) - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Set whether the BoundedInputStream.close() method + should propagate to the underling InputStream.
+
+
setThreadFactory(ThreadFactory) - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Set the thread factory.
+
+
size() - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Return the current size of the byte array.
+
+
SIZE_COMPARATOR - Static variable in class org.apache.commons.io.comparator.SizeFileComparator
+
+
Size comparator instance - directories are treated as zero size
+
+
SIZE_REVERSE - Static variable in class org.apache.commons.io.comparator.SizeFileComparator
+
+
Reverse size comparator instance - directories are treated as zero size
+
+
SIZE_SUMDIR_COMPARATOR - Static variable in class org.apache.commons.io.comparator.SizeFileComparator
+
+
Size comparator instance which sums the size of a directory's contents + using FileUtils.sizeOfDirectory(File)
+
+
SIZE_SUMDIR_REVERSE - Static variable in class org.apache.commons.io.comparator.SizeFileComparator
+
+
Reverse size comparator instance which sums the size of a directory's contents + using FileUtils.sizeOfDirectory(File)
+
+
SizeFileComparator - Class in org.apache.commons.io.comparator
+
+
Compare the length/size of two files for order (see + File.length() and FileUtils.sizeOfDirectory(File)).
+
+
SizeFileComparator() - Constructor for class org.apache.commons.io.comparator.SizeFileComparator
+
+
Construct a file size comparator instance (directories treated as zero size).
+
+
SizeFileComparator(boolean) - Constructor for class org.apache.commons.io.comparator.SizeFileComparator
+
+
Construct a file size comparator instance specifying whether the size of + the directory contents should be aggregated.
+
+
sizeFileFilter(long) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the file is bigger than a certain size.
+
+
sizeFileFilter(long, boolean) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that filters based on file size.
+
+
SizeFileFilter - Class in org.apache.commons.io.filefilter
+
+
Filters files based on size, can filter either smaller files or + files equal to or larger than a given threshold.
+
+
SizeFileFilter(long) - Constructor for class org.apache.commons.io.filefilter.SizeFileFilter
+
+
Constructs a new size file filter for files equal to or + larger than a certain size.
+
+
SizeFileFilter(long, boolean) - Constructor for class org.apache.commons.io.filefilter.SizeFileFilter
+
+
Constructs a new size file filter for files based on a certain size + threshold.
+
+
sizeOf(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Returns the size of the specified file or directory.
+
+
sizeOfAsBigInteger(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Returns the size of the specified file or directory.
+
+
sizeOfDirectory(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Counts the size of a directory recursively (sum of the length of all files).
+
+
sizeOfDirectoryAsBigInteger(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Counts the size of a directory recursively (sum of the length of all files).
+
+
sizeRangeFileFilter(long, long) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that accepts files whose size is >= minimum size + and <= maximum size.
+
+
skip(long) - Method in class org.apache.commons.io.input.BOMInputStream
+
+
Invokes the delegate's skip(long) method, detecting and optionallyskipping BOM.
+
+
skip(long) - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's skip(long) method.
+
+
skip(long) - Method in class org.apache.commons.io.input.BrokenInputStream
+
+
Throws the configured exception.
+
+
skip(long) - Method in class org.apache.commons.io.input.CharSequenceInputStream
+
 
+
skip(long) - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Skip the specified number of characters.
+
+
skip(long) - Method in class org.apache.commons.io.input.CountingInputStream
+
+
Skips the stream over the specified number of bytes, adding the skipped + amount to the count.
+
+
skip(long) - Method in class org.apache.commons.io.input.NullInputStream
+
+
Skip a specified number of bytes.
+
+
skip(long) - Method in class org.apache.commons.io.input.NullReader
+
+
Skip a specified number of characters.
+
+
skip(long) - Method in class org.apache.commons.io.input.ProxyInputStream
+
+
Invokes the delegate's skip(long) method.
+
+
skip(long) - Method in class org.apache.commons.io.input.ProxyReader
+
+
Invokes the delegate's skip(long) method.
+
+
skip(InputStream, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Skips bytes from an input byte stream.
+
+
skip(ReadableByteChannel, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Skips bytes from a ReadableByteChannel.
+
+
skip(Reader, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Skips characters from an input character stream.
+
+
skipBytes(int) - Method in class org.apache.commons.io.input.SwappedDataInputStream
+
+
Invokes the delegate's skip(int) method.
+
+
skipFully(InputStream, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Skips the requested number of bytes or fail if there are not enough left.
+
+
skipFully(ReadableByteChannel, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Skips the requested number of bytes or fail if there are not enough left.
+
+
skipFully(Reader, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Skips the requested number of characters or fail if there are not enough left.
+
+
start() - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Start monitoring.
+
+
stop() - Method in class org.apache.commons.io.input.Tailer
+
+
Allows the tailer to complete its current loop and return.
+
+
stop() - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Stop monitoring.
+
+
stop(long) - Method in class org.apache.commons.io.monitor.FileAlterationMonitor
+
+
Stop monitoring.
+
+
StringBuilderWriter - Class in org.apache.commons.io.output
+
+
Writer implementation that outputs to a StringBuilder.
+
+
StringBuilderWriter() - Constructor for class org.apache.commons.io.output.StringBuilderWriter
+
+
Constructs a new StringBuilder instance with default capacity.
+
+
StringBuilderWriter(int) - Constructor for class org.apache.commons.io.output.StringBuilderWriter
+
+
Constructs a new StringBuilder instance with the specified capacity.
+
+
StringBuilderWriter(StringBuilder) - Constructor for class org.apache.commons.io.output.StringBuilderWriter
+
+
Constructs a new instance with the specified StringBuilder.
+
+
suffixFileFilter(String) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the filename ends with the specified text.
+
+
suffixFileFilter(String, IOCase) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that returns true if the filename ends with the specified text.
+
+
SuffixFileFilter - Class in org.apache.commons.io.filefilter
+
+
Filters files based on the suffix (what the filename ends with).
+
+
SuffixFileFilter(String) - Constructor for class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Constructs a new Suffix file filter for a single extension.
+
+
SuffixFileFilter(String, IOCase) - Constructor for class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Constructs a new Suffix file filter for a single extension + specifying case-sensitivity.
+
+
SuffixFileFilter(String[]) - Constructor for class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Constructs a new Suffix file filter for an array of suffixs.
+
+
SuffixFileFilter(String[], IOCase) - Constructor for class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Constructs a new Suffix file filter for an array of suffixs + specifying case-sensitivity.
+
+
SuffixFileFilter(List<String>) - Constructor for class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Constructs a new Suffix file filter for a list of suffixes.
+
+
SuffixFileFilter(List<String>, IOCase) - Constructor for class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Constructs a new Suffix file filter for a list of suffixes + specifying case-sensitivity.
+
+
swapDouble(double) - Static method in class org.apache.commons.io.EndianUtils
+
+
Converts a "double" value between endian systems.
+
+
swapFloat(float) - Static method in class org.apache.commons.io.EndianUtils
+
+
Converts a "float" value between endian systems.
+
+
swapInteger(int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Converts a "int" value between endian systems.
+
+
swapLong(long) - Static method in class org.apache.commons.io.EndianUtils
+
+
Converts a "long" value between endian systems.
+
+
SwappedDataInputStream - Class in org.apache.commons.io.input
+
+
DataInput for systems relying on little endian data formats.
+
+
SwappedDataInputStream(InputStream) - Constructor for class org.apache.commons.io.input.SwappedDataInputStream
+
+
Constructs a SwappedDataInputStream.
+
+
swapShort(short) - Static method in class org.apache.commons.io.EndianUtils
+
+
Converts a "short" value between endian systems.
+
+
+ + + +

T

+
+
TaggedInputStream - Class in org.apache.commons.io.input
+
+
An input stream decorator that tags potential exceptions so that the + stream that caused the exception can easily be identified.
+
+
TaggedInputStream(InputStream) - Constructor for class org.apache.commons.io.input.TaggedInputStream
+
+
Creates a tagging decorator for the given input stream.
+
+
TaggedIOException - Exception in org.apache.commons.io
+
+
An IOException decorator that adds a serializable tag to the + wrapped exception.
+
+
TaggedIOException(IOException, Serializable) - Constructor for exception org.apache.commons.io.TaggedIOException
+
+
Creates a tagged wrapper for the given exception.
+
+
TaggedOutputStream - Class in org.apache.commons.io.output
+
+
An output stream decorator that tags potential exceptions so that the + stream that caused the exception can easily be identified.
+
+
TaggedOutputStream(OutputStream) - Constructor for class org.apache.commons.io.output.TaggedOutputStream
+
+
Creates a tagging decorator for the given output stream.
+
+
Tailer - Class in org.apache.commons.io.input
+
+
Simple implementation of the unix "tail -f" functionality.
+
+
Tailer(File, TailerListener) - Constructor for class org.apache.commons.io.input.Tailer
+
+
Creates a Tailer for the given file, starting from the beginning, with the default delay of 1.0s.
+
+
Tailer(File, TailerListener, long) - Constructor for class org.apache.commons.io.input.Tailer
+
+
Creates a Tailer for the given file, starting from the beginning.
+
+
Tailer(File, TailerListener, long, boolean) - Constructor for class org.apache.commons.io.input.Tailer
+
+
Creates a Tailer for the given file, with a delay other than the default 1.0s.
+
+
Tailer(File, TailerListener, long, boolean, boolean) - Constructor for class org.apache.commons.io.input.Tailer
+
+
Creates a Tailer for the given file, with a delay other than the default 1.0s.
+
+
Tailer(File, TailerListener, long, boolean, int) - Constructor for class org.apache.commons.io.input.Tailer
+
+
Creates a Tailer for the given file, with a specified buffer size.
+
+
Tailer(File, TailerListener, long, boolean, boolean, int) - Constructor for class org.apache.commons.io.input.Tailer
+
+
Creates a Tailer for the given file, with a specified buffer size.
+
+
Tailer(File, Charset, TailerListener, long, boolean, boolean, int) - Constructor for class org.apache.commons.io.input.Tailer
+
+
Creates a Tailer for the given file, with a specified buffer size.
+
+
TailerListener - Interface in org.apache.commons.io.input
+
+
Listener for events from a Tailer.
+
+
TailerListenerAdapter - Class in org.apache.commons.io.input
+
+ +
+
TailerListenerAdapter() - Constructor for class org.apache.commons.io.input.TailerListenerAdapter
+
 
+
TeeInputStream - Class in org.apache.commons.io.input
+
+
InputStream proxy that transparently writes a copy of all bytes read + from the proxied stream to a given OutputStream.
+
+
TeeInputStream(InputStream, OutputStream) - Constructor for class org.apache.commons.io.input.TeeInputStream
+
+
Creates a TeeInputStream that proxies the given InputStream + and copies all read bytes to the given OutputStream.
+
+
TeeInputStream(InputStream, OutputStream, boolean) - Constructor for class org.apache.commons.io.input.TeeInputStream
+
+
Creates a TeeInputStream that proxies the given InputStream + and copies all read bytes to the given OutputStream.
+
+
TeeOutputStream - Class in org.apache.commons.io.output
+
+
Classic splitter of OutputStream.
+
+
TeeOutputStream(OutputStream, OutputStream) - Constructor for class org.apache.commons.io.output.TeeOutputStream
+
+
Constructs a TeeOutputStream.
+
+
ThresholdingOutputStream - Class in org.apache.commons.io.output
+
+
An output stream which triggers an event when a specified number of bytes of + data have been written to it.
+
+
ThresholdingOutputStream(int) - Constructor for class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Constructs an instance of this class which will trigger an event at the + specified threshold.
+
+
thresholdReached() - Method in class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Switches the underlying output stream from a memory based stream to one + that is backed by disk.
+
+
thresholdReached() - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Indicates that the configured threshold has been reached, and that a + subclass should take whatever action necessary on this event.
+
+
throwCauseIfTaggedWith(Throwable, Object) - Static method in exception org.apache.commons.io.TaggedIOException
+
+
Throws the original IOException if the given throwable is + a TaggedIOException decorator the given tag.
+
+
throwIfCauseOf(Throwable) - Method in class org.apache.commons.io.input.TaggedInputStream
+
+
Re-throws the original exception thrown by this stream.
+
+
throwIfCauseOf(Exception) - Method in class org.apache.commons.io.output.TaggedOutputStream
+
+
Re-throws the original exception thrown by this stream.
+
+
toBufferedInputStream(InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Fetches entire contents of an InputStream and represent + same data as result InputStream.
+
+
toBufferedInputStream(InputStream, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Fetches entire contents of an InputStream and represent + same data as result InputStream.
+
+
toBufferedInputStream(InputStream) - Static method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Fetches entire contents of an InputStream and represent + same data as result InputStream.
+
+
toBufferedInputStream(InputStream, int) - Static method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Fetches entire contents of an InputStream and represent + same data as result InputStream.
+
+
toBufferedReader(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given reader if it is a BufferedReader, otherwise creates a BufferedReader from the given + reader.
+
+
toBufferedReader(Reader, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Returns the given reader if it is a BufferedReader, otherwise creates a BufferedReader from the given + reader.
+
+
toByteArray(InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a byte[].
+
+
toByteArray(InputStream, long) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets contents of an InputStream as a byte[].
+
+
toByteArray(InputStream, int) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a byte[].
+
+
toByteArray(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
toByteArray(Reader, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a Reader as a byte[] + using the specified character encoding.
+
+
toByteArray(Reader, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a Reader as a byte[] + using the specified character encoding.
+
+
toByteArray(String) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. +
2.5 Use String.getBytes() instead
+
+
+
toByteArray(URI) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a URI as a byte[].
+
+
toByteArray(URL) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a URL as a byte[].
+
+
toByteArray(URLConnection) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a URLConnection as a byte[].
+
+
toByteArray() - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Gets the curent contents of this byte stream as a byte array.
+
+
toCharArray(InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
toCharArray(InputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a character array + using the specified character encoding.
+
+
toCharArray(InputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a character array + using the specified character encoding.
+
+
toCharArray(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a Reader as a character array.
+
+
toCharset(Charset) - Static method in class org.apache.commons.io.Charsets
+
+
Returns the given Charset or the default Charset if the given Charset is null.
+
+
toCharset(String) - Static method in class org.apache.commons.io.Charsets
+
+
Returns a Charset for the named charset.
+
+
toFile(URL) - Static method in class org.apache.commons.io.FileUtils
+
+
Convert from a URL to a File.
+
+
toFiles(URL[]) - Static method in class org.apache.commons.io.FileUtils
+
+
Converts each of an array of URL to a File.
+
+
toInputStream(CharSequence) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
toInputStream(CharSequence, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Converts the specified CharSequence to an input stream, encoded as bytes + using the specified character encoding.
+
+
toInputStream(CharSequence, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Converts the specified CharSequence to an input stream, encoded as bytes + using the specified character encoding.
+
+
toInputStream(String) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
toInputStream(String, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Converts the specified string to an input stream, encoded as bytes + using the specified character encoding.
+
+
toInputStream(String, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Converts the specified string to an input stream, encoded as bytes + using the specified character encoding.
+
+
toInputStream() - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Gets the current contents of this byte stream as a Input Stream.
+
+
toList(IOFileFilter...) - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Create a List of file filters.
+
+
toString() - Method in class org.apache.commons.io.ByteOrderMark
+
+
Provide a String representation of the BOM.
+
+
toString() - Method in class org.apache.commons.io.comparator.CompositeFileComparator
+
+
String representation of this file comparator.
+
+
toString() - Method in class org.apache.commons.io.comparator.ExtensionFileComparator
+
+
String representation of this file comparator.
+
+
toString() - Method in class org.apache.commons.io.comparator.NameFileComparator
+
+
String representation of this file comparator.
+
+
toString() - Method in class org.apache.commons.io.comparator.PathFileComparator
+
+
String representation of this file comparator.
+
+
toString() - Method in class org.apache.commons.io.comparator.SizeFileComparator
+
+
String representation of this file comparator.
+
+
toString() - Method in class org.apache.commons.io.FileDeleteStrategy
+
+
Gets a string describing the delete strategy.
+
+
toString() - Method in class org.apache.commons.io.filefilter.AbstractFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.AgeFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.AndFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.DelegateFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.MagicNumberFileFilter
+
+
Returns a String representation of the file filter, which includes the + magic number bytes and byte offset.
+
+
toString() - Method in class org.apache.commons.io.filefilter.NameFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.NotFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.OrFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.PrefixFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.SizeFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.SuffixFileFilter
+
+
Provide a String representaion of this file filter.
+
+
toString() - Method in class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Provide a String representation of this file filter.
+
+
toString() - Method in class org.apache.commons.io.input.BoundedInputStream
+
+
Invokes the delegate's toString() method.
+
+
toString() - Method in class org.apache.commons.io.input.CharSequenceReader
+
+
Return a String representation of the underlying + character sequence.
+
+
toString() - Method in enum org.apache.commons.io.IOCase
+
+
Gets a string describing the sensitivity.
+
+
toString(InputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
toString(InputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a String + using the specified character encoding.
+
+
toString(InputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of an InputStream as a String + using the specified character encoding.
+
+
toString(Reader) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a Reader as a String.
+
+
toString(URI) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
toString(URI, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents at the given URI.
+
+
toString(URI, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents at the given URI.
+
+
toString(URL) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
toString(URL, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents at the given URL.
+
+
toString(URL, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents at the given URL.
+
+
toString(byte[]) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. +
2.5 Use String.String(byte[]) instead
+
+
+
toString(byte[], String) - Static method in class org.apache.commons.io.IOUtils
+
+
Gets the contents of a byte[] as a String + using the specified character encoding.
+
+
toString() - Method in class org.apache.commons.io.monitor.FileAlterationObserver
+
+
Provide a String representation of this observer.
+
+
toString() - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Deprecated. + +
+
+
toString(String) - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Gets the curent contents of this byte stream as a string + using the specified encoding.
+
+
toString(Charset) - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Gets the curent contents of this byte stream as a string + using the specified encoding.
+
+
toString() - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+ +
+
touch(File) - Static method in class org.apache.commons.io.FileUtils
+
+
Implements the same behaviour as the "touch" utility on Unix.
+
+
toURLs(File[]) - Static method in class org.apache.commons.io.FileUtils
+
+
Converts each of an array of File to a URL.
+
+
track(File, Object) - Static method in class org.apache.commons.io.FileCleaner
+
+ +
+
track(File, Object, FileDeleteStrategy) - Static method in class org.apache.commons.io.FileCleaner
+
+ +
+
track(String, Object) - Static method in class org.apache.commons.io.FileCleaner
+
+ +
+
track(String, Object, FileDeleteStrategy) - Static method in class org.apache.commons.io.FileCleaner
+
+ +
+
track(File, Object) - Method in class org.apache.commons.io.FileCleaningTracker
+
+
Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
+
+
track(File, Object, FileDeleteStrategy) - Method in class org.apache.commons.io.FileCleaningTracker
+
+
Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
+
+
track(String, Object) - Method in class org.apache.commons.io.FileCleaningTracker
+
+
Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
+
+
track(String, Object, FileDeleteStrategy) - Method in class org.apache.commons.io.FileCleaningTracker
+
+
Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
+
+
TRUE - Static variable in class org.apache.commons.io.filefilter.TrueFileFilter
+
+
Singleton instance of true filter.
+
+
trueFileFilter() - Static method in class org.apache.commons.io.filefilter.FileFilterUtils
+
+
Returns a filter that always returns true.
+
+
TrueFileFilter - Class in org.apache.commons.io.filefilter
+
+
A file filter that always returns true.
+
+
TrueFileFilter() - Constructor for class org.apache.commons.io.filefilter.TrueFileFilter
+
+
Restrictive constructor.
+
+
+ + + +

U

+
+
UnixLineEndingInputStream - Class in org.apache.commons.io.input
+
+
A filtering input stream that ensures the content will have unix-style line endings, LF.
+
+
UnixLineEndingInputStream(InputStream, boolean) - Constructor for class org.apache.commons.io.input.UnixLineEndingInputStream
+
+
Create an input stream that filters another stream
+
+
US_ASCII - Static variable in class org.apache.commons.io.Charsets
+
+
Deprecated. +
Use Java 7's StandardCharsets
+
+
+
UTF_16 - Static variable in class org.apache.commons.io.Charsets
+
+
Deprecated. +
Use Java 7's StandardCharsets
+
+
+
UTF_16BE - Static variable in class org.apache.commons.io.ByteOrderMark
+
+
UTF-16BE BOM (Big-Endian)
+
+
UTF_16BE - Static variable in class org.apache.commons.io.Charsets
+
+
Deprecated. +
Use Java 7's StandardCharsets
+
+
+
UTF_16LE - Static variable in class org.apache.commons.io.ByteOrderMark
+
+
UTF-16LE BOM (Little-Endian)
+
+
UTF_16LE - Static variable in class org.apache.commons.io.Charsets
+
+
Deprecated. +
Use Java 7's StandardCharsets
+
+
+
UTF_32BE - Static variable in class org.apache.commons.io.ByteOrderMark
+
+
UTF-32BE BOM (Big-Endian)
+
+
UTF_32LE - Static variable in class org.apache.commons.io.ByteOrderMark
+
+
UTF-32LE BOM (Little-Endian)
+
+
UTF_8 - Static variable in class org.apache.commons.io.ByteOrderMark
+
+
UTF-8 BOM
+
+
UTF_8 - Static variable in class org.apache.commons.io.Charsets
+
+
Deprecated. +
Use Java 7's StandardCharsets
+
+
+
UTF_BOM - Static variable in class org.apache.commons.io.ByteOrderMark
+
+
Unicode BOM character; external form depends on the encoding.
+
+
+ + + +

V

+
+
ValidatingObjectInputStream - Class in org.apache.commons.io.serialization
+
+
An ObjectInputStream that's restricted to deserialize + a limited set of classes.
+
+
ValidatingObjectInputStream(InputStream) - Constructor for class org.apache.commons.io.serialization.ValidatingObjectInputStream
+
+
Constructs an object to deserialize the specified input stream.
+
+
valueOf(String) - Static method in enum org.apache.commons.io.IOCase
+
+
Returns the enum constant of this type with the specified name.
+
+
values() - Static method in enum org.apache.commons.io.IOCase
+
+
Returns an array containing the constants of this enum type, in +the order they are declared.
+
+
VISIBLE - Static variable in class org.apache.commons.io.filefilter.HiddenFileFilter
+
+
Singleton instance of visible filter
+
+
+ + + +

W

+
+
waitFor(File, int) - Static method in class org.apache.commons.io.FileUtils
+
+
Waits for NFS to propagate a file creation, imposing a timeout.
+
+
walk(File, Collection<T>) - Method in class org.apache.commons.io.DirectoryWalker
+
+
Internal method that walks the directory hierarchy in a depth-first manner.
+
+
WildcardFileFilter - Class in org.apache.commons.io.filefilter
+
+
Filters files using the supplied wildcards.
+
+
WildcardFileFilter(String) - Constructor for class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Construct a new case-sensitive wildcard filter for a single wildcard.
+
+
WildcardFileFilter(String, IOCase) - Constructor for class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Construct a new wildcard filter for a single wildcard specifying case-sensitivity.
+
+
WildcardFileFilter(String[]) - Constructor for class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Construct a new case-sensitive wildcard filter for an array of wildcards.
+
+
WildcardFileFilter(String[], IOCase) - Constructor for class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Construct a new wildcard filter for an array of wildcards specifying case-sensitivity.
+
+
WildcardFileFilter(List<String>) - Constructor for class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Construct a new case-sensitive wildcard filter for a list of wildcards.
+
+
WildcardFileFilter(List<String>, IOCase) - Constructor for class org.apache.commons.io.filefilter.WildcardFileFilter
+
+
Construct a new wildcard filter for a list of wildcards specifying case-sensitivity.
+
+
WildcardFilter - Class in org.apache.commons.io.filefilter
+
+
Deprecated. +
Use WilcardFileFilter. Deprecated as this class performs directory + filtering which it shouldn't do, but that can't be removed due to compatability.
+
+
+
WildcardFilter(String) - Constructor for class org.apache.commons.io.filefilter.WildcardFilter
+
+
Deprecated.
+
Construct a new case-sensitive wildcard filter for a single wildcard.
+
+
WildcardFilter(String[]) - Constructor for class org.apache.commons.io.filefilter.WildcardFilter
+
+
Deprecated.
+
Construct a new case-sensitive wildcard filter for an array of wildcards.
+
+
WildcardFilter(List<String>) - Constructor for class org.apache.commons.io.filefilter.WildcardFilter
+
+
Deprecated.
+
Construct a new case-sensitive wildcard filter for a list of wildcards.
+
+
wildcardMatch(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks a filename to see if it matches the specified wildcard matcher, + always testing case-sensitive.
+
+
wildcardMatch(String, String, IOCase) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks a filename to see if it matches the specified wildcard matcher + allowing control over case-sensitivity.
+
+
wildcardMatchOnSystem(String, String) - Static method in class org.apache.commons.io.FilenameUtils
+
+
Checks a filename to see if it matches the specified wildcard matcher + using the case rules of the system.
+
+
WindowsLineEndingInputStream - Class in org.apache.commons.io.input
+
+
A filtering input stream that ensures the content will have windows line endings, CRLF.
+
+
WindowsLineEndingInputStream(InputStream, boolean) - Constructor for class org.apache.commons.io.input.WindowsLineEndingInputStream
+
+
Create an input stream that filters another stream
+
+
write(File, CharSequence) - Static method in class org.apache.commons.io.FileUtils
+
+
Deprecated. + +
+
+
write(File, CharSequence, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+ +
+
write(File, CharSequence, Charset) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a CharSequence to a file creating the file if it does not exist.
+
+
write(File, CharSequence, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a CharSequence to a file creating the file if it does not exist.
+
+
write(File, CharSequence, Charset, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a CharSequence to a file creating the file if it does not exist.
+
+
write(File, CharSequence, String, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a CharSequence to a file creating the file if it does not exist.
+
+
write(byte[], OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes bytes from a byte[] to an OutputStream.
+
+
write(byte[], Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
write(byte[], Writer, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes bytes from a byte[] to chars on a Writer + using the specified character encoding.
+
+
write(byte[], Writer, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes bytes from a byte[] to chars on a Writer + using the specified character encoding.
+
+
write(char[], Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a char[] to a Writer
+
+
write(char[], OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
write(char[], OutputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a char[] to bytes on an + OutputStream using the specified character encoding.
+
+
write(char[], OutputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a char[] to bytes on an + OutputStream using the specified character encoding.
+
+
write(CharSequence, Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a CharSequence to a Writer.
+
+
write(CharSequence, OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+ +
+
write(CharSequence, OutputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a CharSequence to bytes on an + OutputStream using the specified character encoding.
+
+
write(CharSequence, OutputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a CharSequence to bytes on an + OutputStream using the specified character encoding.
+
+
write(String, Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a String to a Writer.
+
+
write(String, OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. + +
+
+
write(String, OutputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a String to bytes on an + OutputStream using the specified character encoding.
+
+
write(String, OutputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a String to bytes on an + OutputStream using the specified character encoding.
+
+
write(StringBuffer, Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. +
replaced by write(CharSequence, Writer)
+
+
+
write(StringBuffer, OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. +
replaced by write(CharSequence, OutputStream)
+
+
+
write(StringBuffer, OutputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Deprecated. +
replaced by write(CharSequence, OutputStream, String)
+
+
+
write(int) - Method in class org.apache.commons.io.output.AppendableOutputStream
+
+
Write a character to the underlying appendable.
+
+
write(int) - Method in class org.apache.commons.io.output.BrokenOutputStream
+
+
Throws the configured exception.
+
+
write(byte[], int, int) - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Write the bytes to byte array.
+
+
write(int) - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Write a byte to byte array.
+
+
write(InputStream) - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Writes the entire contents of the specified input stream to this + byte stream.
+
+
write(byte[], int, int) - Method in class org.apache.commons.io.output.ChunkedOutputStream
+
+
Writes the data buffer in chunks to the underlying stream
+
+
write(char[], int, int) - Method in class org.apache.commons.io.output.ChunkedWriter
+
+
writes the data buffer in chunks to the underlying writer
+
+
write(int) - Method in class org.apache.commons.io.output.ClosedOutputStream
+
+
Throws an IOException to indicate that the stream is closed.
+
+
write(int) - Method in class org.apache.commons.io.output.DemuxOutputStream
+
+
Writes byte to stream associated with current thread.
+
+
write(int) - Method in class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Write a character.
+
+
write(char[]) - Method in class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Write the characters from an array.
+
+
write(char[], int, int) - Method in class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Write the specified characters from an array.
+
+
write(String) - Method in class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Write the characters from a string.
+
+
write(String, int, int) - Method in class org.apache.commons.io.output.FileWriterWithEncoding
+
+
Write the specified characters from a string.
+
+
write(int) - Method in class org.apache.commons.io.output.LockableFileWriter
+
+
Write a character.
+
+
write(char[]) - Method in class org.apache.commons.io.output.LockableFileWriter
+
+
Write the characters from an array.
+
+
write(char[], int, int) - Method in class org.apache.commons.io.output.LockableFileWriter
+
+
Write the specified characters from an array.
+
+
write(String) - Method in class org.apache.commons.io.output.LockableFileWriter
+
+
Write the characters from a string.
+
+
write(String, int, int) - Method in class org.apache.commons.io.output.LockableFileWriter
+
+
Write the specified characters from a string.
+
+
write(byte[], int, int) - Method in class org.apache.commons.io.output.NullOutputStream
+
+
Does nothing - output to /dev/null.
+
+
write(int) - Method in class org.apache.commons.io.output.NullOutputStream
+
+
Does nothing - output to /dev/null.
+
+
write(byte[]) - Method in class org.apache.commons.io.output.NullOutputStream
+
+
Does nothing - output to /dev/null.
+
+
write(int) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
write(char[]) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
write(char[], int, int) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
write(String) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
write(String, int, int) - Method in class org.apache.commons.io.output.NullWriter
+
+
Does nothing - output to /dev/null.
+
+
write(int) - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Invokes the delegate's write(int) method.
+
+
write(byte[]) - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Invokes the delegate's write(byte[]) method.
+
+
write(byte[], int, int) - Method in class org.apache.commons.io.output.ProxyOutputStream
+
+
Invokes the delegate's write(byte[]) method.
+
+
write(int) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's write(int) method.
+
+
write(char[]) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's write(char[]) method.
+
+
write(char[], int, int) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's write(char[], int, int) method.
+
+
write(String) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's write(String) method.
+
+
write(String, int, int) - Method in class org.apache.commons.io.output.ProxyWriter
+
+
Invokes the delegate's write(String) method.
+
+
write(String) - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Writes a String to the StringBuilder.
+
+
write(char[], int, int) - Method in class org.apache.commons.io.output.StringBuilderWriter
+
+
Writes a portion of a character array to the StringBuilder.
+
+
write(byte[]) - Method in class org.apache.commons.io.output.TeeOutputStream
+
+
Write the bytes to both streams.
+
+
write(byte[], int, int) - Method in class org.apache.commons.io.output.TeeOutputStream
+
+
Write the specified bytes to both streams.
+
+
write(int) - Method in class org.apache.commons.io.output.TeeOutputStream
+
+
Write a byte to both streams.
+
+
write(int) - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Writes the specified byte to this output stream.
+
+
write(byte[]) - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Writes b.length bytes from the specified byte array to this + output stream.
+
+
write(byte[], int, int) - Method in class org.apache.commons.io.output.ThresholdingOutputStream
+
+
Writes len bytes from the specified byte array starting at + offset off to this output stream.
+
+
write(byte[], int, int) - Method in class org.apache.commons.io.output.WriterOutputStream
+
+
Write bytes from the specified byte array to the stream.
+
+
write(byte[]) - Method in class org.apache.commons.io.output.WriterOutputStream
+
+
Write bytes from the specified byte array to the stream.
+
+
write(int) - Method in class org.apache.commons.io.output.WriterOutputStream
+
+
Write a single byte to the stream.
+
+
write(char[], int, int) - Method in class org.apache.commons.io.output.XmlStreamWriter
+
+
Write the characters to the underlying writer, detecing encoding.
+
+
writeByteArrayToFile(File, byte[]) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a byte array to a file creating the file if it does not exist.
+
+
writeByteArrayToFile(File, byte[], boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a byte array to a file creating the file if it does not exist.
+
+
writeByteArrayToFile(File, byte[], int, int) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes len bytes from the specified byte array starting + at offset off to a file, creating the file if it does + not exist.
+
+
writeByteArrayToFile(File, byte[], int, int, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes len bytes from the specified byte array starting + at offset off to a file, creating the file if it does + not exist.
+
+
writeChunked(byte[], OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes bytes from a byte[] to an OutputStream using chunked writes.
+
+
writeChunked(char[], Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes chars from a char[] to a Writer using chunked writes.
+
+
writeLines(File, String, Collection<?>) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line.
+
+
writeLines(File, String, Collection<?>, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line, optionally appending.
+
+
writeLines(File, Collection<?>) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line.
+
+
writeLines(File, Collection<?>, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line.
+
+
writeLines(File, String, Collection<?>, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line.
+
+
writeLines(File, String, Collection<?>, String, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line.
+
+
writeLines(File, Collection<?>, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line.
+
+
writeLines(File, Collection<?>, String, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes the toString() value of each item in a collection to + the specified File line by line.
+
+
writeLines(Collection<?>, String, OutputStream) - Static method in class org.apache.commons.io.IOUtils
+
+ +
+
writeLines(Collection<?>, String, OutputStream, Charset) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes the toString() value of each item in a collection to + an OutputStream line by line, using the specified character + encoding and the specified line ending.
+
+
writeLines(Collection<?>, String, OutputStream, String) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes the toString() value of each item in a collection to + an OutputStream line by line, using the specified character + encoding and the specified line ending.
+
+
writeLines(Collection<?>, String, Writer) - Static method in class org.apache.commons.io.IOUtils
+
+
Writes the toString() value of each item in a collection to + a Writer line by line, using the specified line ending.
+
+
WriterOutputStream - Class in org.apache.commons.io.output
+
+
OutputStream implementation that transforms a byte stream to a + character stream using a specified charset encoding and writes the resulting + stream to a Writer.
+
+
WriterOutputStream(Writer, CharsetDecoder) - Constructor for class org.apache.commons.io.output.WriterOutputStream
+
+
Constructs a new WriterOutputStream with a default output buffer size of + 1024 characters.
+
+
WriterOutputStream(Writer, CharsetDecoder, int, boolean) - Constructor for class org.apache.commons.io.output.WriterOutputStream
+
+
Constructs a new WriterOutputStream.
+
+
WriterOutputStream(Writer, Charset, int, boolean) - Constructor for class org.apache.commons.io.output.WriterOutputStream
+
+
Constructs a new WriterOutputStream.
+
+
WriterOutputStream(Writer, Charset) - Constructor for class org.apache.commons.io.output.WriterOutputStream
+
+
Constructs a new WriterOutputStream with a default output buffer size of + 1024 characters.
+
+
WriterOutputStream(Writer, String, int, boolean) - Constructor for class org.apache.commons.io.output.WriterOutputStream
+
+
Constructs a new WriterOutputStream.
+
+
WriterOutputStream(Writer, String) - Constructor for class org.apache.commons.io.output.WriterOutputStream
+
+
Constructs a new WriterOutputStream with a default output buffer size of + 1024 characters.
+
+
WriterOutputStream(Writer) - Constructor for class org.apache.commons.io.output.WriterOutputStream
+
+ +
+
writeStringToFile(File, String, Charset) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a String to a file creating the file if it does not exist.
+
+
writeStringToFile(File, String, String) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a String to a file creating the file if it does not exist.
+
+
writeStringToFile(File, String, Charset, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a String to a file creating the file if it does not exist.
+
+
writeStringToFile(File, String, String, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+
Writes a String to a file creating the file if it does not exist.
+
+
writeStringToFile(File, String) - Static method in class org.apache.commons.io.FileUtils
+
+ +
+
writeStringToFile(File, String, boolean) - Static method in class org.apache.commons.io.FileUtils
+
+ +
+
writeSwappedDouble(byte[], int, double) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "double" value to a byte array at a given offset.
+
+
writeSwappedDouble(OutputStream, double) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "double" value to an OutputStream.
+
+
writeSwappedFloat(byte[], int, float) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "float" value to a byte array at a given offset.
+
+
writeSwappedFloat(OutputStream, float) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "float" value to an OutputStream.
+
+
writeSwappedInteger(byte[], int, int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "int" value to a byte array at a given offset.
+
+
writeSwappedInteger(OutputStream, int) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "int" value to an OutputStream.
+
+
writeSwappedLong(byte[], int, long) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "long" value to a byte array at a given offset.
+
+
writeSwappedLong(OutputStream, long) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "long" value to an OutputStream.
+
+
writeSwappedShort(byte[], int, short) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "short" value to a byte array at a given offset.
+
+
writeSwappedShort(OutputStream, short) - Static method in class org.apache.commons.io.EndianUtils
+
+
Writes a "short" value to an OutputStream.
+
+
writeTo(OutputStream) - Method in class org.apache.commons.io.output.ByteArrayOutputStream
+
+
Writes the entire contents of this byte stream to the + specified output stream.
+
+
writeTo(OutputStream) - Method in class org.apache.commons.io.output.DeferredFileOutputStream
+
+
Writes the data from this output stream to the specified output stream, + after it has been closed.
+
+
+ + + +

X

+
+
XmlStreamReader - Class in org.apache.commons.io.input
+
+
Character stream that handles all the necessary Voodo to figure out the + charset encoding of the XML document within the stream.
+
+
XmlStreamReader(File) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader for a File.
+
+
XmlStreamReader(InputStream) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader for a raw InputStream.
+
+
XmlStreamReader(InputStream, boolean) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader for a raw InputStream.
+
+
XmlStreamReader(InputStream, boolean, String) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader for a raw InputStream.
+
+
XmlStreamReader(URL) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader using the InputStream of a URL.
+
+
XmlStreamReader(URLConnection, String) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader using the InputStream of a URLConnection.
+
+
XmlStreamReader(InputStream, String) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader using an InputStream an the associated content-type + header.
+
+
XmlStreamReader(InputStream, String, boolean, String) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader using an InputStream an the associated content-type + header.
+
+
XmlStreamReader(InputStream, String, boolean) - Constructor for class org.apache.commons.io.input.XmlStreamReader
+
+
Creates a Reader using an InputStream an the associated content-type + header.
+
+
XmlStreamReaderException - Exception in org.apache.commons.io.input
+
+
The XmlStreamReaderException is thrown by the XmlStreamReader constructors if + the charset encoding can not be determined according to the XML 1.0 + specification and RFC 3023.
+
+
XmlStreamReaderException(String, String, String, String) - Constructor for exception org.apache.commons.io.input.XmlStreamReaderException
+
+
Creates an exception instance if the charset encoding could not be + determined.
+
+
XmlStreamReaderException(String, String, String, String, String, String) - Constructor for exception org.apache.commons.io.input.XmlStreamReaderException
+
+
Creates an exception instance if the charset encoding could not be + determined.
+
+
XmlStreamWriter - Class in org.apache.commons.io.output
+
+
Character stream that handles all the necessary Voodo to figure out the + charset encoding of the XML document written to the stream.
+
+
XmlStreamWriter(OutputStream) - Constructor for class org.apache.commons.io.output.XmlStreamWriter
+
+
Construct an new XML stream writer for the specified output stream + with a default encoding of UTF-8.
+
+
XmlStreamWriter(OutputStream, String) - Constructor for class org.apache.commons.io.output.XmlStreamWriter
+
+
Construct an new XML stream writer for the specified output stream + with the specified default encoding.
+
+
XmlStreamWriter(File) - Constructor for class org.apache.commons.io.output.XmlStreamWriter
+
+
Construct an new XML stream writer for the specified file + with a default encoding of UTF-8.
+
+
XmlStreamWriter(File, String) - Constructor for class org.apache.commons.io.output.XmlStreamWriter
+
+
Construct an new XML stream writer for the specified file + with the specified default encoding.
+
+
+A B C D E F G H I L M N O P R S T U V W X 
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index.html" index 20fee739663c38baeee58f30768a0baf0999b714..5129b83ca1a6f36398508a62e3d38fbfb066116b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/index.html" @@ -1,3 +1,74 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb75f9e0cb80e628217334cabbb0a4e15bac75e207aeff38271ab6dd17596540 -size 2854 + + + + + +Apache Commons IO 2.5 API + + + + + + + + + +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<h2>Frame Alert</h2> +<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/ByteOrderMark.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/ByteOrderMark.html" index b06b653693f6a2e0497807e4262dafeb0c82a23d..3c8d61b696491e2ef64d9a17f06e4e7da1e19b25 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/ByteOrderMark.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/ByteOrderMark.html" @@ -1,3 +1,527 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cd93b48fb2492f2155c4370db6ef0ee10a467a63dd49655b87c95ae3a7b01eda -size 24081 + + + + + +ByteOrderMark (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class ByteOrderMark

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        UTF_8

        +
        public static final ByteOrderMark UTF_8
        +
        UTF-8 BOM
        +
      • +
      + + + +
        +
      • +

        UTF_16BE

        +
        public static final ByteOrderMark UTF_16BE
        +
        UTF-16BE BOM (Big-Endian)
        +
      • +
      + + + +
        +
      • +

        UTF_16LE

        +
        public static final ByteOrderMark UTF_16LE
        +
        UTF-16LE BOM (Little-Endian)
        +
      • +
      + + + +
        +
      • +

        UTF_32BE

        +
        public static final ByteOrderMark UTF_32BE
        +
        UTF-32BE BOM (Big-Endian)
        +
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        UTF_32LE

        +
        public static final ByteOrderMark UTF_32LE
        +
        UTF-32LE BOM (Little-Endian)
        +
        Since:
        +
        2.2
        +
      • +
      + + + + +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ByteOrderMark

        +
        public ByteOrderMark(String charsetName,
        +             int... bytes)
        +
        Construct a new BOM.
        +
        Parameters:
        charsetName - The name of the charset the BOM represents
        bytes - The BOM's bytes
        +
        Throws:
        +
        IllegalArgumentException - if the charsetName is null or + zero length
        +
        IllegalArgumentException - if the bytes are null or zero + length
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getCharsetName

        +
        public String getCharsetName()
        +
        Return the name of the Charset the BOM represents.
        +
        Returns:
        the character set name
        +
      • +
      + + + +
        +
      • +

        length

        +
        public int length()
        +
        Return the length of the BOM's bytes.
        +
        Returns:
        the length of the BOM's bytes
        +
      • +
      + + + +
        +
      • +

        get

        +
        public int get(int pos)
        +
        The byte at the specified position.
        +
        Parameters:
        pos - The position
        +
        Returns:
        The specified byte
        +
      • +
      + + + +
        +
      • +

        getBytes

        +
        public byte[] getBytes()
        +
        Return a copy of the BOM's bytes.
        +
        Returns:
        a copy of the BOM's bytes
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public boolean equals(Object obj)
        +
        Indicates if this BOM's bytes equals another.
        +
        +
        Overrides:
        +
        equals in class Object
        +
        Parameters:
        obj - The object to compare to
        +
        Returns:
        true if the bom's bytes are equal, otherwise + false
        +
      • +
      + + + +
        +
      • +

        hashCode

        +
        public int hashCode()
        +
        Return the hashcode for this BOM.
        +
        +
        Overrides:
        +
        hashCode in class Object
        +
        Returns:
        the hashcode for this BOM.
        See Also:
        Object.hashCode()
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representation of the BOM.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        the length of the BOM's bytes
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/Charsets.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/Charsets.html" index 922114fe8a89dbdc97496997ad217a2905d41d39..6fb92d4f9856102e4db5a0b094a2f72bb6fb2dcd 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/Charsets.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/Charsets.html" @@ -1,3 +1,514 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e0f2268214ca52aec78227ee5f6b0bb0bd78d1793ca2e3805cc927c6a4a0e814 -size 28523 + + + + + +Charsets (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class Charsets

+
+
+ +
+
    +
  • +
    +
    +
    public class Charsets
    +extends Object
    +
    Charsets required of every implementation of the Java platform. + + From the Java documentation + Standard charsets: +

    + 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. +

    + +
      +
    • US-ASCII
      + Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set.
    • +
    • ISO-8859-1
      + ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1.
    • +
    • UTF-8
      + Eight-bit Unicode Transformation Format.
    • +
    • UTF-16BE
      + Sixteen-bit Unicode Transformation Format, big-endian byte order.
    • +
    • UTF-16LE
      + Sixteen-bit Unicode Transformation Format, little-endian byte order.
    • +
    • UTF-16
      + 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.)
    • +
    +
    Since:
    +
    2.3
    +
    Version:
    +
    $Id: Charsets.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
    See Also:
    Standard charsets
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        ISO_8859_1

        +
        @Deprecated
        +public static final Charset ISO_8859_1
        +
        Deprecated. Use Java 7's StandardCharsets
        +
        CharEncodingISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1. +

        + Every implementation of the Java platform is required to support this character encoding. +

        +
        See Also:
        Standard charsets
        +
      • +
      + + + +
        +
      • +

        US_ASCII

        +
        @Deprecated
        +public static final Charset US_ASCII
        +
        Deprecated. Use Java 7's StandardCharsets
        +

        + Seven-bit ASCII, also known as ISO646-US, also known as the Basic Latin block of the Unicode character set. +

        +

        + Every implementation of the Java platform is required to support this character encoding. +

        +
        See Also:
        Standard charsets
        +
      • +
      + + + +
        +
      • +

        UTF_16

        +
        @Deprecated
        +public static final Charset UTF_16
        +
        Deprecated. Use Java 7's StandardCharsets
        +

        + 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) +

        +

        + Every implementation of the Java platform is required to support this character encoding. +

        +
        See Also:
        Standard charsets
        +
      • +
      + + + +
        +
      • +

        UTF_16BE

        +
        @Deprecated
        +public static final Charset UTF_16BE
        +
        Deprecated. Use Java 7's StandardCharsets
        +

        + Sixteen-bit Unicode Transformation Format, big-endian byte order. +

        +

        + Every implementation of the Java platform is required to support this character encoding. +

        +
        See Also:
        Standard charsets
        +
      • +
      + + + +
        +
      • +

        UTF_16LE

        +
        @Deprecated
        +public static final Charset UTF_16LE
        +
        Deprecated. Use Java 7's StandardCharsets
        +

        + Sixteen-bit Unicode Transformation Format, little-endian byte order. +

        +

        + Every implementation of the Java platform is required to support this character encoding. +

        +
        See Also:
        Standard charsets
        +
      • +
      + + + +
        +
      • +

        UTF_8

        +
        @Deprecated
        +public static final Charset UTF_8
        +
        Deprecated. Use Java 7's StandardCharsets
        +

        + Eight-bit Unicode Transformation Format. +

        +

        + Every implementation of the Java platform is required to support this character encoding. +

        +
        See Also:
        Standard charsets
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Charsets

        +
        public Charsets()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        requiredCharsets

        +
        public static SortedMap<String,Charset> requiredCharsets()
        +
        Constructs a sorted map from canonical charset names to charset objects required of every implementation of the + Java platform. +

        + From the Java documentation + Standard charsets: +

        +
        Returns:
        An immutable, case-insensitive map from canonical charset names to charset objects.
        Since:
        +
        2.5
        +
        See Also:
        Charset.availableCharsets()
        +
      • +
      + + + +
        +
      • +

        toCharset

        +
        public static Charset toCharset(Charset charset)
        +
        Returns the given Charset or the default Charset if the given Charset is null.
        +
        Parameters:
        charset - A charset or null.
        +
        Returns:
        the given Charset or the default Charset if the given Charset is null
        +
      • +
      + + + +
        +
      • +

        toCharset

        +
        public static Charset toCharset(String charset)
        +
        Returns a Charset for the named charset. If the name is null, return the default Charset.
        +
        Parameters:
        charset - The name of the requested charset, may be null.
        +
        Returns:
        a Charset for the named charset
        +
        Throws:
        +
        UnsupportedCharsetException - If the named charset is unavailable
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/CopyUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/CopyUtils.html" index 8ac64c07a87818d5874c479aa53688bd7f5c5fa5..0790a26b5dd6f8f9f54adcabc22cc9386044dc2c 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/CopyUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/CopyUtils.html" @@ -1,3 +1,668 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:edb1fa8197a80b5d1dc2ede79a6c79b24a2e5f724062a277b259a414db68262d -size 43006 + + + + + +CopyUtils (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class CopyUtils

+
+
+ +
+
    +
  • +
    +
    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).
    +
    +
    +
    @Deprecated
    +public class CopyUtils
    +extends Object
    +
    This class provides static utility methods for buffered + copying between sources (InputStream, Reader, + String and byte[]) and destinations + (OutputStream, Writer, String and + byte[]). +

    + Unless otherwise noted, these copy methods do not + 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' close() 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 + this + UnixReview article. +

    + For byte-to-char methods, a copy 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. +

    + We don't provide special variants for the copy 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. +

    + The copy methods use an internal buffer when copying. It is + therefore advisable not to deliberately wrap the stream arguments + to the copy methods in Buffered* streams. For + example, don't do the following: +

    +  copy( new BufferedInputStream( in ), new BufferedOutputStream( out ) );
    +  
    + The rationale is as follows: +

    + 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 + InputStream.read(byte[] b, int off, int len) requests on the + underlying InputStream, to fill an internal buffer, from which further + read requests can inexpensively get their data (until the buffer + runs out). +

    + However, the copy methods do the same thing, keeping an + internal buffer, populated by + 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). +

    + Behold, intrepid explorers; a map of this class: +

    +       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)
    + 
    +

    + 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. +

    + Origin of code: Excalibur.

    +
    Version:
    +
    $Id: CopyUtils.java 1680650 2015-05-20 18:36:40Z britter $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CopyUtils

        +
        public CopyUtils()
        +
        Deprecated. 
        +
        Instances should NOT be constructed in standard programming.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        copy

        +
        public static void copy(byte[] input,
        +        OutputStream output)
        +                 throws IOException
        +
        Deprecated. 
        +
        Copy bytes from a byte[] to an OutputStream.
        +
        Parameters:
        input - the byte array to read from
        output - the OutputStream to write to
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        @Deprecated
        +public static void copy(byte[] input,
        +                   Writer output)
        +                 throws IOException
        +
        Deprecated. 2.5 use copy(byte[], Writer, String) instead
        +
        Copy and convert bytes from a byte[] to chars on a + Writer. + The platform's default encoding is used for the byte-to-char conversion.
        +
        Parameters:
        input - the byte array to read from
        output - the Writer to write to
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(byte[] input,
        +        Writer output,
        +        String encoding)
        +                 throws IOException
        +
        Deprecated. 
        +
        Copy and convert bytes from a byte[] to chars on a + Writer, using the specified encoding.
        +
        Parameters:
        input - the byte array to read from
        output - the Writer to write to
        encoding - The name of a supported character encoding. See the + IANA + Charset Registry for a list of valid encoding types.
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static int copy(InputStream input,
        +       OutputStream output)
        +                throws IOException
        +
        Deprecated. 
        +
        Copy bytes from an InputStream to an + OutputStream.
        +
        Parameters:
        input - the InputStream to read from
        output - the OutputStream to write to
        +
        Returns:
        the number of bytes copied
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static int copy(Reader input,
        +       Writer output)
        +                throws IOException
        +
        Deprecated. 
        +
        Copy chars from a Reader to a Writer.
        +
        Parameters:
        input - the Reader to read from
        output - the Writer to write to
        +
        Returns:
        the number of characters copied
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        @Deprecated
        +public static void copy(InputStream input,
        +                   Writer output)
        +                 throws IOException
        +
        Deprecated. 2.5 use copy(InputStream, Writer, String) instead
        +
        Copy and convert bytes from an InputStream to chars on a + Writer. + The platform's default encoding is used for the byte-to-char conversion.
        +
        Parameters:
        input - the InputStream to read from
        output - the Writer to write to
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(InputStream input,
        +        Writer output,
        +        String encoding)
        +                 throws IOException
        +
        Deprecated. 
        +
        Copy and convert bytes from an InputStream to chars on a + Writer, using the specified encoding.
        +
        Parameters:
        input - the InputStream to read from
        output - the Writer to write to
        encoding - The name of a supported character encoding. See the + IANA + Charset Registry for a list of valid encoding types.
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        @Deprecated
        +public static void copy(Reader input,
        +                   OutputStream output)
        +                 throws IOException
        +
        Deprecated. 2.5 use copy(Reader, OutputStream, String) instead
        +
        Serialize chars from a Reader to bytes on an + OutputStream, and flush the OutputStream. + Uses the default platform encoding.
        +
        Parameters:
        input - the Reader to read from
        output - the OutputStream to write to
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(Reader input,
        +        OutputStream output,
        +        String encoding)
        +                 throws IOException
        +
        Deprecated. 
        +
        Serialize chars from a Reader to bytes on an + OutputStream, and flush the OutputStream.
        +
        Parameters:
        input - the Reader to read from
        output - the OutputStream to write to
        encoding - The name of a supported character encoding. See the + IANA + Charset Registry for a list of valid encoding types.
        +
        Throws:
        +
        IOException - In case of an I/O problem
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        copy

        +
        @Deprecated
        +public static void copy(String input,
        +                   OutputStream output)
        +                 throws IOException
        +
        Deprecated. 2.5 use copy(String, OutputStream, String) instead
        +
        Serialize chars from a String to bytes on an + OutputStream, and + flush the OutputStream. + Uses the platform default encoding.
        +
        Parameters:
        input - the String to read from
        output - the OutputStream to write to
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(String input,
        +        OutputStream output,
        +        String encoding)
        +                 throws IOException
        +
        Deprecated. 
        +
        Serialize chars from a String to bytes on an + OutputStream, and + flush the OutputStream.
        +
        Parameters:
        input - the String to read from
        output - the OutputStream to write to
        encoding - The name of a supported character encoding. See the + IANA + Charset Registry for a list of valid encoding types.
        +
        Throws:
        +
        IOException - In case of an I/O problem
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(String input,
        +        Writer output)
        +                 throws IOException
        +
        Deprecated. 
        +
        Copy chars from a String to a Writer.
        +
        Parameters:
        input - the String to read from
        output - the Writer to write to
        +
        Throws:
        +
        IOException - In case of an I/O problem
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.CancelException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.CancelException.html" index 25a418435fbae2ca986497900f4314b19546e05e..65fe06a29b3775c787d2e7f7066d88d94e5f36f0 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.CancelException.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.CancelException.html" @@ -1,3 +1,342 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0e5e1e5b66782e946e7e8d583877296da5e3cf9351db70ad670014f2ea62750b -size 18434 + + + + + +DirectoryWalker.CancelException (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class DirectoryWalker.CancelException

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable
    +
    +
    +
    Enclosing class:
    +
    DirectoryWalker<T>
    +
    +
    +
    +
    public static class DirectoryWalker.CancelException
    +extends IOException
    +
    CancelException is thrown in DirectoryWalker to cancel the current + processing.
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DirectoryWalker.CancelException

        +
        public DirectoryWalker.CancelException(File file,
        +                               int depth)
        +
        Constructs a CancelException with + the file and depth when cancellation occurred.
        +
        Parameters:
        file - the file when the operation was cancelled, may be null
        depth - the depth when the operation was cancelled, may be null
        +
      • +
      + + + +
        +
      • +

        DirectoryWalker.CancelException

        +
        public DirectoryWalker.CancelException(String message,
        +                               File file,
        +                               int depth)
        +
        Constructs a CancelException with + an appropriate message and the file and depth when + cancellation occurred.
        +
        Parameters:
        message - the detail message
        file - the file when the operation was cancelled
        depth - the depth when the operation was cancelled
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getFile

        +
        public File getFile()
        +
        Return the file when the operation was cancelled.
        +
        Returns:
        the file when the operation was cancelled
        +
      • +
      + + + +
        +
      • +

        getDepth

        +
        public int getDepth()
        +
        Return the depth when the operation was cancelled.
        +
        Returns:
        the depth when the operation was cancelled
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.html" index 64d846078c219b0c25acd16e780231968c9c0d5b..a288132830b2f8fa22aa4bccbbadee4fd73bcef1 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/DirectoryWalker.html" @@ -1,3 +1,897 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4448811beb270ccefffb8fa341c2f7d5dd3ff70a80926915a2cc84510f84e780 -size 56834 + + + + + +DirectoryWalker (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class DirectoryWalker<T>

+
+
+ +
+
    +
  • +
    +
    +
    public abstract class DirectoryWalker<T>
    +extends Object
    +
    Abstract class that walks through a directory hierarchy and provides + subclasses with convenient hooks to add specific behaviour. +

    + This class operates with a FileFilter and maximum depth to + limit the files and direcories visited. + Commons IO supplies many common filter implementations in the + filefilter package. +

    + The following sections describe: +

    + + +

    1. Example Implementation

    + + There are many possible extensions, for example, to delete all + files and '.svn' directories, and return a list of deleted files: +
    +  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);
    +    }
    +  }
    + 
    + + +

    2. Filter Example

    + + 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. +

    + The first option is to visit all directories and files. + This is achieved via the no-args constructor. +

    + The second constructor option is to supply a single 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. +

    + For example, if you wanted all directories which are not hidden + and files which end in ".txt": +

    +  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);
    + 
    +

    + The third constructor option is to specify separate filters, one for + directories and one for files. These are combined internally to form + the correct FileFilter, something which is very easy to + get wrong when attempted manually, particularly when trying to + express constructs like 'any file in directories named docs'. +

    + For example, if you wanted all directories which are not hidden + and files which end in ".txt": +

    +  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"),
    +  );
    + 
    + This is much simpler than the previous example, and is why it is the preferred + option for filtering. + + +

    3. Cancellation

    + + The DirectoryWalker contains some of the logic required for cancel processing. + Subclasses must complete the implementation. +

    + What DirectoryWalker does provide for cancellation is: +

    +

    + Implementations need to provide: +

      +
    • The decision logic on whether to cancel processing or not.
    • +
    • Constructing and throwing a DirectoryWalker.CancelException.
    • +
    • Custom cancel processing in the handleCancelled() method. +
    +

    + Two possible scenarios are envisaged for cancellation: +

      +
    • 3.1 External / Mult-threaded - cancellation being + decided/initiated by an external process.
    • +
    • 3.2 Internal - cancellation being decided/initiated + from within a DirectoryWalker implementation.
    • +
    +

    + The following sections provide example implementations for these two different + scenarios. + + +

    3.1 External / Multi-threaded

    + + This example provides a public cancel() 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 + + volatile flag to ensure it will work properly in a multi-threaded environment. + The flag is returned by the handleIsCancelled() method, which + will cause the walk to stop immediately. The handleCancelled() + method will be the next, and last, callback method received once cancellation + has occurred. + +
    +  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
    +    }
    +  }
    + 
    + + +

    3.2 Internal

    + + This shows an example of how internal cancellation processing could be implemented. + Note the decision logic and throwing a DirectoryWalker.CancelException could be implemented + in any of the lifecycle methods. + +
    +  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
    +    }
    +  }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: DirectoryWalker.java 1723627 2016-01-07 21:15:47Z niallp $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DirectoryWalker

        +
        protected DirectoryWalker()
        +
        Construct an instance with no filtering and unlimited depth.
        +
      • +
      + + + +
        +
      • +

        DirectoryWalker

        +
        protected DirectoryWalker(FileFilter filter,
        +               int depthLimit)
        +
        Construct an instance with a filter and limit the depth navigated to. +

        + The filter controls which files and directories will be navigated to as + part of the walk. The FileFilterUtils class is useful for combining + various filters together. A null filter means that no + filtering should occur and all files and directories will be visited.

        +
        Parameters:
        filter - the filter to apply, null means visit all files
        depthLimit - controls how deep the hierarchy is + navigated to (less than 0 means unlimited)
        +
      • +
      + + + +
        +
      • +

        DirectoryWalker

        +
        protected DirectoryWalker(IOFileFilter directoryFilter,
        +               IOFileFilter fileFilter,
        +               int depthLimit)
        +
        Construct an instance with a directory and a file filter and an optional + limit on the depth navigated to. +

        + The filters control which files and directories will be navigated to as part + of the walk. This constructor uses FileFilterUtils.makeDirectoryOnly(IOFileFilter) + and FileFilterUtils.makeFileOnly(IOFileFilter) internally to combine the filters. + A null filter means that no filtering should occur.

        +
        Parameters:
        directoryFilter - the filter to apply to directories, null means visit all directories
        fileFilter - the filter to apply to files, null means visit all files
        depthLimit - controls how deep the hierarchy is + navigated to (less than 0 means unlimited)
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        walk

        +
        protected final void walk(File startDirectory,
        +        Collection<T> results)
        +                   throws IOException
        +
        Internal method that walks the directory hierarchy in a depth-first manner. +

        + 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. +

        + 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 handle.

        +
        Parameters:
        startDirectory - the directory to start from, not null
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        NullPointerException - if the start directory is null
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        checkIfCancelled

        +
        protected final void checkIfCancelled(File file,
        +                    int depth,
        +                    Collection<T> results)
        +                               throws IOException
        +
        Checks whether the walk has been cancelled by calling handleIsCancelled(java.io.File, int, java.util.Collection<T>), + throwing a CancelException if it has. +

        + 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 handleFile(java.io.File, int, java.util.Collection<T>), may take a long time to run. In that case, + you may wish to check for cancellation by calling this method.

        +
        Parameters:
        file - the current file being processed
        depth - the current file level (starting directory = 0)
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleIsCancelled

        +
        protected boolean handleIsCancelled(File file,
        +                        int depth,
        +                        Collection<T> results)
        +                             throws IOException
        +
        Overridable callback method invoked to determine if the entire walk + operation should be immediately cancelled. +

        + This method should be implemented by those subclasses that want to + provide a public cancel() method available from another + thread. The design pattern for the subclass should be as follows: +

        +  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
        +    }
        +  }
        + 
        +

        + If this method returns true, then the directory walk is immediately + cancelled. The next callback method will be handleCancelled(java.io.File, java.util.Collection<T>, org.apache.commons.io.DirectoryWalker.CancelException). +

        + This implementation returns false.

        +
        Parameters:
        file - the file or directory being processed
        depth - the current directory level (starting directory = 0)
        results - the collection of result objects, may be updated
        +
        Returns:
        true if the walk has been cancelled
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleCancelled

        +
        protected void handleCancelled(File startDirectory,
        +                   Collection<T> results,
        +                   DirectoryWalker.CancelException cancel)
        +                        throws IOException
        +
        Overridable callback method invoked when the operation is cancelled. + The file being processed when the cancellation occurred can be + obtained from the exception. +

        + This implementation just re-throws the DirectoryWalker.CancelException.

        +
        Parameters:
        startDirectory - the directory that the walk started from
        results - the collection of result objects, may be updated
        cancel - the exception throw to cancel further processing + containing details at the point of cancellation.
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleStart

        +
        protected void handleStart(File startDirectory,
        +               Collection<T> results)
        +                    throws IOException
        +
        Overridable callback method invoked at the start of processing. +

        + This implementation does nothing.

        +
        Parameters:
        startDirectory - the directory to start from
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleDirectory

        +
        protected boolean handleDirectory(File directory,
        +                      int depth,
        +                      Collection<T> results)
        +                           throws IOException
        +
        Overridable callback method invoked to determine if a directory should be processed. +

        + 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. +

        + This implementation does nothing and returns true.

        +
        Parameters:
        directory - the current directory being processed
        depth - the current directory level (starting directory = 0)
        results - the collection of result objects, may be updated
        +
        Returns:
        true to process this directory, false to skip this directory
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleDirectoryStart

        +
        protected void handleDirectoryStart(File directory,
        +                        int depth,
        +                        Collection<T> results)
        +                             throws IOException
        +
        Overridable callback method invoked at the start of processing each directory. +

        + This implementation does nothing.

        +
        Parameters:
        directory - the current directory being processed
        depth - the current directory level (starting directory = 0)
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        filterDirectoryContents

        +
        protected File[] filterDirectoryContents(File directory,
        +                             int depth,
        +                             File[] files)
        +                                  throws IOException
        +
        Overridable callback method invoked with the contents of each directory. +

        + This implementation returns the files unchanged

        +
        Parameters:
        directory - the current directory being processed
        depth - the current directory level (starting directory = 0)
        files - the files (possibly filtered) in the directory, may be null
        +
        Returns:
        the filtered list of files
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        handleFile

        +
        protected void handleFile(File file,
        +              int depth,
        +              Collection<T> results)
        +                   throws IOException
        +
        Overridable callback method invoked for each (non-directory) file. +

        + This implementation does nothing.

        +
        Parameters:
        file - the current file being processed
        depth - the current directory level (starting directory = 0)
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleRestricted

        +
        protected void handleRestricted(File directory,
        +                    int depth,
        +                    Collection<T> results)
        +                         throws IOException
        +
        Overridable callback method invoked for each restricted directory. +

        + This implementation does nothing.

        +
        Parameters:
        directory - the restricted directory
        depth - the current directory level (starting directory = 0)
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleDirectoryEnd

        +
        protected void handleDirectoryEnd(File directory,
        +                      int depth,
        +                      Collection<T> results)
        +                           throws IOException
        +
        Overridable callback method invoked at the end of processing each directory. +

        + This implementation does nothing.

        +
        Parameters:
        directory - the directory being processed
        depth - the current directory level (starting directory = 0)
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      + + + +
        +
      • +

        handleEnd

        +
        protected void handleEnd(Collection<T> results)
        +                  throws IOException
        +
        Overridable callback method invoked at the end of processing. +

        + This implementation does nothing.

        +
        Parameters:
        results - the collection of result objects, may be updated
        +
        Throws:
        +
        IOException - if an I/O Error occurs
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/EndianUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/EndianUtils.html" index 447ef3052e891e630aa5456001e9775addabff96..33dd4e51a59909fc19fb516c34ec09f2acc173b8 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/EndianUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/EndianUtils.html" @@ -1,3 +1,879 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3302829f255f9c40d2143683c811403062ec9eb17073a13a642866e494270815 -size 47265 + + + + + +EndianUtils (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class EndianUtils

+
+
+ +
+
    +
  • +
    +
    +
    public class EndianUtils
    +extends Object
    +
    Utility code for dealing with different endian systems. +

    + 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. +

    + Origin of code: Excalibur

    +
    Version:
    +
    $Id: EndianUtils.java 1686450 2015-06-19 16:43:48Z krosenvold $
    +
    See Also:
    SwappedDataInputStream
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      EndianUtils() +
      Instances should NOT be constructed in standard programming.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      static doublereadSwappedDouble(byte[] data, + int offset) +
      Reads a "double" value from a byte array at a given offset.
      +
      static doublereadSwappedDouble(InputStream input) +
      Reads a "double" value from an InputStream.
      +
      static floatreadSwappedFloat(byte[] data, + int offset) +
      Reads a "float" value from a byte array at a given offset.
      +
      static floatreadSwappedFloat(InputStream input) +
      Reads a "float" value from an InputStream.
      +
      static intreadSwappedInteger(byte[] data, + int offset) +
      Reads a "int" value from a byte array at a given offset.
      +
      static intreadSwappedInteger(InputStream input) +
      Reads a "int" value from an InputStream.
      +
      static longreadSwappedLong(byte[] data, + int offset) +
      Reads a "long" value from a byte array at a given offset.
      +
      static longreadSwappedLong(InputStream input) +
      Reads a "long" value from an InputStream.
      +
      static shortreadSwappedShort(byte[] data, + int offset) +
      Reads a "short" value from a byte array at a given offset.
      +
      static shortreadSwappedShort(InputStream input) +
      Reads a "short" value from an InputStream.
      +
      static longreadSwappedUnsignedInteger(byte[] data, + int offset) +
      Reads an unsigned integer (32-bit) value from a byte array at a given + offset.
      +
      static longreadSwappedUnsignedInteger(InputStream input) +
      Reads a unsigned integer (32-bit) from an InputStream.
      +
      static intreadSwappedUnsignedShort(byte[] data, + int offset) +
      Reads an unsigned short (16-bit) value from a byte array at a given + offset.
      +
      static intreadSwappedUnsignedShort(InputStream input) +
      Reads a unsigned short (16-bit) from an InputStream.
      +
      static doubleswapDouble(double value) +
      Converts a "double" value between endian systems.
      +
      static floatswapFloat(float value) +
      Converts a "float" value between endian systems.
      +
      static intswapInteger(int value) +
      Converts a "int" value between endian systems.
      +
      static longswapLong(long value) +
      Converts a "long" value between endian systems.
      +
      static shortswapShort(short value) +
      Converts a "short" value between endian systems.
      +
      static voidwriteSwappedDouble(byte[] data, + int offset, + double value) +
      Writes a "double" value to a byte array at a given offset.
      +
      static voidwriteSwappedDouble(OutputStream output, + double value) +
      Writes a "double" value to an OutputStream.
      +
      static voidwriteSwappedFloat(byte[] data, + int offset, + float value) +
      Writes a "float" value to a byte array at a given offset.
      +
      static voidwriteSwappedFloat(OutputStream output, + float value) +
      Writes a "float" value to an OutputStream.
      +
      static voidwriteSwappedInteger(byte[] data, + int offset, + int value) +
      Writes a "int" value to a byte array at a given offset.
      +
      static voidwriteSwappedInteger(OutputStream output, + int value) +
      Writes a "int" value to an OutputStream.
      +
      static voidwriteSwappedLong(byte[] data, + int offset, + long value) +
      Writes a "long" value to a byte array at a given offset.
      +
      static voidwriteSwappedLong(OutputStream output, + long value) +
      Writes a "long" value to an OutputStream.
      +
      static voidwriteSwappedShort(byte[] data, + int offset, + short value) +
      Writes a "short" value to a byte array at a given offset.
      +
      static voidwriteSwappedShort(OutputStream output, + short value) +
      Writes a "short" value to an OutputStream.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        EndianUtils

        +
        public EndianUtils()
        +
        Instances should NOT be constructed in standard programming.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        swapShort

        +
        public static short swapShort(short value)
        +
        Converts a "short" value between endian systems.
        +
        Parameters:
        value - value to convert
        +
        Returns:
        the converted value
        +
      • +
      + + + +
        +
      • +

        swapInteger

        +
        public static int swapInteger(int value)
        +
        Converts a "int" value between endian systems.
        +
        Parameters:
        value - value to convert
        +
        Returns:
        the converted value
        +
      • +
      + + + +
        +
      • +

        swapLong

        +
        public static long swapLong(long value)
        +
        Converts a "long" value between endian systems.
        +
        Parameters:
        value - value to convert
        +
        Returns:
        the converted value
        +
      • +
      + + + +
        +
      • +

        swapFloat

        +
        public static float swapFloat(float value)
        +
        Converts a "float" value between endian systems.
        +
        Parameters:
        value - value to convert
        +
        Returns:
        the converted value
        +
      • +
      + + + +
        +
      • +

        swapDouble

        +
        public static double swapDouble(double value)
        +
        Converts a "double" value between endian systems.
        +
        Parameters:
        value - value to convert
        +
        Returns:
        the converted value
        +
      • +
      + + + +
        +
      • +

        writeSwappedShort

        +
        public static void writeSwappedShort(byte[] data,
        +                     int offset,
        +                     short value)
        +
        Writes a "short" value to a byte array at a given offset. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        data - target byte array
        offset - starting offset in the byte array
        value - value to write
        +
      • +
      + + + +
        +
      • +

        readSwappedShort

        +
        public static short readSwappedShort(byte[] data,
        +                     int offset)
        +
        Reads a "short" value from a byte array at a given offset. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        data - source byte array
        offset - starting offset in the byte array
        +
        Returns:
        the value read
        +
      • +
      + + + +
        +
      • +

        readSwappedUnsignedShort

        +
        public static int readSwappedUnsignedShort(byte[] data,
        +                           int offset)
        +
        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.
        +
        Parameters:
        data - source byte array
        offset - starting offset in the byte array
        +
        Returns:
        the value read
        +
      • +
      + + + +
        +
      • +

        writeSwappedInteger

        +
        public static void writeSwappedInteger(byte[] data,
        +                       int offset,
        +                       int value)
        +
        Writes a "int" value to a byte array at a given offset. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        data - target byte array
        offset - starting offset in the byte array
        value - value to write
        +
      • +
      + + + +
        +
      • +

        readSwappedInteger

        +
        public static int readSwappedInteger(byte[] data,
        +                     int offset)
        +
        Reads a "int" value from a byte array at a given offset. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        data - source byte array
        offset - starting offset in the byte array
        +
        Returns:
        the value read
        +
      • +
      + + + +
        +
      • +

        readSwappedUnsignedInteger

        +
        public static long readSwappedUnsignedInteger(byte[] data,
        +                              int offset)
        +
        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.
        +
        Parameters:
        data - source byte array
        offset - starting offset in the byte array
        +
        Returns:
        the value read
        +
      • +
      + + + +
        +
      • +

        writeSwappedLong

        +
        public static void writeSwappedLong(byte[] data,
        +                    int offset,
        +                    long value)
        +
        Writes a "long" value to a byte array at a given offset. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        data - target byte array
        offset - starting offset in the byte array
        value - value to write
        +
      • +
      + + + +
        +
      • +

        readSwappedLong

        +
        public static long readSwappedLong(byte[] data,
        +                   int offset)
        +
        Reads a "long" value from a byte array at a given offset. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        data - source byte array
        offset - starting offset in the byte array
        +
        Returns:
        the value read
        +
      • +
      + + + +
        +
      • +

        writeSwappedFloat

        +
        public static void writeSwappedFloat(byte[] data,
        +                     int offset,
        +                     float value)
        +
        Writes a "float" value to a byte array at a given offset. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        data - target byte array
        offset - starting offset in the byte array
        value - value to write
        +
      • +
      + + + +
        +
      • +

        readSwappedFloat

        +
        public static float readSwappedFloat(byte[] data,
        +                     int offset)
        +
        Reads a "float" value from a byte array at a given offset. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        data - source byte array
        offset - starting offset in the byte array
        +
        Returns:
        the value read
        +
      • +
      + + + +
        +
      • +

        writeSwappedDouble

        +
        public static void writeSwappedDouble(byte[] data,
        +                      int offset,
        +                      double value)
        +
        Writes a "double" value to a byte array at a given offset. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        data - target byte array
        offset - starting offset in the byte array
        value - value to write
        +
      • +
      + + + +
        +
      • +

        readSwappedDouble

        +
        public static double readSwappedDouble(byte[] data,
        +                       int offset)
        +
        Reads a "double" value from a byte array at a given offset. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        data - source byte array
        offset - starting offset in the byte array
        +
        Returns:
        the value read
        +
      • +
      + + + +
        +
      • +

        writeSwappedShort

        +
        public static void writeSwappedShort(OutputStream output,
        +                     short value)
        +                              throws IOException
        +
        Writes a "short" value to an OutputStream. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        output - target OutputStream
        value - value to write
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        readSwappedShort

        +
        public static short readSwappedShort(InputStream input)
        +                              throws IOException
        +
        Reads a "short" value from an InputStream. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        input - source InputStream
        +
        Returns:
        the value just read
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        readSwappedUnsignedShort

        +
        public static int readSwappedUnsignedShort(InputStream input)
        +                                    throws IOException
        +
        Reads a unsigned short (16-bit) from an InputStream. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        input - source InputStream
        +
        Returns:
        the value just read
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        writeSwappedInteger

        +
        public static void writeSwappedInteger(OutputStream output,
        +                       int value)
        +                                throws IOException
        +
        Writes a "int" value to an OutputStream. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        output - target OutputStream
        value - value to write
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        readSwappedInteger

        +
        public static int readSwappedInteger(InputStream input)
        +                              throws IOException
        +
        Reads a "int" value from an InputStream. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        input - source InputStream
        +
        Returns:
        the value just read
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        readSwappedUnsignedInteger

        +
        public static long readSwappedUnsignedInteger(InputStream input)
        +                                       throws IOException
        +
        Reads a unsigned integer (32-bit) from an InputStream. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        input - source InputStream
        +
        Returns:
        the value just read
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        writeSwappedLong

        +
        public static void writeSwappedLong(OutputStream output,
        +                    long value)
        +                             throws IOException
        +
        Writes a "long" value to an OutputStream. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        output - target OutputStream
        value - value to write
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        readSwappedLong

        +
        public static long readSwappedLong(InputStream input)
        +                            throws IOException
        +
        Reads a "long" value from an InputStream. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        input - source InputStream
        +
        Returns:
        the value just read
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        writeSwappedFloat

        +
        public static void writeSwappedFloat(OutputStream output,
        +                     float value)
        +                              throws IOException
        +
        Writes a "float" value to an OutputStream. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        output - target OutputStream
        value - value to write
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        readSwappedFloat

        +
        public static float readSwappedFloat(InputStream input)
        +                              throws IOException
        +
        Reads a "float" value from an InputStream. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        input - source InputStream
        +
        Returns:
        the value just read
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        writeSwappedDouble

        +
        public static void writeSwappedDouble(OutputStream output,
        +                      double value)
        +                               throws IOException
        +
        Writes a "double" value to an OutputStream. The value is + converted to the opposed endian system while writing.
        +
        Parameters:
        output - target OutputStream
        value - value to write
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      + + + +
        +
      • +

        readSwappedDouble

        +
        public static double readSwappedDouble(InputStream input)
        +                                throws IOException
        +
        Reads a "double" value from an InputStream. The value is + converted to the opposed endian system while reading.
        +
        Parameters:
        input - source InputStream
        +
        Returns:
        the value just read
        +
        Throws:
        +
        IOException - in case of an I/O problem
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaner.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaner.html" index 17660be8d00f7c2c6e16697b31cba878a744710c..6b04435c3d62d59bd81df5a98c048dd1e974e06a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaner.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaner.html" @@ -1,3 +1,459 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:13b40c8ffe87239fb4c76fb3263f05674e29b0cf105eb1f21e8282a42ec03579 -size 27343 + + + + + +FileCleaner (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class FileCleaner

+
+
+ +
+
    +
  • +
    +
    Deprecated.  + +
    +
    +
    @Deprecated
    +public class FileCleaner
    +extends Object
    +
    Keeps track of files awaiting deletion, and deletes them when an associated + marker object is reclaimed by the garbage collector. +

    + 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. +

    + 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 + exitWhenFinished(), typically in + javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent) or similar.

    +
    Version:
    +
    $Id: FileCleaner.java 1680650 2015-05-20 18:36:40Z britter $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileCleaner

        +
        public FileCleaner()
        +
        Deprecated. 
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        track

        +
        @Deprecated
        +public static void track(File file,
        +                    Object marker)
        + +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The normal deletion strategy will be used.
        +
        Parameters:
        file - the file to be tracked, not null
        marker - the marker object used to track the file, not null
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
      • +
      + + + +
        +
      • +

        track

        +
        @Deprecated
        +public static void track(File file,
        +                    Object marker,
        +                    FileDeleteStrategy deleteStrategy)
        + +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The speified deletion strategy is used.
        +
        Parameters:
        file - the file to be tracked, not null
        marker - the marker object used to track the file, not null
        deleteStrategy - the strategy to delete the file, null means normal
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
      • +
      + + + +
        +
      • +

        track

        +
        @Deprecated
        +public static void track(String path,
        +                    Object marker)
        + +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The normal deletion strategy will be used.
        +
        Parameters:
        path - the full path to the file to be tracked, not null
        marker - the marker object used to track the file, not null
        +
        Throws:
        +
        NullPointerException - if the path is null
        +
      • +
      + + + +
        +
      • +

        track

        +
        @Deprecated
        +public static void track(String path,
        +                    Object marker,
        +                    FileDeleteStrategy deleteStrategy)
        + +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The speified deletion strategy is used.
        +
        Parameters:
        path - the full path to the file to be tracked, not null
        marker - the marker object used to track the file, not null
        deleteStrategy - the strategy to delete the file, null means normal
        +
        Throws:
        +
        NullPointerException - if the path is null
        +
      • +
      + + + +
        +
      • +

        getTrackCount

        +
        @Deprecated
        +public static int getTrackCount()
        + +
        Retrieve the number of files currently being tracked, and therefore + awaiting deletion.
        +
        Returns:
        the number of files being tracked
        +
      • +
      + + + +
        +
      • +

        exitWhenFinished

        +
        @Deprecated
        +public static void exitWhenFinished()
        + +
        Call this method to cause the file cleaner thread to terminate when + there are no more objects being tracked for deletion. +

        + 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. +

        + 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. +

        + This method allows the thread to be terminated. Simply call this method + in the resource cleanup code, such as + javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent). + One called, no new objects can be tracked by the file cleaner.

        +
      • +
      + + + +
        +
      • +

        getInstance

        +
        public static FileCleaningTracker getInstance()
        +
        Deprecated. 
        +
        Returns the singleton instance, which is used by the deprecated, static methods. + This is mainly useful for code, which wants to support the new + FileCleaningTracker class while maintain compatibility with the + deprecated FileCleaner.
        +
        Returns:
        the singleton instance
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaningTracker.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaningTracker.html" index b7302042afa1fd1cb3b4db37bdde2eaaf1dde304..d7b5d7ed61e4fdb24a9fc8592927e6592e458b31 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaningTracker.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileCleaningTracker.html" @@ -1,3 +1,430 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:639ef9912cf6cebfc0735edfab1d9fc6ee27dda5ec778a97579c6b144c58046a -size 23362 + + + + + +FileCleaningTracker (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class FileCleaningTracker

+
+
+ +
+
    +
  • +
    +
    +
    public class FileCleaningTracker
    +extends Object
    +
    Keeps track of files awaiting deletion, and deletes them when an associated + marker object is reclaimed by the garbage collector. +

    + 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. +

    + 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 + exitWhenFinished, typically in + javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent) or similar.

    +
    Version:
    +
    $Id: FileCleaningTracker.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidexitWhenFinished() +
      Call this method to cause the file cleaner thread to terminate when + there are no more objects being tracked for deletion.
      +
      List<String>getDeleteFailures() +
      Return the file paths that failed to delete.
      +
      intgetTrackCount() +
      Retrieve the number of files currently being tracked, and therefore + awaiting deletion.
      +
      voidtrack(File file, + Object marker) +
      Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
      +
      voidtrack(File file, + Object marker, + FileDeleteStrategy deleteStrategy) +
      Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
      +
      voidtrack(String path, + Object marker) +
      Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
      +
      voidtrack(String path, + Object marker, + FileDeleteStrategy deleteStrategy) +
      Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileCleaningTracker

        +
        public FileCleaningTracker()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        track

        +
        public void track(File file,
        +         Object marker)
        +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The normal deletion strategy will be used.
        +
        Parameters:
        file - the file to be tracked, not null
        marker - the marker object used to track the file, not null
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
      • +
      + + + +
        +
      • +

        track

        +
        public void track(File file,
        +         Object marker,
        +         FileDeleteStrategy deleteStrategy)
        +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The speified deletion strategy is used.
        +
        Parameters:
        file - the file to be tracked, not null
        marker - the marker object used to track the file, not null
        deleteStrategy - the strategy to delete the file, null means normal
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
      • +
      + + + +
        +
      • +

        track

        +
        public void track(String path,
        +         Object marker)
        +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The normal deletion strategy will be used.
        +
        Parameters:
        path - the full path to the file to be tracked, not null
        marker - the marker object used to track the file, not null
        +
        Throws:
        +
        NullPointerException - if the path is null
        +
      • +
      + + + +
        +
      • +

        track

        +
        public void track(String path,
        +         Object marker,
        +         FileDeleteStrategy deleteStrategy)
        +
        Track the specified file, using the provided marker, deleting the file + when the marker instance is garbage collected. + The speified deletion strategy is used.
        +
        Parameters:
        path - the full path to the file to be tracked, not null
        marker - the marker object used to track the file, not null
        deleteStrategy - the strategy to delete the file, null means normal
        +
        Throws:
        +
        NullPointerException - if the path is null
        +
      • +
      + + + +
        +
      • +

        getTrackCount

        +
        public int getTrackCount()
        +
        Retrieve the number of files currently being tracked, and therefore + awaiting deletion.
        +
        Returns:
        the number of files being tracked
        +
      • +
      + + + +
        +
      • +

        getDeleteFailures

        +
        public List<String> getDeleteFailures()
        +
        Return the file paths that failed to delete.
        +
        Returns:
        the file paths that failed to delete
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        exitWhenFinished

        +
        public void exitWhenFinished()
        +
        Call this method to cause the file cleaner thread to terminate when + there are no more objects being tracked for deletion. +

        + 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. +

        + 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. +

        + This method allows the thread to be terminated. Simply call this method + in the resource cleanup code, such as + javax.servlet.ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent). + Once called, no new objects can be tracked by the file cleaner.

        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileDeleteStrategy.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileDeleteStrategy.html" index bd76db7f49690b623e9aeab9e4e89c68841657db..9018c4db98d19ab2d8c8c5f85dadc42c7f2101d4 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileDeleteStrategy.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileDeleteStrategy.html" @@ -1,3 +1,415 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7af8aa68120bf809b16c7ba4be6d81b78f8f5d776ad4e4eff2523aa0b033802a -size 20825 + + + + + +FileDeleteStrategy (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class FileDeleteStrategy

+
+
+ +
+
    +
  • +
    +
    +
    public class FileDeleteStrategy
    +extends Object
    +
    Strategy for deleting files. +

    + 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. +

    + This class captures the strategy to use and is designed for user subclassing.

    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: FileDeleteStrategy.java 1563227 2014-01-31 19:45:30Z ggregory $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      static FileDeleteStrategyFORCE +
      The singleton instance for forced file deletion, which always deletes, + even if the file represents a non-empty directory.
      +
      static FileDeleteStrategyNORMAL +
      The singleton instance for normal file deletion, which does not permit + the deletion of directories that are not empty.
      +
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + +
      Constructors 
      ModifierConstructor and Description
      protected FileDeleteStrategy(String name) +
      Restricted constructor.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        NORMAL

        +
        public static final FileDeleteStrategy NORMAL
        +
        The singleton instance for normal file deletion, which does not permit + the deletion of directories that are not empty.
        +
      • +
      + + + +
        +
      • +

        FORCE

        +
        public static final FileDeleteStrategy FORCE
        +
        The singleton instance for forced file deletion, which always deletes, + even if the file represents a non-empty directory.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileDeleteStrategy

        +
        protected FileDeleteStrategy(String name)
        +
        Restricted constructor.
        +
        Parameters:
        name - the name by which the strategy is known
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        deleteQuietly

        +
        public boolean deleteQuietly(File fileToDelete)
        +
        Deletes the file object, which may be a file or a directory. + All IOExceptions are caught and false returned instead. + If the file does not exist or is null, true is returned. +

        + Subclass writers should override doDelete(File), not this method.

        +
        Parameters:
        fileToDelete - the file to delete, null returns true
        +
        Returns:
        true if the file was deleted, or there was no such file
        +
      • +
      + + + +
        +
      • +

        delete

        +
        public void delete(File fileToDelete)
        +            throws IOException
        +
        Deletes the file object, which may be a file or a directory. + If the file does not exist, the method just returns. +

        + Subclass writers should override doDelete(File), not this method.

        +
        Parameters:
        fileToDelete - the file to delete, not null
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - if an error occurs during file deletion
        +
      • +
      + + + +
        +
      • +

        doDelete

        +
        protected boolean doDelete(File fileToDelete)
        +                    throws IOException
        +
        Actually deletes the file object, which may be a file or a directory. +

        + This method is designed for subclasses to override. + The implementation may return either false or an IOException + when deletion fails. The delete(File) and deleteQuietly(File) + methods will handle either response appropriately. + A check has been made to ensure that the file will exist. +

        + This implementation uses File.delete().

        +
        Parameters:
        fileToDelete - the file to delete, exists, not null
        +
        Returns:
        true if the file was deleteds
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - if an error occurs during file deletion
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Gets a string describing the delete strategy.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        a string describing the delete strategy
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileExistsException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileExistsException.html" index 8d85f7bdfb285cae4ce102f1170cb6498f364707..7a562c9dc1ea57fc838ccbd66201194b5781a770 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileExistsException.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileExistsException.html" @@ -1,3 +1,295 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e42a0cb8af4368a1153561a411e0a7c28ec13946e877c3ce6f0e4bf15b8dc2e1 -size 15305 + + + + + +FileExistsException (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class FileExistsException

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable
    +
    +
    +
    +
    public class FileExistsException
    +extends IOException
    +
    Indicates that a file already exists.
    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: FileExistsException.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileExistsException

        +
        public FileExistsException()
        +
        Default Constructor.
        +
      • +
      + + + +
        +
      • +

        FileExistsException

        +
        public FileExistsException(String message)
        +
        Construct an instance with the specified message.
        +
        Parameters:
        message - The error message
        +
      • +
      + + + +
        +
      • +

        FileExistsException

        +
        public FileExistsException(File file)
        +
        Construct an instance with the specified file.
        +
        Parameters:
        file - The file that exists
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileSystemUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileSystemUtils.html" index 423eca69e5ff5cf508ff186c244ebc9551d7068c..251dea423956cee2a2bd1352f998a3a9665c7b5e 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileSystemUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileSystemUtils.html" @@ -1,3 +1,440 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ab2183a0a74a83303cc7df5d09dcce38869f165783d633451467dbf0c43df85c -size 23269 + + + + + +FileSystemUtils (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class FileSystemUtils

+
+
+ +
+
    +
  • +
    +
    +
    public class FileSystemUtils
    +extends Object
    +
    General File System utilities. +

    + This class provides static utility methods for general file system + functions not provided via the JDK File class. +

    + The current functions provided are: +

      +
    • Get the free space on a drive +
    +
    Since:
    +
    1.1
    +
    Version:
    +
    $Id: FileSystemUtils.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      FileSystemUtils() +
      Instances should NOT be constructed in standard programming.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      static longfreeSpace(String path) +
      Deprecated.  +
      Use freeSpaceKb(String) + Deprecated from 1.3, may be removed in 2.0
      +
      +
      static longfreeSpaceKb() +
      Returns the disk size of the volume which holds the working directory.
      +
      static longfreeSpaceKb(long timeout) +
      Returns the disk size of the volume which holds the working directory.
      +
      static longfreeSpaceKb(String path) +
      Returns the free space on a drive or volume in kilobytes by invoking + the command line.
      +
      static longfreeSpaceKb(String path, + long timeout) +
      Returns the free space on a drive or volume in kilobytes by invoking + the command line.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileSystemUtils

        +
        public FileSystemUtils()
        +
        Instances should NOT be constructed in standard programming.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        freeSpace

        +
        @Deprecated
        +public static long freeSpace(String path)
        +                      throws IOException
        +
        Deprecated. Use freeSpaceKb(String) + Deprecated from 1.3, may be removed in 2.0
        +
        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 freeSpaceKb(String) which returns a result in kilobytes. +

        + Note that some OS's are NOT currently supported, including OS/390, + OpenVMS. +

        + FileSystemUtils.freeSpace("C:");       // Windows
        + FileSystemUtils.freeSpace("/volume");  // *nix
        + 
        + The free space is calculated via the command line. + It uses 'dir /-c' on Windows and 'df' on *nix.
        +
        Parameters:
        path - the path to get free space for, not null, not empty on Unix
        +
        Returns:
        the amount of free drive space on the drive or volume
        +
        Throws:
        +
        IllegalArgumentException - if the path is invalid
        +
        IllegalStateException - if an error occurred in initialisation
        +
        IOException - if an error occurs when finding the free space
        Since:
        +
        1.1, enhanced OS support in 1.2 and 1.3
        +
      • +
      + + + +
        +
      • +

        freeSpaceKb

        +
        public static long freeSpaceKb(String path)
        +                        throws IOException
        +
        Returns the free space on a drive or volume in kilobytes by invoking + the command line. +
        + FileSystemUtils.freeSpaceKb("C:");       // Windows
        + FileSystemUtils.freeSpaceKb("/volume");  // *nix
        + 
        + 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. +

        + 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.

        +
        Parameters:
        path - the path to get free space for, not null, not empty on Unix
        +
        Returns:
        the amount of free drive space on the drive or volume in kilobytes
        +
        Throws:
        +
        IllegalArgumentException - if the path is invalid
        +
        IllegalStateException - if an error occurred in initialisation
        +
        IOException - if an error occurs when finding the free space
        Since:
        +
        1.2, enhanced OS support in 1.3
        +
      • +
      + + + +
        +
      • +

        freeSpaceKb

        +
        public static long freeSpaceKb(String path,
        +               long timeout)
        +                        throws IOException
        +
        Returns the free space on a drive or volume in kilobytes by invoking + the command line. +
        + FileSystemUtils.freeSpaceKb("C:");       // Windows
        + FileSystemUtils.freeSpaceKb("/volume");  // *nix
        + 
        + 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. +

        + 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.

        +
        Parameters:
        path - the path to get free space for, not null, not empty on Unix
        timeout - The timeout amount in milliseconds or no timeout if the value + is zero or less
        +
        Returns:
        the amount of free drive space on the drive or volume in kilobytes
        +
        Throws:
        +
        IllegalArgumentException - if the path is invalid
        +
        IllegalStateException - if an error occurred in initialisation
        +
        IOException - if an error occurs when finding the free space
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        freeSpaceKb

        +
        public static long freeSpaceKb()
        +                        throws IOException
        +
        Returns the disk size of the volume which holds the working directory. +

        + Identical to: +

        + freeSpaceKb(new File(".").getAbsolutePath())
        + 
        +
        Returns:
        the amount of free drive space on the drive or volume in kilobytes
        +
        Throws:
        +
        IllegalStateException - if an error occurred in initialisation
        +
        IOException - if an error occurs when finding the free space
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        freeSpaceKb

        +
        public static long freeSpaceKb(long timeout)
        +                        throws IOException
        +
        Returns the disk size of the volume which holds the working directory. +

        + Identical to: +

        + freeSpaceKb(new File(".").getAbsolutePath())
        + 
        +
        Parameters:
        timeout - The timeout amount in milliseconds or no timeout if the value + is zero or less
        +
        Returns:
        the amount of free drive space on the drive or volume in kilobytes
        +
        Throws:
        +
        IllegalStateException - if an error occurred in initialisation
        +
        IOException - if an error occurs when finding the free space
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileUtils.html" index 59e9572121aa067bd8b0c043a462cd92b9edff64..f10c4d81a5f4cbf7bd6f3f53716b9e488fed544c 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FileUtils.html" @@ -1,3 +1,3441 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cc8a65829eda8f802441e49588e90ed4b67b066c705fab84cf674b6972cfb5dc -size 279172 + + + + + +FileUtils (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class FileUtils

+
+
+ +
+
    +
  • +
    +
    +
    public class FileUtils
    +extends Object
    +
    General file manipulation utilities. +

    + Facilities are provided in the following areas: +

      +
    • writing to a file +
    • reading from a file +
    • make a directory including parent directories +
    • copying files and directories +
    • deleting files and directories +
    • converting to and from a URL +
    • listing files and directories by filter and extension +
    • comparing file content +
    • file last changed date +
    • calculating a checksum +
    +

    + Origin of code: Excalibur, Alexandria, Commons-Utils

    +
    Version:
    +
    $Id: FileUtils.java 1722481 2016-01-01 01:42:04Z dbrosius $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        ONE_KB

        +
        public static final long ONE_KB
        +
        The number of bytes in a kilobyte.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        ONE_KB_BI

        +
        public static final BigInteger ONE_KB_BI
        +
        The number of bytes in a kilobyte.
        +
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        ONE_MB

        +
        public static final long ONE_MB
        +
        The number of bytes in a megabyte.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        ONE_MB_BI

        +
        public static final BigInteger ONE_MB_BI
        +
        The number of bytes in a megabyte.
        +
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        ONE_GB

        +
        public static final long ONE_GB
        +
        The number of bytes in a gigabyte.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        ONE_GB_BI

        +
        public static final BigInteger ONE_GB_BI
        +
        The number of bytes in a gigabyte.
        +
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        ONE_TB

        +
        public static final long ONE_TB
        +
        The number of bytes in a terabyte.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        ONE_TB_BI

        +
        public static final BigInteger ONE_TB_BI
        +
        The number of bytes in a terabyte.
        +
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        ONE_PB

        +
        public static final long ONE_PB
        +
        The number of bytes in a petabyte.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        ONE_PB_BI

        +
        public static final BigInteger ONE_PB_BI
        +
        The number of bytes in a petabyte.
        +
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        ONE_EB

        +
        public static final long ONE_EB
        +
        The number of bytes in an exabyte.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        ONE_EB_BI

        +
        public static final BigInteger ONE_EB_BI
        +
        The number of bytes in an exabyte.
        +
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        ONE_ZB

        +
        public static final BigInteger ONE_ZB
        +
        The number of bytes in a zettabyte.
        +
      • +
      + + + +
        +
      • +

        ONE_YB

        +
        public static final BigInteger ONE_YB
        +
        The number of bytes in a yottabyte.
        +
      • +
      + + + +
        +
      • +

        EMPTY_FILE_ARRAY

        +
        public static final File[] EMPTY_FILE_ARRAY
        +
        An empty array of type File.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileUtils

        +
        public FileUtils()
        +
        Instances should NOT be constructed in standard programming.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getFile

        +
        public static File getFile(File directory,
        +           String... names)
        +
        Construct a file from the set of name elements.
        +
        Parameters:
        directory - the parent directory
        names - the name elements
        +
        Returns:
        the file
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        getFile

        +
        public static File getFile(String... names)
        +
        Construct a file from the set of name elements.
        +
        Parameters:
        names - the name elements
        +
        Returns:
        the file
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        getTempDirectoryPath

        +
        public static String getTempDirectoryPath()
        +
        Returns the path to the system temporary directory.
        +
        Returns:
        the path to the system temporary directory.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        getTempDirectory

        +
        public static File getTempDirectory()
        +
        Returns a File representing the system temporary directory.
        +
        Returns:
        the system temporary directory.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        getUserDirectoryPath

        +
        public static String getUserDirectoryPath()
        +
        Returns the path to the user's home directory.
        +
        Returns:
        the path to the user's home directory.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        getUserDirectory

        +
        public static File getUserDirectory()
        +
        Returns a File representing the user's home directory.
        +
        Returns:
        the user's home directory.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        openInputStream

        +
        public static FileInputStream openInputStream(File file)
        +                                       throws IOException
        +
        Opens a FileInputStream for the specified file, providing better + error messages than simply calling new FileInputStream(file). +

        + At the end of the method either the stream will be successfully opened, + or an exception will have been thrown. +

        + An exception is thrown if the file does not exist. + An exception is thrown if the file object exists but is a directory. + An exception is thrown if the file exists but cannot be read.

        +
        Parameters:
        file - the file to open for input, must not be null
        +
        Returns:
        a new FileInputStream for the specified file
        +
        Throws:
        +
        FileNotFoundException - if the file does not exist
        +
        IOException - if the file object is a directory
        +
        IOException - if the file cannot be read
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        openOutputStream

        +
        public static FileOutputStream openOutputStream(File file)
        +                                         throws IOException
        +
        Opens a FileOutputStream for the specified file, checking and + creating the parent directory if it does not exist. +

        + At the end of the method either the stream will be successfully opened, + or an exception will have been thrown. +

        + The parent directory will be created if it does not exist. + The file will be created if it does not exist. + An exception is thrown if the file object exists but is a directory. + An exception is thrown if the file exists but cannot be written to. + An exception is thrown if the parent directory cannot be created.

        +
        Parameters:
        file - the file to open for output, must not be null
        +
        Returns:
        a new FileOutputStream for the specified file
        +
        Throws:
        +
        IOException - if the file object is a directory
        +
        IOException - if the file cannot be written to
        +
        IOException - if a parent directory needs creating but that fails
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        openOutputStream

        +
        public static FileOutputStream openOutputStream(File file,
        +                                boolean append)
        +                                         throws IOException
        +
        Opens a FileOutputStream for the specified file, checking and + creating the parent directory if it does not exist. +

        + At the end of the method either the stream will be successfully opened, + or an exception will have been thrown. +

        + The parent directory will be created if it does not exist. + The file will be created if it does not exist. + An exception is thrown if the file object exists but is a directory. + An exception is thrown if the file exists but cannot be written to. + An exception is thrown if the parent directory cannot be created.

        +
        Parameters:
        file - the file to open for output, must not be null
        append - if true, then bytes will be added to the + end of the file rather than overwriting
        +
        Returns:
        a new FileOutputStream for the specified file
        +
        Throws:
        +
        IOException - if the file object is a directory
        +
        IOException - if the file cannot be written to
        +
        IOException - if a parent directory needs creating but that fails
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        byteCountToDisplaySize

        +
        public static String byteCountToDisplaySize(BigInteger size)
        +
        Returns a human-readable version of the file size, where the input represents a specific number of bytes. +

        + If the size is over 1GB, the size is returned as the number of whole GB, i.e. the size is rounded down to the + nearest GB boundary. +

        +

        + Similarly for the 1MB and 1KB boundaries. +

        +
        Parameters:
        size - the number of bytes
        +
        Returns:
        a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes)
        Since:
        +
        2.4
        +
        See Also:
        IO-226 - should the rounding be changed?
        +
      • +
      + + + +
        +
      • +

        byteCountToDisplaySize

        +
        public static String byteCountToDisplaySize(long size)
        +
        Returns a human-readable version of the file size, where the input represents a specific number of bytes. +

        + If the size is over 1GB, the size is returned as the number of whole GB, i.e. the size is rounded down to the + nearest GB boundary. +

        +

        + Similarly for the 1MB and 1KB boundaries. +

        +
        Parameters:
        size - the number of bytes
        +
        Returns:
        a human-readable display value (includes units - EB, PB, TB, GB, MB, KB or bytes)
        See Also:
        IO-226 - should the rounding be changed?
        +
      • +
      + + + +
        +
      • +

        touch

        +
        public static void touch(File file)
        +                  throws IOException
        +
        Implements the same behaviour as the "touch" utility on Unix. It creates + a new file with size 0 or, if the file exists already, it is opened and + closed without modifying it, but updating the file date and time. +

        + NOTE: As from v1.3, this method throws an IOException if the last + modified date of the file cannot be set. Also, as from v1.3 this method + creates parent directories if they do not exist.

        +
        Parameters:
        file - the File to touch
        +
        Throws:
        +
        IOException - If an I/O problem occurs
        +
      • +
      + + + +
        +
      • +

        convertFileCollectionToFileArray

        +
        public static File[] convertFileCollectionToFileArray(Collection<File> files)
        +
        Converts a Collection containing java.io.File instanced into array + representation. This is to account for the difference between + File.listFiles() and FileUtils.listFiles().
        +
        Parameters:
        files - a Collection containing java.io.File instances
        +
        Returns:
        an array of java.io.File
        +
      • +
      + + + +
        +
      • +

        listFiles

        +
        public static Collection<File> listFiles(File directory,
        +                         IOFileFilter fileFilter,
        +                         IOFileFilter dirFilter)
        +
        Finds files within a given directory (and optionally its + subdirectories). All files found are filtered by an IOFileFilter. +

        + If your search should recurse into subdirectories you can pass in + an IOFileFilter for directories. You don't need to bind a + DirectoryFileFilter (via logical AND) to this filter. This method does + that for you. +

        + An example: If you want to search through all directories called + "temp" you pass in FileFilterUtils.NameFileFilter("temp") +

        + Another common usage of this method is find files in a directory + tree but ignoring the directories generated CVS. You can simply pass + in FileFilterUtils.makeCVSAware(null).

        +
        Parameters:
        directory - the directory to search in
        fileFilter - filter to apply when finding files.
        dirFilter - optional filter to apply when finding subdirectories. + If this parameter is null, subdirectories will not be included in the + search. Use TrueFileFilter.INSTANCE to match all directories.
        +
        Returns:
        an collection of java.io.File with the matching files
        See Also:
        FileFilterUtils, +NameFileFilter
        +
      • +
      + + + + + + + +
        +
      • +

        iterateFiles

        +
        public static Iterator<File> iterateFiles(File directory,
        +                          IOFileFilter fileFilter,
        +                          IOFileFilter dirFilter)
        +
        Allows iteration over the files in given directory (and optionally + its subdirectories). +

        + All files found are filtered by an IOFileFilter. This method is + based on listFiles(File, IOFileFilter, IOFileFilter), + which supports Iterable ('foreach' loop). +

        +
        Parameters:
        directory - the directory to search in
        fileFilter - filter to apply when finding files.
        dirFilter - optional filter to apply when finding subdirectories. + If this parameter is null, subdirectories will not be included in the + search. Use TrueFileFilter.INSTANCE to match all directories.
        +
        Returns:
        an iterator of java.io.File for the matching files
        Since:
        +
        1.2
        +
        See Also:
        FileFilterUtils, +NameFileFilter
        +
      • +
      + + + +
        +
      • +

        iterateFilesAndDirs

        +
        public static Iterator<File> iterateFilesAndDirs(File directory,
        +                                 IOFileFilter fileFilter,
        +                                 IOFileFilter dirFilter)
        +
        Allows iteration over the files in given directory (and optionally + its subdirectories). +

        + All files found are filtered by an IOFileFilter. This method is + based on listFilesAndDirs(File, IOFileFilter, IOFileFilter), + which supports Iterable ('foreach' loop). +

        + The resulting iterator includes the subdirectories themselves.

        +
        Parameters:
        directory - the directory to search in
        fileFilter - filter to apply when finding files.
        dirFilter - optional filter to apply when finding subdirectories. + If this parameter is null, subdirectories will not be included in the + search. Use TrueFileFilter.INSTANCE to match all directories.
        +
        Returns:
        an iterator of java.io.File for the matching files
        Since:
        +
        2.2
        +
        See Also:
        FileFilterUtils, +NameFileFilter
        +
      • +
      + + + +
        +
      • +

        listFiles

        +
        public static Collection<File> listFiles(File directory,
        +                         String[] extensions,
        +                         boolean recursive)
        +
        Finds files within a given directory (and optionally its subdirectories) + which match an array of extensions.
        +
        Parameters:
        directory - the directory to search in
        extensions - an array of extensions, ex. {"java","xml"}. If this + parameter is null, all files are returned.
        recursive - if true all subdirectories are searched as well
        +
        Returns:
        an collection of java.io.File with the matching files
        +
      • +
      + + + +
        +
      • +

        iterateFiles

        +
        public static Iterator<File> iterateFiles(File directory,
        +                          String[] extensions,
        +                          boolean recursive)
        +
        Allows iteration over the files in a given directory (and optionally + its subdirectories) which match an array of extensions. This method + is based on listFiles(File, String[], boolean), + which supports Iterable ('foreach' loop).
        +
        Parameters:
        directory - the directory to search in
        extensions - an array of extensions, ex. {"java","xml"}. If this + parameter is null, all files are returned.
        recursive - if true all subdirectories are searched as well
        +
        Returns:
        an iterator of java.io.File with the matching files
        Since:
        +
        1.2
        +
      • +
      + + + +
        +
      • +

        contentEquals

        +
        public static boolean contentEquals(File file1,
        +                    File file2)
        +                             throws IOException
        +
        Compares the contents of two files to determine if they are equal or not. +

        + This method checks to see if the two files are different lengths + or if they point to the same file, before resorting to byte-by-byte + comparison of the contents. +

        + Code origin: Avalon

        +
        Parameters:
        file1 - the first file
        file2 - the second file
        +
        Returns:
        true if the content of the files are equal or they both don't + exist, false otherwise
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        contentEqualsIgnoreEOL

        +
        public static boolean contentEqualsIgnoreEOL(File file1,
        +                             File file2,
        +                             String charsetName)
        +                                      throws IOException
        +
        Compares the contents of two files to determine if they are equal or not. +

        + This method checks to see if the two files point to the same file, + before resorting to line-by-line comparison of the contents. +

        +
        Parameters:
        file1 - the first file
        file2 - the second file
        charsetName - the character encoding to be used. + May be null, in which case the platform default is used
        +
        Returns:
        true if the content of the files are equal or neither exists, + false otherwise
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.2
        +
        See Also:
        IOUtils.contentEqualsIgnoreEOL(Reader, Reader)
        +
      • +
      + + + +
        +
      • +

        toFile

        +
        public static File toFile(URL url)
        +
        Convert from a URL to a File. +

        + From version 1.1 this method will decode the URL. + Syntax such as file:///my%20docs/file.txt will be + correctly decoded to /my docs/file.txt. Starting with version + 1.5, this method uses UTF-8 to decode percent-encoded octets to characters. + Additionally, malformed percent-encoded octets are handled leniently by + passing them through literally.

        +
        Parameters:
        url - the file URL to convert, null returns null
        +
        Returns:
        the equivalent File object, or null + if the URL's protocol is not file
        +
      • +
      + + + +
        +
      • +

        toFiles

        +
        public static File[] toFiles(URL[] urls)
        +
        Converts each of an array of URL to a File. +

        + Returns an array of the same size as the input. + If the input is null, an empty array is returned. + If the input contains null, the output array contains null at the same + index. +

        + This method will decode the URL. + Syntax such as file:///my%20docs/file.txt will be + correctly decoded to /my docs/file.txt.

        +
        Parameters:
        urls - the file URLs to convert, null returns empty array
        +
        Returns:
        a non-null array of Files matching the input, with a null item + if there was a null at that index in the input array
        +
        Throws:
        +
        IllegalArgumentException - if any file is not a URL file
        +
        IllegalArgumentException - if any file is incorrectly encoded
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        toURLs

        +
        public static URL[] toURLs(File[] files)
        +                    throws IOException
        +
        Converts each of an array of File to a URL. +

        + Returns an array of the same size as the input.

        +
        Parameters:
        files - the files to convert, must not be null
        +
        Returns:
        an array of URLs matching the input
        +
        Throws:
        +
        IOException - if a file cannot be converted
        +
        NullPointerException - if the parameter is null
        +
      • +
      + + + +
        +
      • +

        copyFileToDirectory

        +
        public static void copyFileToDirectory(File srcFile,
        +                       File destDir)
        +                                throws IOException
        +
        Copies a file to a directory preserving the file date. +

        + This method copies the contents of the specified source file + to a file of the same name in the specified destination directory. + The destination directory is created if it does not exist. + If the destination file exists, then this method will overwrite it. +

        + Note: This method tries to preserve the file's last + modified date/times using File.setLastModified(long), however + it is not guaranteed that the operation will succeed. + If the modification operation fails, no indication is provided.

        +
        Parameters:
        srcFile - an existing file to copy, must not be null
        destDir - the directory to place the copy in, must not be null
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        See Also:
        copyFile(File, File, boolean)
        +
      • +
      + + + +
        +
      • +

        copyFileToDirectory

        +
        public static void copyFileToDirectory(File srcFile,
        +                       File destDir,
        +                       boolean preserveFileDate)
        +                                throws IOException
        +
        Copies a file to a directory optionally preserving the file date. +

        + This method copies the contents of the specified source file + to a file of the same name in the specified destination directory. + The destination directory is created if it does not exist. + If the destination file exists, then this method will overwrite it. +

        + Note: Setting preserveFileDate to + true tries to preserve the file's last modified + date/times using File.setLastModified(long), however it is + not guaranteed that the operation will succeed. + If the modification operation fails, no indication is provided.

        +
        Parameters:
        srcFile - an existing file to copy, must not be null
        destDir - the directory to place the copy in, must not be null
        preserveFileDate - true if the file date of the copy + should be the same as the original
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        +
        IOException - if the output file length is not the same as the input file length after the copy + completes
        Since:
        +
        1.3
        +
        See Also:
        copyFile(File, File, boolean)
        +
      • +
      + + + +
        +
      • +

        copyFile

        +
        public static void copyFile(File srcFile,
        +            File destFile)
        +                     throws IOException
        +
        Copies a file to a new location preserving the file date. +

        + This method copies the contents of the specified source file to the + specified destination file. The directory holding the destination file is + created if it does not exist. If the destination file exists, then this + method will overwrite it. +

        + Note: This method tries to preserve the file's last + modified date/times using File.setLastModified(long), however + it is not guaranteed that the operation will succeed. + If the modification operation fails, no indication is provided.

        +
        Parameters:
        srcFile - an existing file to copy, must not be null
        destFile - the new file, must not be null
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        +
        IOException - if the output file length is not the same as the input file length after the copy + completes
        See Also:
        copyFileToDirectory(File, File), +copyFile(File, File, boolean)
        +
      • +
      + + + +
        +
      • +

        copyFile

        +
        public static void copyFile(File srcFile,
        +            File destFile,
        +            boolean preserveFileDate)
        +                     throws IOException
        +
        Copies a file to a new location. +

        + This method copies the contents of the specified source file + to the specified destination file. + The directory holding the destination file is created if it does not exist. + If the destination file exists, then this method will overwrite it. +

        + Note: Setting preserveFileDate to + true tries to preserve the file's last modified + date/times using File.setLastModified(long), however it is + not guaranteed that the operation will succeed. + If the modification operation fails, no indication is provided.

        +
        Parameters:
        srcFile - an existing file to copy, must not be null
        destFile - the new file, must not be null
        preserveFileDate - true if the file date of the copy + should be the same as the original
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        +
        IOException - if the output file length is not the same as the input file length after the copy + completes
        See Also:
        copyFileToDirectory(File, File, boolean), +doCopyFile(File, File, boolean)
        +
      • +
      + + + +
        +
      • +

        copyFile

        +
        public static long copyFile(File input,
        +            OutputStream output)
        +                     throws IOException
        +
        Copy bytes from a File to an OutputStream. +

        + This method buffers the input internally, so there is no need to use a BufferedInputStream. +

        +
        Parameters:
        input - the File to read from
        output - the OutputStream to write to
        +
        Returns:
        the number of bytes copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        copyDirectoryToDirectory

        +
        public static void copyDirectoryToDirectory(File srcDir,
        +                            File destDir)
        +                                     throws IOException
        +
        Copies a directory to within another directory preserving the file dates. +

        + This method copies the source directory and all its contents to a + directory of the same name in the specified destination directory. +

        + The destination directory is created if it does not exist. + If the destination directory did exist, then this method merges + the source with the destination, with the source taking precedence. +

        + Note: This method tries to preserve the files' last + modified date/times using File.setLastModified(long), however + it is not guaranteed that those operations will succeed. + If the modification operation fails, no indication is provided.

        +
        Parameters:
        srcDir - an existing directory to copy, must not be null
        destDir - the directory to place the copy in, must not be null
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        1.2
        +
      • +
      + + + +
        +
      • +

        copyDirectory

        +
        public static void copyDirectory(File srcDir,
        +                 File destDir)
        +                          throws IOException
        +
        Copies a whole directory to a new location preserving the file dates. +

        + This method copies the specified directory and all its child + directories and files to the specified destination. + The destination is the new location and name of the directory. +

        + The destination directory is created if it does not exist. + If the destination directory did exist, then this method merges + the source with the destination, with the source taking precedence. +

        + Note: This method tries to preserve the files' last + modified date/times using File.setLastModified(long), however + it is not guaranteed that those operations will succeed. + If the modification operation fails, no indication is provided.

        +
        Parameters:
        srcDir - an existing directory to copy, must not be null
        destDir - the new directory, must not be null
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copyDirectory

        +
        public static void copyDirectory(File srcDir,
        +                 File destDir,
        +                 boolean preserveFileDate)
        +                          throws IOException
        +
        Copies a whole directory to a new location. +

        + This method copies the contents of the specified source directory + to within the specified destination directory. +

        + The destination directory is created if it does not exist. + If the destination directory did exist, then this method merges + the source with the destination, with the source taking precedence. +

        + Note: Setting preserveFileDate to + true tries to preserve the files' last modified + date/times using File.setLastModified(long), however it is + not guaranteed that those operations will succeed. + If the modification operation fails, no indication is provided.

        +
        Parameters:
        srcDir - an existing directory to copy, must not be null
        destDir - the new directory, must not be null
        preserveFileDate - true if the file date of the copy + should be the same as the original
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copyDirectory

        +
        public static void copyDirectory(File srcDir,
        +                 File destDir,
        +                 FileFilter filter)
        +                          throws IOException
        +
        Copies a filtered directory to a new location preserving the file dates. +

        + This method copies the contents of the specified source directory + to within the specified destination directory. +

        + The destination directory is created if it does not exist. + If the destination directory did exist, then this method merges + the source with the destination, with the source taking precedence. +

        + Note: This method tries to preserve the files' last + modified date/times using File.setLastModified(long), however + it is not guaranteed that those operations will succeed. + If the modification operation fails, no indication is provided. +

        +

        Example: Copy directories only

        +
        +  // only copy the directory structure
        +  FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY);
        +  
        + +

        Example: Copy directories and txt files

        +
        +  // Create a filter for ".txt" files
        +  IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".txt");
        +  IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter);
        +
        +  // Create a filter for either directories or ".txt" files
        +  FileFilter filter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, txtFiles);
        +
        +  // Copy using the filter
        +  FileUtils.copyDirectory(srcDir, destDir, filter);
        +  
        +
        Parameters:
        srcDir - an existing directory to copy, must not be null
        destDir - the new directory, must not be null
        filter - the filter to apply, null means copy all directories and files + should be the same as the original
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        copyDirectory

        +
        public static void copyDirectory(File srcDir,
        +                 File destDir,
        +                 FileFilter filter,
        +                 boolean preserveFileDate)
        +                          throws IOException
        +
        Copies a filtered directory to a new location. +

        + This method copies the contents of the specified source directory + to within the specified destination directory. +

        + The destination directory is created if it does not exist. + If the destination directory did exist, then this method merges + the source with the destination, with the source taking precedence. +

        + Note: Setting preserveFileDate to + true tries to preserve the files' last modified + date/times using File.setLastModified(long), however it is + not guaranteed that those operations will succeed. + If the modification operation fails, no indication is provided. +

        +

        Example: Copy directories only

        +
        +  // only copy the directory structure
        +  FileUtils.copyDirectory(srcDir, destDir, DirectoryFileFilter.DIRECTORY, false);
        +  
        + +

        Example: Copy directories and txt files

        +
        +  // Create a filter for ".txt" files
        +  IOFileFilter txtSuffixFilter = FileFilterUtils.suffixFileFilter(".txt");
        +  IOFileFilter txtFiles = FileFilterUtils.andFileFilter(FileFileFilter.FILE, txtSuffixFilter);
        +
        +  // Create a filter for either directories or ".txt" files
        +  FileFilter filter = FileFilterUtils.orFileFilter(DirectoryFileFilter.DIRECTORY, txtFiles);
        +
        +  // Copy using the filter
        +  FileUtils.copyDirectory(srcDir, destDir, filter, false);
        +  
        +
        Parameters:
        srcDir - an existing directory to copy, must not be null
        destDir - the new directory, must not be null
        filter - the filter to apply, null means copy all directories and files
        preserveFileDate - true if the file date of the copy + should be the same as the original
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        copyURLToFile

        +
        public static void copyURLToFile(URL source,
        +                 File destination)
        +                          throws IOException
        +
        Copies bytes from the URL source to a file + destination. The directories up to destination + will be created if they don't already exist. destination + will be overwritten if it already exists. +

        + Warning: this method does not set a connection or read timeout and thus + might block forever. Use copyURLToFile(URL, File, int, int) + with reasonable timeouts to prevent this.

        +
        Parameters:
        source - the URL to copy bytes from, must not be null
        destination - the non-directory File to write bytes to + (possibly overwriting), must not be null
        +
        Throws:
        +
        IOException - if source URL cannot be opened
        +
        IOException - if destination is a directory
        +
        IOException - if destination cannot be written
        +
        IOException - if destination needs creating but can't be
        +
        IOException - if an IO error occurs during copying
        +
      • +
      + + + +
        +
      • +

        copyURLToFile

        +
        public static void copyURLToFile(URL source,
        +                 File destination,
        +                 int connectionTimeout,
        +                 int readTimeout)
        +                          throws IOException
        +
        Copies bytes from the URL source to a file + destination. The directories up to destination + will be created if they don't already exist. destination + will be overwritten if it already exists.
        +
        Parameters:
        source - the URL to copy bytes from, must not be null
        destination - the non-directory File to write bytes to + (possibly overwriting), must not be null
        connectionTimeout - the number of milliseconds until this method + will timeout if no connection could be established to the source
        readTimeout - the number of milliseconds until this method will + timeout if no data could be read from the source
        +
        Throws:
        +
        IOException - if source URL cannot be opened
        +
        IOException - if destination is a directory
        +
        IOException - if destination cannot be written
        +
        IOException - if destination needs creating but can't be
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        copyInputStreamToFile

        +
        public static void copyInputStreamToFile(InputStream source,
        +                         File destination)
        +                                  throws IOException
        +
        Copies bytes from an InputStream source to a file + destination. The directories up to destination + will be created if they don't already exist. destination + will be overwritten if it already exists. + The source stream is closed. + See copyToFile(InputStream, File) for a method that does not close the input stream.
        +
        Parameters:
        source - the InputStream to copy bytes from, must not be null, will be closed
        destination - the non-directory File to write bytes to + (possibly overwriting), must not be null
        +
        Throws:
        +
        IOException - if destination is a directory
        +
        IOException - if destination cannot be written
        +
        IOException - if destination needs creating but can't be
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        copyToFile

        +
        public static void copyToFile(InputStream source,
        +              File destination)
        +                       throws IOException
        +
        Copies bytes from an InputStream source to a file + destination. The directories up to destination + will be created if they don't already exist. destination + will be overwritten if it already exists. + The source stream is left open, e.g. for use with ZipInputStream. + See copyInputStreamToFile(InputStream, File) for a method that closes the input stream.
        +
        Parameters:
        source - the InputStream to copy bytes from, must not be null
        destination - the non-directory File to write bytes to + (possibly overwriting), must not be null
        +
        Throws:
        +
        IOException - if destination is a directory
        +
        IOException - if destination cannot be written
        +
        IOException - if destination needs creating but can't be
        +
        IOException - if an IO error occurs during copying
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        deleteDirectory

        +
        public static void deleteDirectory(File directory)
        +                            throws IOException
        +
        Deletes a directory recursively.
        +
        Parameters:
        directory - directory to delete
        +
        Throws:
        +
        IOException - in case deletion is unsuccessful
        +
        IllegalArgumentException - if directory does not exist or is not a directory
        +
      • +
      + + + +
        +
      • +

        deleteQuietly

        +
        public static boolean deleteQuietly(File file)
        +
        Deletes a file, never throwing an exception. If file is a directory, delete it and all sub-directories. +

        + The difference between File.delete() and this method are: +

          +
        • A directory to be deleted does not have to be empty.
        • +
        • No exceptions are thrown when a file or directory cannot be deleted.
        • +
        +
        Parameters:
        file - file or directory to delete, can be null
        +
        Returns:
        true if the file or directory was deleted, otherwise + false
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        directoryContains

        +
        public static boolean directoryContains(File directory,
        +                        File child)
        +                                 throws IOException
        +
        Determines whether the parent directory contains the child element (a file or directory). +

        + Files are normalized before comparison. +

        + + Edge cases: +
          +
        • A directory must not be null: if null, throw IllegalArgumentException
        • +
        • A directory must be a directory: if not a directory, throw IllegalArgumentException
        • +
        • A directory does not contain itself: return false
        • +
        • A null child file is not contained in any parent: return false
        • +
        +
        Parameters:
        directory - the file to consider as the parent.
        child - the file to consider as the child.
        +
        Returns:
        true is the candidate leaf is under by the specified composite. False otherwise.
        +
        Throws:
        +
        IOException - if an IO error occurs while checking the files.
        +
        IllegalArgumentException - if directory is null or not a directory.
        Since:
        +
        2.2
        +
        See Also:
        FilenameUtils.directoryContains(String, String)
        +
      • +
      + + + +
        +
      • +

        cleanDirectory

        +
        public static void cleanDirectory(File directory)
        +                           throws IOException
        +
        Cleans a directory without deleting it.
        +
        Parameters:
        directory - directory to clean
        +
        Throws:
        +
        IOException - in case cleaning is unsuccessful
        +
        IllegalArgumentException - if directory does not exist or is not a directory
        +
      • +
      + + + +
        +
      • +

        waitFor

        +
        public static boolean waitFor(File file,
        +              int seconds)
        +
        Waits for NFS to propagate a file creation, imposing a timeout. +

        + This method repeatedly tests File.exists() until it returns + true up to the maximum time specified in seconds.

        +
        Parameters:
        file - the file to check, must not be null
        seconds - the maximum time in seconds to wait
        +
        Returns:
        true if file exists
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
      • +
      + + + +
        +
      • +

        readFileToString

        +
        public static String readFileToString(File file,
        +                      Charset encoding)
        +                               throws IOException
        +
        Reads the contents of a file into a String. + The file is always closed.
        +
        Parameters:
        file - the file to read, must not be null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the file contents, never null
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        readFileToString

        +
        public static String readFileToString(File file,
        +                      String encoding)
        +                               throws IOException
        +
        Reads the contents of a file into a String. The file is always closed.
        +
        Parameters:
        file - the file to read, must not be null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the file contents, never null
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the encoding is not supported.
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        readFileToString

        +
        @Deprecated
        +public static String readFileToString(File file)
        +                               throws IOException
        +
        Deprecated. 2.5 use readFileToString(File, Charset) instead
        +
        Reads the contents of a file into a String using the default encoding for the VM. + The file is always closed.
        +
        Parameters:
        file - the file to read, must not be null
        +
        Returns:
        the file contents, never null
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        1.3.1
        +
      • +
      + + + +
        +
      • +

        readFileToByteArray

        +
        public static byte[] readFileToByteArray(File file)
        +                                  throws IOException
        +
        Reads the contents of a file into a byte array. + The file is always closed.
        +
        Parameters:
        file - the file to read, must not be null
        +
        Returns:
        the file contents, never null
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        readLines

        +
        public static List<String> readLines(File file,
        +                     Charset encoding)
        +                              throws IOException
        +
        Reads the contents of a file line by line to a List of Strings. + The file is always closed.
        +
        Parameters:
        file - the file to read, must not be null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the list of Strings representing each line in the file, never null
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        readLines

        +
        public static List<String> readLines(File file,
        +                     String encoding)
        +                              throws IOException
        +
        Reads the contents of a file line by line to a List of Strings. The file is always closed.
        +
        Parameters:
        file - the file to read, must not be null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the list of Strings representing each line in the file, never null
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        readLines

        +
        @Deprecated
        +public static List<String> readLines(File file)
        +                              throws IOException
        +
        Deprecated. 2.5 use readLines(File, Charset) instead
        +
        Reads the contents of a file line by line to a List of Strings using the default encoding for the VM. + The file is always closed.
        +
        Parameters:
        file - the file to read, must not be null
        +
        Returns:
        the list of Strings representing each line in the file, never null
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        lineIterator

        +
        public static LineIterator lineIterator(File file,
        +                        String encoding)
        +                                 throws IOException
        +
        Returns an Iterator for the lines in a File. +

        + This method opens an InputStream for the file. + When you have finished with the iterator you should close the stream + to free internal resources. This can be done by calling the + LineIterator.close() or + LineIterator.closeQuietly(LineIterator) method. +

        + The recommended usage pattern is: +

        + LineIterator it = FileUtils.lineIterator(file, "UTF-8");
        + try {
        +   while (it.hasNext()) {
        +     String line = it.nextLine();
        +     /// do something with line
        +   }
        + } finally {
        +   LineIterator.closeQuietly(iterator);
        + }
        + 
        +

        + If an exception occurs during the creation of the iterator, the + underlying stream is closed.

        +
        Parameters:
        file - the file to open for input, must not be null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        an Iterator of the lines in the file, never null
        +
        Throws:
        +
        IOException - in case of an I/O error (file closed)
        Since:
        +
        1.2
        +
      • +
      + + + +
        +
      • +

        lineIterator

        +
        public static LineIterator lineIterator(File file)
        +                                 throws IOException
        +
        Returns an Iterator for the lines in a File using the default encoding for the VM.
        +
        Parameters:
        file - the file to open for input, must not be null
        +
        Returns:
        an Iterator of the lines in the file, never null
        +
        Throws:
        +
        IOException - in case of an I/O error (file closed)
        Since:
        +
        1.3
        +
        See Also:
        lineIterator(File, String)
        +
      • +
      + + + +
        +
      • +

        writeStringToFile

        +
        public static void writeStringToFile(File file,
        +                     String data,
        +                     Charset encoding)
        +                              throws IOException
        +
        Writes a String to a file creating the file if it does not exist. +

        + NOTE: As from v1.3, the parent directories of the file will be created + if they do not exist.

        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedEncodingException - if the encoding is not supported by the VM
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        writeStringToFile

        +
        public static void writeStringToFile(File file,
        +                     String data,
        +                     String encoding)
        +                              throws IOException
        +
        Writes a String to a file creating the file if it does not exist. +

        + NOTE: As from v1.3, the parent directories of the file will be created + if they do not exist.

        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedEncodingException - if the encoding is not supported by the VM
        +
      • +
      + + + +
        +
      • +

        writeStringToFile

        +
        public static void writeStringToFile(File file,
        +                     String data,
        +                     Charset encoding,
        +                     boolean append)
        +                              throws IOException
        +
        Writes a String to a file creating the file if it does not exist.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        append - if true, then the String will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        writeStringToFile

        +
        public static void writeStringToFile(File file,
        +                     String data,
        +                     String encoding,
        +                     boolean append)
        +                              throws IOException
        +
        Writes a String to a file creating the file if it does not exist.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        append - if true, then the String will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the encoding is not supported by the VM
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        writeStringToFile

        +
        @Deprecated
        +public static void writeStringToFile(File file,
        +                                String data)
        +                              throws IOException
        +
        Deprecated. 2.5 use writeStringToFile(File, String, Charset) instead
        +
        Writes a String to a file creating the file if it does not exist using the default encoding for the VM.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        writeStringToFile

        +
        @Deprecated
        +public static void writeStringToFile(File file,
        +                                String data,
        +                                boolean append)
        +                              throws IOException
        + +
        Writes a String to a file creating the file if it does not exist using the default encoding for the VM.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        append - if true, then the String will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        write

        +
        @Deprecated
        +public static void write(File file,
        +                    CharSequence data)
        +                  throws IOException
        +
        Deprecated. 2.5 use write(File, CharSequence, Charset) instead
        +
        Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        write

        +
        @Deprecated
        +public static void write(File file,
        +                    CharSequence data,
        +                    boolean append)
        +                  throws IOException
        +
        Deprecated. 2.5 use write(File, CharSequence, Charset, boolean) instead
        +
        Writes a CharSequence to a file creating the file if it does not exist using the default encoding for the VM.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        append - if true, then the data will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        write

        +
        public static void write(File file,
        +         CharSequence data,
        +         Charset encoding)
        +                  throws IOException
        +
        Writes a CharSequence to a file creating the file if it does not exist.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        write

        +
        public static void write(File file,
        +         CharSequence data,
        +         String encoding)
        +                  throws IOException
        +
        Writes a CharSequence to a file creating the file if it does not exist.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedEncodingException - if the encoding is not supported by the VM
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        write

        +
        public static void write(File file,
        +         CharSequence data,
        +         Charset encoding,
        +         boolean append)
        +                  throws IOException
        +
        Writes a CharSequence to a file creating the file if it does not exist.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        append - if true, then the data will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        write

        +
        public static void write(File file,
        +         CharSequence data,
        +         String encoding,
        +         boolean append)
        +                  throws IOException
        +
        Writes a CharSequence to a file creating the file if it does not exist.
        +
        Parameters:
        file - the file to write
        data - the content to write to the file
        encoding - the encoding to use, null means platform default
        append - if true, then the data will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the encoding is not supported by the VM
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        writeByteArrayToFile

        +
        public static void writeByteArrayToFile(File file,
        +                        byte[] data)
        +                                 throws IOException
        +
        Writes a byte array to a file creating the file if it does not exist. +

        + NOTE: As from v1.3, the parent directories of the file will be created + if they do not exist.

        +
        Parameters:
        file - the file to write to
        data - the content to write to the file
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        writeByteArrayToFile

        +
        public static void writeByteArrayToFile(File file,
        +                        byte[] data,
        +                        boolean append)
        +                                 throws IOException
        +
        Writes a byte array to a file creating the file if it does not exist.
        +
        Parameters:
        file - the file to write to
        data - the content to write to the file
        append - if true, then bytes will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        writeByteArrayToFile

        +
        public static void writeByteArrayToFile(File file,
        +                        byte[] data,
        +                        int off,
        +                        int len)
        +                                 throws IOException
        +
        Writes len bytes from the specified byte array starting + at offset off to a file, creating the file if it does + not exist.
        +
        Parameters:
        file - the file to write to
        data - the content to write to the file
        off - the start offset in the data
        len - the number of bytes to write
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        writeByteArrayToFile

        +
        public static void writeByteArrayToFile(File file,
        +                        byte[] data,
        +                        int off,
        +                        int len,
        +                        boolean append)
        +                                 throws IOException
        +
        Writes len bytes from the specified byte array starting + at offset off to a file, creating the file if it does + not exist.
        +
        Parameters:
        file - the file to write to
        data - the content to write to the file
        off - the start offset in the data
        len - the number of bytes to write
        append - if true, then bytes will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              String encoding,
        +              Collection<?> lines)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line. + The specified character encoding and the default line ending will be used. +

        + NOTE: As from v1.3, the parent directories of the file will be created + if they do not exist.

        +
        Parameters:
        file - the file to write to
        encoding - the encoding to use, null means platform default
        lines - the lines to write, null entries produce blank lines
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedEncodingException - if the encoding is not supported by the VM
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              String encoding,
        +              Collection<?> lines,
        +              boolean append)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line, optionally appending. + The specified character encoding and the default line ending will be used.
        +
        Parameters:
        file - the file to write to
        encoding - the encoding to use, null means platform default
        lines - the lines to write, null entries produce blank lines
        append - if true, then the lines will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedEncodingException - if the encoding is not supported by the VM
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              Collection<?> lines)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line. + The default VM encoding and the default line ending will be used.
        +
        Parameters:
        file - the file to write to
        lines - the lines to write, null entries produce blank lines
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              Collection<?> lines,
        +              boolean append)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line. + The default VM encoding and the default line ending will be used.
        +
        Parameters:
        file - the file to write to
        lines - the lines to write, null entries produce blank lines
        append - if true, then the lines will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              String encoding,
        +              Collection<?> lines,
        +              String lineEnding)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line. + The specified character encoding and the line ending will be used. +

        + NOTE: As from v1.3, the parent directories of the file will be created + if they do not exist.

        +
        Parameters:
        file - the file to write to
        encoding - the encoding to use, null means platform default
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedEncodingException - if the encoding is not supported by the VM
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              String encoding,
        +              Collection<?> lines,
        +              String lineEnding,
        +              boolean append)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line. + The specified character encoding and the line ending will be used.
        +
        Parameters:
        file - the file to write to
        encoding - the encoding to use, null means platform default
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        append - if true, then the lines will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        +
        UnsupportedEncodingException - if the encoding is not supported by the VM
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              Collection<?> lines,
        +              String lineEnding)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line. + The default VM encoding and the specified line ending will be used.
        +
        Parameters:
        file - the file to write to
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(File file,
        +              Collection<?> lines,
        +              String lineEnding,
        +              boolean append)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + the specified File line by line. + The default VM encoding and the specified line ending will be used.
        +
        Parameters:
        file - the file to write to
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        append - if true, then the lines will be added to the + end of the file rather than overwriting
        +
        Throws:
        +
        IOException - in case of an I/O error
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        forceDelete

        +
        public static void forceDelete(File file)
        +                        throws IOException
        +
        Deletes a file. If file is a directory, delete it and all sub-directories. +

        + The difference between File.delete() and this method are: +

          +
        • A directory to be deleted does not have to be empty.
        • +
        • You get exceptions when a file or directory cannot be deleted. + (java.io.File methods returns a boolean)
        • +
        +
        Parameters:
        file - file or directory to delete, must not be null
        +
        Throws:
        +
        NullPointerException - if the directory is null
        +
        FileNotFoundException - if the file was not found
        +
        IOException - in case deletion is unsuccessful
        +
      • +
      + + + +
        +
      • +

        forceDeleteOnExit

        +
        public static void forceDeleteOnExit(File file)
        +                              throws IOException
        +
        Schedules a file to be deleted when JVM exits. + If file is directory delete it and all sub-directories.
        +
        Parameters:
        file - file or directory to delete, must not be null
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case deletion is unsuccessful
        +
      • +
      + + + +
        +
      • +

        forceMkdir

        +
        public static void forceMkdir(File directory)
        +                       throws IOException
        +
        Makes a directory, including any necessary but nonexistent parent + directories. If a file already exists with specified name but it is + not a directory then an IOException is thrown. + If the directory cannot be created (or does not already exist) + then an IOException is thrown.
        +
        Parameters:
        directory - directory to create, must not be null
        +
        Throws:
        +
        NullPointerException - if the directory is null
        +
        IOException - if the directory cannot be created or the file already exists but is not a directory
        +
      • +
      + + + +
        +
      • +

        forceMkdirParent

        +
        public static void forceMkdirParent(File file)
        +                             throws IOException
        +
        Makes any necessary but nonexistent parent directories for a given File. If the parent directory cannot be + created then an IOException is thrown.
        +
        Parameters:
        file - file with parent to create, must not be null
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - if the parent directory cannot be created
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        sizeOf

        +
        public static long sizeOf(File file)
        +
        Returns the size of the specified file or directory. If the provided + File is a regular file, then the file's length is returned. + If the argument is a directory, then the size of the directory is + calculated recursively. If a directory or subdirectory is security + restricted, its size will not be included. +

        + Note that overflow is not detected, and the return value may be negative if + overflow occurs. See sizeOfAsBigInteger(File) for an alternative + method that does not overflow.

        +
        Parameters:
        file - the regular file or directory to return the size + of (must not be null).
        +
        Returns:
        the length of the file, or recursive size of the directory, + provided (in bytes).
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IllegalArgumentException - if the file does not exist.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sizeOfAsBigInteger

        +
        public static BigInteger sizeOfAsBigInteger(File file)
        +
        Returns the size of the specified file or directory. If the provided + File is a regular file, then the file's length is returned. + If the argument is a directory, then the size of the directory is + calculated recursively. If a directory or subdirectory is security + restricted, its size will not be included.
        +
        Parameters:
        file - the regular file or directory to return the size + of (must not be null).
        +
        Returns:
        the length of the file, or recursive size of the directory, + provided (in bytes).
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IllegalArgumentException - if the file does not exist.
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        sizeOfDirectory

        +
        public static long sizeOfDirectory(File directory)
        +
        Counts the size of a directory recursively (sum of the length of all files). +

        + Note that overflow is not detected, and the return value may be negative if + overflow occurs. See sizeOfDirectoryAsBigInteger(File) for an alternative + method that does not overflow.

        +
        Parameters:
        directory - directory to inspect, must not be null
        +
        Returns:
        size of directory in bytes, 0 if directory is security restricted, a negative number when the real total + is greater than Long.MAX_VALUE.
        +
        Throws:
        +
        NullPointerException - if the directory is null
        +
      • +
      + + + +
        +
      • +

        sizeOfDirectoryAsBigInteger

        +
        public static BigInteger sizeOfDirectoryAsBigInteger(File directory)
        +
        Counts the size of a directory recursively (sum of the length of all files).
        +
        Parameters:
        directory - directory to inspect, must not be null
        +
        Returns:
        size of directory in bytes, 0 if directory is security restricted.
        +
        Throws:
        +
        NullPointerException - if the directory is null
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        isFileNewer

        +
        public static boolean isFileNewer(File file,
        +                  File reference)
        +
        Tests if the specified File is newer than the reference + File.
        +
        Parameters:
        file - the File of which the modification date must + be compared, must not be null
        reference - the File of which the modification date + is used, must not be null
        +
        Returns:
        true if the File exists and has been modified more + recently than the reference File
        +
        Throws:
        +
        IllegalArgumentException - if the file is null
        +
        IllegalArgumentException - if the reference file is null or doesn't exist
        +
      • +
      + + + +
        +
      • +

        isFileNewer

        +
        public static boolean isFileNewer(File file,
        +                  Date date)
        +
        Tests if the specified File is newer than the specified + Date.
        +
        Parameters:
        file - the File of which the modification date + must be compared, must not be null
        date - the date reference, must not be null
        +
        Returns:
        true if the File exists and has been modified + after the given Date.
        +
        Throws:
        +
        IllegalArgumentException - if the file is null
        +
        IllegalArgumentException - if the date is null
        +
      • +
      + + + +
        +
      • +

        isFileNewer

        +
        public static boolean isFileNewer(File file,
        +                  long timeMillis)
        +
        Tests if the specified File is newer than the specified + time reference.
        +
        Parameters:
        file - the File of which the modification date must + be compared, must not be null
        timeMillis - the time reference measured in milliseconds since the + epoch (00:00:00 GMT, January 1, 1970)
        +
        Returns:
        true if the File exists and has been modified after + the given time reference.
        +
        Throws:
        +
        IllegalArgumentException - if the file is null
        +
      • +
      + + + +
        +
      • +

        isFileOlder

        +
        public static boolean isFileOlder(File file,
        +                  File reference)
        +
        Tests if the specified File is older than the reference + File.
        +
        Parameters:
        file - the File of which the modification date must + be compared, must not be null
        reference - the File of which the modification date + is used, must not be null
        +
        Returns:
        true if the File exists and has been modified before + the reference File
        +
        Throws:
        +
        IllegalArgumentException - if the file is null
        +
        IllegalArgumentException - if the reference file is null or doesn't exist
        +
      • +
      + + + +
        +
      • +

        isFileOlder

        +
        public static boolean isFileOlder(File file,
        +                  Date date)
        +
        Tests if the specified File is older than the specified + Date.
        +
        Parameters:
        file - the File of which the modification date + must be compared, must not be null
        date - the date reference, must not be null
        +
        Returns:
        true if the File exists and has been modified + before the given Date.
        +
        Throws:
        +
        IllegalArgumentException - if the file is null
        +
        IllegalArgumentException - if the date is null
        +
      • +
      + + + +
        +
      • +

        isFileOlder

        +
        public static boolean isFileOlder(File file,
        +                  long timeMillis)
        +
        Tests if the specified File is older than the specified + time reference.
        +
        Parameters:
        file - the File of which the modification date must + be compared, must not be null
        timeMillis - the time reference measured in milliseconds since the + epoch (00:00:00 GMT, January 1, 1970)
        +
        Returns:
        true if the File exists and has been modified before + the given time reference.
        +
        Throws:
        +
        IllegalArgumentException - if the file is null
        +
      • +
      + + + +
        +
      • +

        checksumCRC32

        +
        public static long checksumCRC32(File file)
        +                          throws IOException
        +
        Computes the checksum of a file using the CRC32 checksum routine. + The value of the checksum is returned.
        +
        Parameters:
        file - the file to checksum, must not be null
        +
        Returns:
        the checksum value
        +
        Throws:
        +
        NullPointerException - if the file or checksum is null
        +
        IllegalArgumentException - if the file is a directory
        +
        IOException - if an IO error occurs reading the file
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        checksum

        +
        public static Checksum checksum(File file,
        +                Checksum checksum)
        +                         throws IOException
        +
        Computes the checksum of a file using the specified checksum object. + Multiple files may be checked using one Checksum instance + if desired simply by reusing the same checksum object. + For example: +
        +   long csum = FileUtils.checksum(file, new CRC32()).getValue();
        + 
        +
        Parameters:
        file - the file to checksum, must not be null
        checksum - the checksum object to be used, must not be null
        +
        Returns:
        the checksum specified, updated with the content of the file
        +
        Throws:
        +
        NullPointerException - if the file or checksum is null
        +
        IllegalArgumentException - if the file is a directory
        +
        IOException - if an IO error occurs reading the file
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        moveDirectory

        +
        public static void moveDirectory(File srcDir,
        +                 File destDir)
        +                          throws IOException
        +
        Moves a directory. +

        + When the destination directory is on another file system, do a "copy and delete".

        +
        Parameters:
        srcDir - the directory to be moved
        destDir - the destination directory
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        FileExistsException - if the destination directory exists
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs moving the file
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        moveDirectoryToDirectory

        +
        public static void moveDirectoryToDirectory(File src,
        +                            File destDir,
        +                            boolean createDestDir)
        +                                     throws IOException
        +
        Moves a directory to another directory.
        +
        Parameters:
        src - the file to be moved
        destDir - the destination file
        createDestDir - If true create the destination directory, + otherwise if false throw an IOException
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        FileExistsException - if the directory exists in the destination directory
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs moving the file
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        moveFile

        +
        public static void moveFile(File srcFile,
        +            File destFile)
        +                     throws IOException
        +
        Moves a file. +

        + When the destination file is on another file system, do a "copy and delete".

        +
        Parameters:
        srcFile - the file to be moved
        destFile - the destination file
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        FileExistsException - if the destination file exists
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs moving the file
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        moveFileToDirectory

        +
        public static void moveFileToDirectory(File srcFile,
        +                       File destDir,
        +                       boolean createDestDir)
        +                                throws IOException
        +
        Moves a file to a directory.
        +
        Parameters:
        srcFile - the file to be moved
        destDir - the destination file
        createDestDir - If true create the destination directory, + otherwise if false throw an IOException
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        FileExistsException - if the destination file exists
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs moving the file
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        moveToDirectory

        +
        public static void moveToDirectory(File src,
        +                   File destDir,
        +                   boolean createDestDir)
        +                            throws IOException
        +
        Moves a file or directory to the destination directory. +

        + When the destination is on another file system, do a "copy and delete".

        +
        Parameters:
        src - the file or directory to be moved
        destDir - the destination directory
        createDestDir - If true create the destination directory, + otherwise if false throw an IOException
        +
        Throws:
        +
        NullPointerException - if source or destination is null
        +
        FileExistsException - if the directory or file exists in the destination directory
        +
        IOException - if source or destination is invalid
        +
        IOException - if an IO error occurs moving the file
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        isSymlink

        +
        public static boolean isSymlink(File file)
        +                         throws IOException
        +
        Determines whether the specified file is a Symbolic Link rather than an actual file. +

        + Will not return true if there is a Symbolic Link anywhere in the path, + only if the specific file is. +

        + When using jdk1.7, this method delegates to boolean java.nio.file.Files.isSymbolicLink(Path path) + + Note: the current implementation always returns false if running on + jkd1.6 and the system is detected as Windows using FilenameUtils.isSystemWindows() +

        + For code that runs on Java 1.7 or later, use the following method instead: +
        + boolean java.nio.file.Files.isSymbolicLink(Path path)

        +
        Parameters:
        file - the file to check
        +
        Returns:
        true if the file is a Symbolic Link
        +
        Throws:
        +
        IOException - if an IO error occurs while checking the file
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FilenameUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FilenameUtils.html" index e9cd38d7fb46b9670842fb01697c43d4e8cf826d..fec6b6e236641b2fd5e06bc7159955f4d71d9b94 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FilenameUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/FilenameUtils.html" @@ -1,3 +1,1432 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d741723b2e9b2880036bbc91c5ba867cf8c0fd6b8e033c914f4e060bda91507b -size 86736 + + + + + +FilenameUtils (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class FilenameUtils

+
+
+ +
+
    +
  • +
    +
    +
    public class FilenameUtils
    +extends Object
    +
    General filename and filepath manipulation utilities. +

    + 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. +

    + NOTE: You may be able to avoid using this class entirely simply by + using JDK File objects and the two argument constructor + File(File,String). +

    + 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. +

    + Most methods recognise both separators (forward and back), and both + sets of prefixes. See the javadoc of each method for details. +

    + This class defines six components within a filename + (example C:\dev\project\file.txt): +

      +
    • the prefix - C:\
    • +
    • the path - dev\project\
    • +
    • the full path - C:\dev\project\
    • +
    • the name - file.txt
    • +
    • the base name - file
    • +
    • the extension - txt
    • +
    + 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. +

    + This class only supports Unix and Windows style names. + Prefixes are matched as follows: +

    + 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)
    + 
    + Both prefix styles are matched always, irrespective of the machine that you are + currently running on. +

    + Origin of code: Excalibur, Alexandria, Tomcat, Commons-Utils.

    +
    Since:
    +
    1.1
    +
    Version:
    +
    $Id: FilenameUtils.java 1702170 2015-09-10 06:35:02Z krosenvold $
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      FilenameUtils() +
      Instances should NOT be constructed in standard programming.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      static Stringconcat(String basePath, + String fullFilenameToAdd) +
      Concatenates a filename to a base path using normal command line style rules.
      +
      static booleandirectoryContains(String canonicalParent, + String canonicalChild) +
      Determines whether the parent directory contains the child element (a file or directory).
      +
      static booleanequals(String filename1, + String filename2) +
      Checks whether two filenames are equal exactly.
      +
      static booleanequals(String filename1, + String filename2, + boolean normalized, + IOCase caseSensitivity) +
      Checks whether two filenames are equal, optionally normalizing and providing + control over the case-sensitivity.
      +
      static booleanequalsNormalized(String filename1, + String filename2) +
      Checks whether two filenames are equal after both have been normalized.
      +
      static booleanequalsNormalizedOnSystem(String filename1, + String filename2) +
      Checks whether two filenames are equal after both have been normalized + and using the case rules of the system.
      +
      static booleanequalsOnSystem(String filename1, + String filename2) +
      Checks whether two filenames are equal using the case rules of the system.
      +
      static StringgetBaseName(String filename) +
      Gets the base name, minus the full path and extension, from a full filename.
      +
      static StringgetExtension(String filename) +
      Gets the extension of a filename.
      +
      static StringgetFullPath(String filename) +
      Gets the full path from a full filename, which is the prefix + path.
      +
      static StringgetFullPathNoEndSeparator(String filename) +
      Gets the full path from a full filename, which is the prefix + path, + and also excluding the final directory separator.
      +
      static StringgetName(String filename) +
      Gets the name minus the path from a full filename.
      +
      static StringgetPath(String filename) +
      Gets the path from a full filename, which excludes the prefix.
      +
      static StringgetPathNoEndSeparator(String filename) +
      Gets the path from a full filename, which excludes the prefix, and + also excluding the final directory separator.
      +
      static StringgetPrefix(String filename) +
      Gets the prefix from a full filename, such as C:/ + or ~/.
      +
      static intgetPrefixLength(String filename) +
      Returns the length of the filename prefix, such as C:/ or ~/.
      +
      static intindexOfExtension(String filename) +
      Returns the index of the last extension separator character, which is a dot.
      +
      static intindexOfLastSeparator(String filename) +
      Returns the index of the last directory separator character.
      +
      static booleanisExtension(String filename, + Collection<String> extensions) +
      Checks whether the extension of the filename is one of those specified.
      +
      static booleanisExtension(String filename, + String extension) +
      Checks whether the extension of the filename is that specified.
      +
      static booleanisExtension(String filename, + String[] extensions) +
      Checks whether the extension of the filename is one of those specified.
      +
      static Stringnormalize(String filename) +
      Normalizes a path, removing double and single dot path steps.
      +
      static Stringnormalize(String filename, + boolean unixSeparator) +
      Normalizes a path, removing double and single dot path steps.
      +
      static StringnormalizeNoEndSeparator(String filename) +
      Normalizes a path, removing double and single dot path steps, + and removing any final directory separator.
      +
      static StringnormalizeNoEndSeparator(String filename, + boolean unixSeparator) +
      Normalizes a path, removing double and single dot path steps, + and removing any final directory separator.
      +
      static StringremoveExtension(String filename) +
      Removes the extension from a filename.
      +
      static StringseparatorsToSystem(String path) +
      Converts all separators to the system separator.
      +
      static StringseparatorsToUnix(String path) +
      Converts all separators to the Unix separator of forward slash.
      +
      static StringseparatorsToWindows(String path) +
      Converts all separators to the Windows separator of backslash.
      +
      static booleanwildcardMatch(String filename, + String wildcardMatcher) +
      Checks a filename to see if it matches the specified wildcard matcher, + always testing case-sensitive.
      +
      static booleanwildcardMatch(String filename, + String wildcardMatcher, + IOCase caseSensitivity) +
      Checks a filename to see if it matches the specified wildcard matcher + allowing control over case-sensitivity.
      +
      static booleanwildcardMatchOnSystem(String filename, + String wildcardMatcher) +
      Checks a filename to see if it matches the specified wildcard matcher + using the case rules of the system.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        EXTENSION_SEPARATOR

        +
        public static final char EXTENSION_SEPARATOR
        +
        The extension separator character.
        +
        Since:
        +
        1.4
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        EXTENSION_SEPARATOR_STR

        +
        public static final String EXTENSION_SEPARATOR_STR
        +
        The extension separator String.
        +
        Since:
        +
        1.4
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FilenameUtils

        +
        public FilenameUtils()
        +
        Instances should NOT be constructed in standard programming.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        normalize

        +
        public static String normalize(String filename)
        +
        Normalizes a path, removing double and single dot path steps. +

        + 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. +

        + 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, null + is returned. +

        + The output will be the same on both Unix and Windows except + for the separator character. +

        + /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
        + 
        + (Note the file separator returned will be correct for Windows/Unix)
        +
        Parameters:
        filename - the filename to normalize, null returns null
        +
        Returns:
        the normalized filename, or null if invalid. Null bytes inside string will be removed
        +
      • +
      + + + +
        +
      • +

        normalize

        +
        public static String normalize(String filename,
        +               boolean unixSeparator)
        +
        Normalizes a path, removing double and single dot path steps. +

        + 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. +

        + 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, null + is returned. +

        + The output will be the same on both Unix and Windows except + for the separator character. +

        + /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
        + 
        + The output will be the same on both Unix and Windows including + the separator character.
        +
        Parameters:
        filename - the filename to normalize, null returns null
        unixSeparator - true if a unix separator should + be used or false if a windows separator should be used.
        +
        Returns:
        the normalized filename, or null if invalid. Null bytes inside string will be removed
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        normalizeNoEndSeparator

        +
        public static String normalizeNoEndSeparator(String filename)
        +
        Normalizes a path, removing double and single dot path steps, + and removing any final directory separator. +

        + 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. +

        + 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, null + is returned. +

        + The output will be the same on both Unix and Windows except + for the separator character. +

        + /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
        + 
        + (Note the file separator returned will be correct for Windows/Unix)
        +
        Parameters:
        filename - the filename to normalize, null returns null
        +
        Returns:
        the normalized filename, or null if invalid. Null bytes inside string will be removed
        +
      • +
      + + + +
        +
      • +

        normalizeNoEndSeparator

        +
        public static String normalizeNoEndSeparator(String filename,
        +                             boolean unixSeparator)
        +
        Normalizes a path, removing double and single dot path steps, + and removing any final directory separator. +

        + 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. +

        + 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, null + is returned. +

        + The output will be the same on both Unix and Windows including + the separator character. +

        + /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
        + 
        +
        Parameters:
        filename - the filename to normalize, null returns null
        unixSeparator - true if a unix separator should + be used or false if a windows separtor should be used.
        +
        Returns:
        the normalized filename, or null if invalid. Null bytes inside string will be removed
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        concat

        +
        public static String concat(String basePath,
        +            String fullFilenameToAdd)
        +
        Concatenates a filename to a base path using normal command line style rules. +

        + The effect is equivalent to resultant directory after changing + directory to the first argument, followed by changing directory to + the second argument. +

        + The first argument is the base path, the second is the path to concatenate. + The returned path is always normalized via normalize(String), + thus .. is handled. +

        + If pathToAdd is absolute (has an absolute prefix), then + it will be normalized and returned. + Otherwise, the paths will be joined, normalized and returned. +

        + The output will be the same on both Unix and Windows except + for the separator character. +

        + /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 (!)
        + 
        + (*) 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 getFullPath(String) on the base path argument.
        +
        Parameters:
        basePath - the base path to attach to, always treated as a path
        fullFilenameToAdd - the filename (or path) to attach to the base
        +
        Returns:
        the concatenated path, or null if invalid. Null bytes inside string will be removed
        +
      • +
      + + + +
        +
      • +

        directoryContains

        +
        public static boolean directoryContains(String canonicalParent,
        +                        String canonicalChild)
        +                                 throws IOException
        +
        Determines whether the parent directory contains the child element (a file or directory). +

        + The files names are expected to be normalized. +

        + + Edge cases: +
          +
        • A directory must not be null: if null, throw IllegalArgumentException
        • +
        • A directory does not contain itself: return false
        • +
        • A null child file is not contained in any parent: return false
        • +
        +
        Parameters:
        canonicalParent - the file to consider as the parent.
        canonicalChild - the file to consider as the child.
        +
        Returns:
        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 Also:
        FileUtils.directoryContains(File, File)
        +
      • +
      + + + +
        +
      • +

        separatorsToUnix

        +
        public static String separatorsToUnix(String path)
        +
        Converts all separators to the Unix separator of forward slash.
        +
        Parameters:
        path - the path to be changed, null ignored
        +
        Returns:
        the updated path
        +
      • +
      + + + +
        +
      • +

        separatorsToWindows

        +
        public static String separatorsToWindows(String path)
        +
        Converts all separators to the Windows separator of backslash.
        +
        Parameters:
        path - the path to be changed, null ignored
        +
        Returns:
        the updated path
        +
      • +
      + + + +
        +
      • +

        separatorsToSystem

        +
        public static String separatorsToSystem(String path)
        +
        Converts all separators to the system separator.
        +
        Parameters:
        path - the path to be changed, null ignored
        +
        Returns:
        the updated path
        +
      • +
      + + + +
        +
      • +

        getPrefixLength

        +
        public static int getPrefixLength(String filename)
        +
        Returns the length of the filename prefix, such as C:/ or ~/. +

        + This method will handle a file in either Unix or Windows format. +

        + 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. +

        + 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
        + 
        +

        + 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.

        +
        Parameters:
        filename - the filename to find the prefix in, null returns -1
        +
        Returns:
        the length of the prefix, -1 if invalid or null
        +
      • +
      + + + +
        +
      • +

        indexOfLastSeparator

        +
        public static int indexOfLastSeparator(String filename)
        +
        Returns the index of the last directory separator character. +

        + This method will handle a file in either Unix or Windows format. + The position of the last forward or backslash is returned. +

        + The output will be the same irrespective of the machine that the code is running on.

        +
        Parameters:
        filename - the filename to find the last path separator in, null returns -1
        +
        Returns:
        the index of the last separator character, or -1 if there + is no such character
        +
      • +
      + + + +
        +
      • +

        indexOfExtension

        +
        public static int indexOfExtension(String filename)
        +
        Returns the index of the last extension separator character, which is a dot. +

        + This method also checks that there is no directory separator after the last dot. To do this it uses + indexOfLastSeparator(String) which will handle a file in either Unix or Windows format. +

        +

        + The output will be the same irrespective of the machine that the code is running on. +

        +
        Parameters:
        filename - the filename to find the last extension separator in, null returns -1
        +
        Returns:
        the index of the last extension separator character, or -1 if there is no such character
        +
      • +
      + + + +
        +
      • +

        getPrefix

        +
        public static String getPrefix(String filename)
        +
        Gets the prefix from a full filename, such as C:/ + or ~/. +

        + This method will handle a file in either Unix or Windows format. + The prefix includes the first slash in the full filename where applicable. +

        + 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)
        + 
        +

        + 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.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the prefix of the file, null if invalid. Null bytes inside string will be removed
        +
      • +
      + + + +
        +
      • +

        getPath

        +
        public static String getPath(String filename)
        +
        Gets the path from a full filename, which excludes the prefix. +

        + 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. +

        + 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/
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on. +

        + This method drops the prefix from the result. + See getFullPath(String) for the method that retains the prefix.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the path of the file, an empty string if none exists, null if invalid. + Null bytes inside string will be removed
        +
      • +
      + + + +
        +
      • +

        getPathNoEndSeparator

        +
        public static String getPathNoEndSeparator(String filename)
        +
        Gets the path from a full filename, which excludes the prefix, and + also excluding the final directory separator. +

        + 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. +

        + 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
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on. +

        + This method drops the prefix from the result. + See getFullPathNoEndSeparator(String) for the method that retains the prefix.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the path of the file, an empty string if none exists, null if invalid. + Null bytes inside string will be removed
        +
      • +
      + + + +
        +
      • +

        getFullPath

        +
        public static String getFullPath(String filename)
        +
        Gets the full path from a full filename, which is the prefix + path. +

        + 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. +

        + 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/
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the path of the file, an empty string if none exists, null if invalid
        +
      • +
      + + + +
        +
      • +

        getFullPathNoEndSeparator

        +
        public static String getFullPathNoEndSeparator(String filename)
        +
        Gets the full path from a full filename, which is the prefix + path, + and also excluding the final directory separator. +

        + 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. +

        + 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
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the path of the file, an empty string if none exists, null if invalid
        +
      • +
      + + + +
        +
      • +

        getName

        +
        public static String getName(String filename)
        +
        Gets the name minus the path from a full filename. +

        + This method will handle a file in either Unix or Windows format. + The text after the last forward or backslash is returned. +

        + a/b/c.txt --> c.txt
        + a.txt     --> a.txt
        + a/b/c     --> c
        + a/b/c/    --> ""
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the name of the file without the path, or an empty string if none exists. + Null bytes inside string will be removed
        +
      • +
      + + + +
        +
      • +

        getBaseName

        +
        public static String getBaseName(String filename)
        +
        Gets the base name, minus the full path and extension, from a full filename. +

        + 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. +

        + a/b/c.txt --> c
        + a.txt     --> a
        + a/b/c     --> c
        + a/b/c/    --> ""
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the name of the file without the path, or an empty string if none exists. Null bytes inside string + will be removed
        +
      • +
      + + + +
        +
      • +

        getExtension

        +
        public static String getExtension(String filename)
        +
        Gets the extension of a filename. +

        + This method returns the textual part of the filename after the last dot. + There must be no directory separator after the dot. +

        + foo.txt      --> "txt"
        + a/b/c.jpg    --> "jpg"
        + a/b.txt/c    --> ""
        + a/b/c        --> ""
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on.

        +
        Parameters:
        filename - the filename to retrieve the extension of.
        +
        Returns:
        the extension of the file or an empty string if none exists or null + if the filename is null.
        +
      • +
      + + + +
        +
      • +

        removeExtension

        +
        public static String removeExtension(String filename)
        +
        Removes the extension from a filename. +

        + This method returns the textual part of the filename before the last dot. + There must be no directory separator after the dot. +

        + foo.txt    --> foo
        + a\b\c.jpg  --> a\b\c
        + a\b\c      --> a\b\c
        + a.b\c      --> a.b\c
        + 
        +

        + The output will be the same irrespective of the machine that the code is running on.

        +
        Parameters:
        filename - the filename to query, null returns null
        +
        Returns:
        the filename minus the extension
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public static boolean equals(String filename1,
        +             String filename2)
        +
        Checks whether two filenames are equal exactly. +

        + No processing is performed on the filenames other than comparison, + thus this is merely a null-safe case-sensitive equals.

        +
        Parameters:
        filename1 - the first filename to query, may be null
        filename2 - the second filename to query, may be null
        +
        Returns:
        true if the filenames are equal, null equals null
        See Also:
        IOCase.SENSITIVE
        +
      • +
      + + + +
        +
      • +

        equalsOnSystem

        +
        public static boolean equalsOnSystem(String filename1,
        +                     String filename2)
        +
        Checks whether two filenames are equal using the case rules of the system. +

        + No processing is performed on the filenames other than comparison. + The check is case-sensitive on Unix and case-insensitive on Windows.

        +
        Parameters:
        filename1 - the first filename to query, may be null
        filename2 - the second filename to query, may be null
        +
        Returns:
        true if the filenames are equal, null equals null
        See Also:
        IOCase.SYSTEM
        +
      • +
      + + + +
        +
      • +

        equalsNormalized

        +
        public static boolean equalsNormalized(String filename1,
        +                       String filename2)
        +
        Checks whether two filenames are equal after both have been normalized. +

        + Both filenames are first passed to normalize(String). + The check is then performed in a case-sensitive manner.

        +
        Parameters:
        filename1 - the first filename to query, may be null
        filename2 - the second filename to query, may be null
        +
        Returns:
        true if the filenames are equal, null equals null
        See Also:
        IOCase.SENSITIVE
        +
      • +
      + + + +
        +
      • +

        equalsNormalizedOnSystem

        +
        public static boolean equalsNormalizedOnSystem(String filename1,
        +                               String filename2)
        +
        Checks whether two filenames are equal after both have been normalized + and using the case rules of the system. +

        + Both filenames are first passed to normalize(String). + The check is then performed case-sensitive on Unix and + case-insensitive on Windows.

        +
        Parameters:
        filename1 - the first filename to query, may be null
        filename2 - the second filename to query, may be null
        +
        Returns:
        true if the filenames are equal, null equals null
        See Also:
        IOCase.SYSTEM
        +
      • +
      + + + +
        +
      • +

        equals

        +
        public static boolean equals(String filename1,
        +             String filename2,
        +             boolean normalized,
        +             IOCase caseSensitivity)
        +
        Checks whether two filenames are equal, optionally normalizing and providing + control over the case-sensitivity.
        +
        Parameters:
        filename1 - the first filename to query, may be null
        filename2 - the second filename to query, may be null
        normalized - whether to normalize the filenames
        caseSensitivity - what case sensitivity rule to use, null means case-sensitive
        +
        Returns:
        true if the filenames are equal, null equals null
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        isExtension

        +
        public static boolean isExtension(String filename,
        +                  String extension)
        +
        Checks whether the extension of the filename is that specified. +

        + 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.

        +
        Parameters:
        filename - the filename to query, null returns false
        extension - the extension to check for, null or empty checks for no extension
        +
        Returns:
        true if the filename has the specified extension
        +
        Throws:
        +
        IllegalArgumentException - if the supplied filename contains null bytes
        +
      • +
      + + + +
        +
      • +

        isExtension

        +
        public static boolean isExtension(String filename,
        +                  String[] extensions)
        +
        Checks whether the extension of the filename is one of those specified. +

        + 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.

        +
        Parameters:
        filename - the filename to query, null returns false
        extensions - the extensions to check for, null checks for no extension
        +
        Returns:
        true if the filename is one of the extensions
        +
        Throws:
        +
        IllegalArgumentException - if the supplied filename contains null bytes
        +
      • +
      + + + +
        +
      • +

        isExtension

        +
        public static boolean isExtension(String filename,
        +                  Collection<String> extensions)
        +
        Checks whether the extension of the filename is one of those specified. +

        + 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.

        +
        Parameters:
        filename - the filename to query, null returns false
        extensions - the extensions to check for, null checks for no extension
        +
        Returns:
        true if the filename is one of the extensions
        +
        Throws:
        +
        IllegalArgumentException - if the supplied filename contains null bytes
        +
      • +
      + + + +
        +
      • +

        wildcardMatch

        +
        public static boolean wildcardMatch(String filename,
        +                    String wildcardMatcher)
        +
        Checks a filename to see if it matches the specified wildcard matcher, + always testing case-sensitive. +

        + 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. +

        + 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
        + 
        + N.B. the sequence "*?" does not work properly at present in match strings.
        +
        Parameters:
        filename - the filename to match on
        wildcardMatcher - the wildcard string to match against
        +
        Returns:
        true if the filename matches the wilcard string
        See Also:
        IOCase.SENSITIVE
        +
      • +
      + + + +
        +
      • +

        wildcardMatchOnSystem

        +
        public static boolean wildcardMatchOnSystem(String filename,
        +                            String wildcardMatcher)
        +
        Checks a filename to see if it matches the specified wildcard matcher + using the case rules of the system. +

        + 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. +

        + 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
        + 
        + N.B. the sequence "*?" does not work properly at present in match strings.
        +
        Parameters:
        filename - the filename to match on
        wildcardMatcher - the wildcard string to match against
        +
        Returns:
        true if the filename matches the wilcard string
        See Also:
        IOCase.SYSTEM
        +
      • +
      + + + +
        +
      • +

        wildcardMatch

        +
        public static boolean wildcardMatch(String filename,
        +                    String wildcardMatcher,
        +                    IOCase caseSensitivity)
        +
        Checks a filename to see if it matches the specified wildcard matcher + allowing control over case-sensitivity. +

        + 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.

        +
        Parameters:
        filename - the filename to match on
        wildcardMatcher - the wildcard string to match against
        caseSensitivity - what case sensitivity rule to use, null means case-sensitive
        +
        Returns:
        true if the filename matches the wilcard string
        Since:
        +
        1.3
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/HexDump.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/HexDump.html" index bf2c03fc47d166b3218486588327deb5771004ee..4a7f24448c1f53838afc28c316db10dea8057839 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/HexDump.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/HexDump.html" @@ -1,3 +1,340 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2db2eee4731fcfc554786432fe3fdc149eb1d27d86f563a041bf50404b3fe515 -size 15413 + + + + + +HexDump (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class HexDump

+
+
+ +
+
    +
  • +
    +
    +
    public class HexDump
    +extends Object
    +
    Dumps data in hexadecimal format. +

    + Provides a single function to take an array of bytes and display it + in hexadecimal form. +

    + Origin of code: POI.

    +
    Version:
    +
    $Id: HexDump.java 1471767 2013-04-24 23:24:19Z sebb $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      static StringEOL +
      The line-separator (initializes to "line.separator" system property.
      +
      +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      HexDump() +
      Instances should NOT be constructed in standard programming.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        EOL

        +
        public static final String EOL
        +
        The line-separator (initializes to "line.separator" system property.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        HexDump

        +
        public HexDump()
        +
        Instances should NOT be constructed in standard programming.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        dump

        +
        public static void dump(byte[] data,
        +        long offset,
        +        OutputStream stream,
        +        int index)
        +                 throws IOException,
        +                        ArrayIndexOutOfBoundsException,
        +                        IllegalArgumentException
        +
        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. +

        + 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. +

        + All bytes between the given index (inclusive) and the end of the + data array are dumped.

        +
        Parameters:
        data - the byte array to be dumped
        offset - offset of the byte array within a larger entity
        stream - the OutputStream to which the data is to be + written
        index - initial index into the byte array
        +
        Throws:
        +
        IOException - is thrown if anything goes wrong writing + the data to stream
        +
        ArrayIndexOutOfBoundsException - if the index is + outside the data array's bounds
        +
        IllegalArgumentException - if the output stream is null
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOCase.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOCase.html" new file mode 100644 index 0000000000000000000000000000000000000000..86527099bd8d71dbf4fe93202cda72934762054d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOCase.html" @@ -0,0 +1,597 @@ + + + + + +IOCase (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Enum IOCase

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparable<IOCase>
    +
    +
    +
    +
    public enum IOCase
    +extends Enum<IOCase>
    +implements Serializable
    +
    Enumeration of IO case sensitivity. +

    + Different filing systems have different rules for case-sensitivity. + Windows is case-insensitive, Unix is case-sensitive. +

    + 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. +

    + Wherever possible, you should use the check methods in this + class to compare filenames.

    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: IOCase.java 1483915 2013-05-17 17:02:35Z sebb $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Enum Constant Summary

      + + + + + + + + + + + + + + +
      Enum Constants 
      Enum Constant and Description
      INSENSITIVE +
      The constant for case insensitive regardless of operating system.
      +
      SENSITIVE +
      The constant for case sensitive regardless of operating system.
      +
      SYSTEM +
      The constant for case sensitivity determined by the current operating system.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Enum Constant Detail

      + + + +
        +
      • +

        SENSITIVE

        +
        public static final IOCase SENSITIVE
        +
        The constant for case sensitive regardless of operating system.
        +
      • +
      + + + +
        +
      • +

        INSENSITIVE

        +
        public static final IOCase INSENSITIVE
        +
        The constant for case insensitive regardless of operating system.
        +
      • +
      + + + +
        +
      • +

        SYSTEM

        +
        public static final IOCase SYSTEM
        +
        The constant for case sensitivity determined by the current operating system. + Windows is case-insensitive when comparing filenames, Unix is case-sensitive. +

        + Note: 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 File.separatorChar). +

        + If you derialize this constant of Windows, and deserialize on Unix, or vice + versa, then the value of the case-sensitivity flag will change.

        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        values

        +
        public static IOCase[] values()
        +
        Returns an array containing the constants of this enum type, in +the order they are declared. This method may be used to iterate +over the constants as follows: +
        +for (IOCase c : IOCase.values())
        +    System.out.println(c);
        +
        +
        Returns:
        an array containing the constants of this enum type, in the order they are declared
        +
      • +
      + + + +
        +
      • +

        valueOf

        +
        public static IOCase valueOf(String name)
        +
        Returns the enum constant of this type with the specified name. +The string must match exactly an identifier used to declare an +enum constant in this type. (Extraneous whitespace characters are +not permitted.)
        +
        Parameters:
        name - the name of the enum constant to be returned.
        +
        Returns:
        the enum constant with the specified name
        +
        Throws:
        +
        IllegalArgumentException - if this enum type has no constant with the specified name
        +
        NullPointerException - if the argument is null
        +
      • +
      + + + +
        +
      • +

        forName

        +
        public static IOCase forName(String name)
        +
        Factory method to create an IOCase from a name.
        +
        Parameters:
        name - the name to find
        +
        Returns:
        the IOCase object
        +
        Throws:
        +
        IllegalArgumentException - if the name is invalid
        +
      • +
      + + + +
        +
      • +

        getName

        +
        public String getName()
        +
        Gets the name of the constant.
        +
        Returns:
        the name of the constant
        +
      • +
      + + + +
        +
      • +

        isCaseSensitive

        +
        public boolean isCaseSensitive()
        +
        Does the object represent case sensitive comparison.
        +
        Returns:
        true if case sensitive
        +
      • +
      + + + +
        +
      • +

        checkCompareTo

        +
        public int checkCompareTo(String str1,
        +                 String str2)
        +
        Compares two strings using the case-sensitivity rule. +

        + This method mimics String.compareTo(java.lang.String) but takes case-sensitivity + into account.

        +
        Parameters:
        str1 - the first string to compare, not null
        str2 - the second string to compare, not null
        +
        Returns:
        true if equal using the case rules
        +
        Throws:
        +
        NullPointerException - if either string is null
        +
      • +
      + + + +
        +
      • +

        checkEquals

        +
        public boolean checkEquals(String str1,
        +                  String str2)
        +
        Compares two strings using the case-sensitivity rule. +

        + This method mimics String.equals(java.lang.Object) but takes case-sensitivity + into account.

        +
        Parameters:
        str1 - the first string to compare, not null
        str2 - the second string to compare, not null
        +
        Returns:
        true if equal using the case rules
        +
        Throws:
        +
        NullPointerException - if either string is null
        +
      • +
      + + + +
        +
      • +

        checkStartsWith

        +
        public boolean checkStartsWith(String str,
        +                      String start)
        +
        Checks if one string starts with another using the case-sensitivity rule. +

        + This method mimics String.startsWith(String) but takes case-sensitivity + into account.

        +
        Parameters:
        str - the string to check, not null
        start - the start to compare against, not null
        +
        Returns:
        true if equal using the case rules
        +
        Throws:
        +
        NullPointerException - if either string is null
        +
      • +
      + + + +
        +
      • +

        checkEndsWith

        +
        public boolean checkEndsWith(String str,
        +                    String end)
        +
        Checks if one string ends with another using the case-sensitivity rule. +

        + This method mimics String.endsWith(java.lang.String) but takes case-sensitivity + into account.

        +
        Parameters:
        str - the string to check, not null
        end - the end to compare against, not null
        +
        Returns:
        true if equal using the case rules
        +
        Throws:
        +
        NullPointerException - if either string is null
        +
      • +
      + + + +
        +
      • +

        checkIndexOf

        +
        public int checkIndexOf(String str,
        +               int strStartIndex,
        +               String search)
        +
        Checks if one string contains another starting at a specific index using the + case-sensitivity rule. +

        + This method mimics parts of String.indexOf(String, int) + but takes case-sensitivity into account.

        +
        Parameters:
        str - the string to check, not null
        strStartIndex - the index to start at in str
        search - the start to search for, not null
        +
        Returns:
        the first index of the search String, + -1 if no match or null string input
        +
        Throws:
        +
        NullPointerException - if either string is null
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        checkRegionMatches

        +
        public boolean checkRegionMatches(String str,
        +                         int strStartIndex,
        +                         String search)
        +
        Checks if one string contains another at a specific index using the case-sensitivity rule. +

        + This method mimics parts of String.regionMatches(boolean, int, String, int, int) + but takes case-sensitivity into account.

        +
        Parameters:
        str - the string to check, not null
        strStartIndex - the index to start at in str
        search - the start to search for, not null
        +
        Returns:
        true if equal using the case rules
        +
        Throws:
        +
        NullPointerException - if either string is null
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Gets a string describing the sensitivity.
        +
        +
        Overrides:
        +
        toString in class Enum<IOCase>
        +
        Returns:
        a string describing the sensitivity
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOExceptionWithCause.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOExceptionWithCause.html" new file mode 100644 index 0000000000000000000000000000000000000000..e36b52892471872cba3c8836cfb0ace24c003a1d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOExceptionWithCause.html" @@ -0,0 +1,302 @@ + + + + + +IOExceptionWithCause (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class IOExceptionWithCause

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        IOExceptionWithCause

        +
        public IOExceptionWithCause(String message,
        +                    Throwable cause)
        +
        Deprecated. 
        +
        Constructs a new instance with the given message and cause. +

        + As specified in Throwable, the message in the given cause is not used in this instance's + message. +

        +
        Parameters:
        message - the message (see Throwable.getMessage())
        cause - the cause (see Throwable.getCause()). A null value is allowed.
        +
      • +
      + + + +
        +
      • +

        IOExceptionWithCause

        +
        public IOExceptionWithCause(Throwable cause)
        +
        Deprecated. 
        +
        Constructs a new instance with the given cause. +

        + The message is set to cause==null ? null : cause.toString(), which by default contains the class + and message of cause. This constructor is useful for call sites that just wrap another throwable. +

        +
        Parameters:
        cause - the cause (see Throwable.getCause()). A null value is allowed.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOUtils.html" new file mode 100644 index 0000000000000000000000000000000000000000..0d1b667710beac20ea9781b68329f7a3f8da77bd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/IOUtils.html" @@ -0,0 +1,4242 @@ + + + + + +IOUtils (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class IOUtils

+
+
+ +
+
    +
  • +
    +
    +
    public class IOUtils
    +extends Object
    +
    General IO stream manipulation utilities. +

    + This class provides static utility methods for input/output operations. +

      +
    • closeQuietly - these methods close a stream ignoring nulls and exceptions +
    • toXxx/read - these methods read data from a stream +
    • write - these methods write data to a stream +
    • copy - these methods copy all the data from one stream to another +
    • contentEquals - these methods compare the content of two streams +
    +

    + The byte-to-char methods and char-to-byte methods involve a conversion step. + Two methods are provided in each case, one that uses the platform default + encoding and the other which allows you to specify an encoding. You are + encouraged to always specify an encoding because relying on the platform + default can lead to unexpected results, for example when moving from + development to production. +

    + All the methods in this class that read a stream are buffered internally. + This means that there is no cause to use a BufferedInputStream + or BufferedReader. The default buffer size of 4K has been shown + to be efficient in tests. +

    + The various copy methods all delegate the actual copying to one of the following methods: +

    + For example, copy(InputStream, OutputStream) calls copyLarge(InputStream, OutputStream) + which calls copy(InputStream, OutputStream, int) which creates the buffer and calls + copyLarge(InputStream, OutputStream, byte[]). +

    + Applications can re-use buffers by using the underlying methods directly. + This may improve performance for applications that need to do a lot of copying. +

    + Wherever possible, the methods in this class do not flush or close + the stream. This is to avoid making non-portable assumptions about the + streams' origin and further use. Thus the caller is still responsible for + closing streams after use. +

    + Origin of code: Excalibur.

    +
    Version:
    +
    $Id: IOUtils.java 1722156 2015-12-29 15:40:07Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        EOF

        +
        public static final int EOF
        +
        Represents the end-of-file (or stream).
        +
        Since:
        +
        2.5 (made public)
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        DIR_SEPARATOR_UNIX

        +
        public static final char DIR_SEPARATOR_UNIX
        +
        The Unix directory separator character.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        DIR_SEPARATOR_WINDOWS

        +
        public static final char DIR_SEPARATOR_WINDOWS
        +
        The Windows directory separator character.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        DIR_SEPARATOR

        +
        public static final char DIR_SEPARATOR
        +
        The system directory separator character.
        +
      • +
      + + + +
        +
      • +

        LINE_SEPARATOR_UNIX

        +
        public static final String LINE_SEPARATOR_UNIX
        +
        The Unix line separator string.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        LINE_SEPARATOR_WINDOWS

        +
        public static final String LINE_SEPARATOR_WINDOWS
        +
        The Windows line separator string.
        +
        See Also:
        Constant Field Values
        +
      • +
      + + + +
        +
      • +

        LINE_SEPARATOR

        +
        public static final String LINE_SEPARATOR
        +
        The system line separator string.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        IOUtils

        +
        public IOUtils()
        +
        Instances should NOT be constructed in standard programming.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        close

        +
        public static void close(URLConnection conn)
        +
        Closes a URLConnection.
        +
        Parameters:
        conn - the connection to close.
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(Reader input)
        +
        Closes an Reader unconditionally. +

        + Equivalent to Reader.close(), except any exceptions will be ignored. + This is typically used in finally blocks. +

        + Example code: +

        +   char[] data = new char[1024];
        +   Reader in = null;
        +   try {
        +       in = new FileReader("foo.txt");
        +       in.read(data);
        +       in.close(); //close errors are handled
        +   } catch (Exception e) {
        +       // error handling
        +   } finally {
        +       IOUtils.closeQuietly(in);
        +   }
        + 
        +
        Parameters:
        input - the Reader to close, may be null or already closed
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(Writer output)
        +
        Closes an Writer unconditionally. +

        + Equivalent to Writer.close(), except any exceptions will be ignored. + This is typically used in finally blocks. +

        + Example code: +

        +   Writer out = null;
        +   try {
        +       out = new StringWriter();
        +       out.write("Hello World");
        +       out.close(); //close errors are handled
        +   } catch (Exception e) {
        +       // error handling
        +   } finally {
        +       IOUtils.closeQuietly(out);
        +   }
        + 
        +
        Parameters:
        output - the Writer to close, may be null or already closed
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(InputStream input)
        +
        Closes an InputStream unconditionally. +

        + Equivalent to InputStream.close(), except any exceptions will be ignored. + This is typically used in finally blocks. +

        + Example code: +

        +   byte[] data = new byte[1024];
        +   InputStream in = null;
        +   try {
        +       in = new FileInputStream("foo.txt");
        +       in.read(data);
        +       in.close(); //close errors are handled
        +   } catch (Exception e) {
        +       // error handling
        +   } finally {
        +       IOUtils.closeQuietly(in);
        +   }
        + 
        +
        Parameters:
        input - the InputStream to close, may be null or already closed
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(OutputStream output)
        +
        Closes an OutputStream unconditionally. +

        + Equivalent to OutputStream.close(), except any exceptions will be ignored. + This is typically used in finally blocks. +

        + Example code: +

        + byte[] data = "Hello, World".getBytes();
        +
        + OutputStream out = null;
        + try {
        +     out = new FileOutputStream("foo.txt");
        +     out.write(data);
        +     out.close(); //close errors are handled
        + } catch (IOException e) {
        +     // error handling
        + } finally {
        +     IOUtils.closeQuietly(out);
        + }
        + 
        +
        Parameters:
        output - the OutputStream to close, may be null or already closed
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(Closeable closeable)
        +
        Closes a Closeable unconditionally. +

        + Equivalent to Closeable.close(), except any exceptions will be ignored. This is typically used in + finally blocks. +

        + Example code: +

        +
        + Closeable closeable = null;
        + try {
        +     closeable = new FileReader("foo.txt");
        +     // process closeable
        +     closeable.close();
        + } catch (Exception e) {
        +     // error handling
        + } finally {
        +     IOUtils.closeQuietly(closeable);
        + }
        + 
        +

        + Closing all streams: +

        +
        + try {
        +     return IOUtils.copy(inputStream, outputStream);
        + } finally {
        +     IOUtils.closeQuietly(inputStream);
        +     IOUtils.closeQuietly(outputStream);
        + }
        + 
        +
        Parameters:
        closeable - the objects to close, may be null or already closed
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(Closeable... closeables)
        +
        Closes a Closeable unconditionally. +

        + Equivalent to Closeable.close(), except any exceptions will be ignored. +

        + This is typically used in finally blocks to ensure that the closeable is closed + even if an Exception was thrown before the normal close statement was reached. +
        + It should not be used to replace the close statement(s) + which should be present for the non-exceptional case. +
        + It is only intended to simplify tidying up where normal processing has already failed + and reporting close failure as well is not necessary or useful. +

        + Example code: +

        +
        + Closeable closeable = null;
        + try {
        +     closeable = new FileReader("foo.txt");
        +     // processing using the closeable; may throw an Exception
        +     closeable.close(); // Normal close - exceptions not ignored
        + } catch (Exception e) {
        +     // error handling
        + } finally {
        +     IOUtils.closeQuietly(closeable); // In case normal close was skipped due to Exception
        + }
        + 
        +

        + Closing all streams: +
        +

        + try {
        +     return IOUtils.copy(inputStream, outputStream);
        + } finally {
        +     IOUtils.closeQuietly(inputStream, outputStream);
        + }
        + 
        +
        Parameters:
        closeables - the objects to close, may be null or already closed
        Since:
        +
        2.5
        +
        See Also:
        closeQuietly(Closeable)
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(Socket sock)
        +
        Closes a Socket unconditionally. +

        + Equivalent to Socket.close(), except any exceptions will be ignored. + This is typically used in finally blocks. +

        + Example code: +

        +   Socket socket = null;
        +   try {
        +       socket = new Socket("http://www.foo.com/", 80);
        +       // process socket
        +       socket.close();
        +   } catch (Exception e) {
        +       // error handling
        +   } finally {
        +       IOUtils.closeQuietly(socket);
        +   }
        + 
        +
        Parameters:
        sock - the Socket to close, may be null or already closed
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(Selector selector)
        +
        Closes a Selector unconditionally. +

        + Equivalent to Selector.close(), except any exceptions will be ignored. + This is typically used in finally blocks. +

        + Example code: +

        +   Selector selector = null;
        +   try {
        +       selector = Selector.open();
        +       // process socket
        +
        +   } catch (Exception e) {
        +       // error handling
        +   } finally {
        +       IOUtils.closeQuietly(selector);
        +   }
        + 
        +
        Parameters:
        selector - the Selector to close, may be null or already closed
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(ServerSocket sock)
        +
        Closes a ServerSocket unconditionally. +

        + Equivalent to ServerSocket.close(), except any exceptions will be ignored. + This is typically used in finally blocks. +

        + Example code: +

        +   ServerSocket socket = null;
        +   try {
        +       socket = new ServerSocket();
        +       // process socket
        +       socket.close();
        +   } catch (Exception e) {
        +       // error handling
        +   } finally {
        +       IOUtils.closeQuietly(socket);
        +   }
        + 
        +
        Parameters:
        sock - the ServerSocket to close, may be null or already closed
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        toBufferedInputStream

        +
        public static InputStream toBufferedInputStream(InputStream input)
        +                                         throws IOException
        +
        Fetches entire contents of an InputStream and represent + same data as result InputStream. +

        + This method is useful where, +

          +
        • Source InputStream is slow.
        • +
        • It has network resources associated, so we cannot keep it open for + long time.
        • +
        • It has network timeout associated.
        • +
        + It can be used in favor of toByteArray(InputStream), since it + avoids unnecessary allocation and copy of byte[].
        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.
        +
        Parameters:
        input - Stream to be fully buffered.
        +
        Returns:
        A fully buffered stream.
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        toBufferedInputStream

        +
        public static InputStream toBufferedInputStream(InputStream input,
        +                                int size)
        +                                         throws IOException
        +
        Fetches entire contents of an InputStream and represent + same data as result InputStream. +

        + This method is useful where, +

          +
        • Source InputStream is slow.
        • +
        • It has network resources associated, so we cannot keep it open for + long time.
        • +
        • It has network timeout associated.
        • +
        + It can be used in favor of toByteArray(InputStream), since it + avoids unnecessary allocation and copy of byte[].
        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.
        +
        Parameters:
        input - Stream to be fully buffered.
        size - the initial buffer size
        +
        Returns:
        A fully buffered stream.
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        toBufferedReader

        +
        public static BufferedReader toBufferedReader(Reader reader)
        +
        Returns the given reader if it is a BufferedReader, otherwise creates a BufferedReader from the given + reader.
        +
        Parameters:
        reader - the reader to wrap or return (not null)
        +
        Returns:
        the given reader or a new BufferedReader for the given reader
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.2
        +
        See Also:
        buffer(Reader)
        +
      • +
      + + + +
        +
      • +

        toBufferedReader

        +
        public static BufferedReader toBufferedReader(Reader reader,
        +                              int size)
        +
        Returns the given reader if it is a BufferedReader, otherwise creates a BufferedReader from the given + reader.
        +
        Parameters:
        reader - the reader to wrap or return (not null)
        size - the buffer size, if a new BufferedReader is created.
        +
        Returns:
        the given reader or a new BufferedReader for the given reader
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
        See Also:
        buffer(Reader)
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedReader buffer(Reader reader)
        +
        Returns the given reader if it is already a BufferedReader, otherwise creates a BufferedReader from + the given reader.
        +
        Parameters:
        reader - the reader to wrap or return (not null)
        +
        Returns:
        the given reader or a new BufferedReader for the given reader
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedReader buffer(Reader reader,
        +                    int size)
        +
        Returns the given reader if it is already a BufferedReader, otherwise creates a BufferedReader from the + given reader.
        +
        Parameters:
        reader - the reader to wrap or return (not null)
        size - the buffer size, if a new BufferedReader is created.
        +
        Returns:
        the given reader or a new BufferedReader for the given reader
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedWriter buffer(Writer writer)
        +
        Returns the given Writer if it is already a BufferedWriter, otherwise creates a BufferedWriter from the + given Writer.
        +
        Parameters:
        writer - the Writer to wrap or return (not null)
        +
        Returns:
        the given Writer or a new BufferedWriter for the given Writer
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedWriter buffer(Writer writer,
        +                    int size)
        +
        Returns the given Writer if it is already a BufferedWriter, otherwise creates a BufferedWriter from the + given Writer.
        +
        Parameters:
        writer - the Writer to wrap or return (not null)
        size - the buffer size, if a new BufferedWriter is created.
        +
        Returns:
        the given Writer or a new BufferedWriter for the given Writer
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedOutputStream buffer(OutputStream outputStream)
        +
        Returns the given OutputStream if it is already a BufferedOutputStream, otherwise creates a + BufferedOutputStream from the given OutputStream.
        +
        Parameters:
        outputStream - the OutputStream to wrap or return (not null)
        +
        Returns:
        the given OutputStream or a new BufferedOutputStream for the given OutputStream
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedOutputStream buffer(OutputStream outputStream,
        +                          int size)
        +
        Returns the given OutputStream if it is already a BufferedOutputStream, otherwise creates a + BufferedOutputStream from the given OutputStream.
        +
        Parameters:
        outputStream - the OutputStream to wrap or return (not null)
        size - the buffer size, if a new BufferedOutputStream is created.
        +
        Returns:
        the given OutputStream or a new BufferedOutputStream for the given OutputStream
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedInputStream buffer(InputStream inputStream)
        +
        Returns the given InputStream if it is already a BufferedInputStream, otherwise creates a + BufferedInputStream from the given InputStream.
        +
        Parameters:
        inputStream - the InputStream to wrap or return (not null)
        +
        Returns:
        the given InputStream or a new BufferedInputStream for the given InputStream
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        buffer

        +
        public static BufferedInputStream buffer(InputStream inputStream,
        +                         int size)
        +
        Returns the given InputStream if it is already a BufferedInputStream, otherwise creates a + BufferedInputStream from the given InputStream.
        +
        Parameters:
        inputStream - the InputStream to wrap or return (not null)
        size - the buffer size, if a new BufferedInputStream is created.
        +
        Returns:
        the given InputStream or a new BufferedInputStream for the given InputStream
        +
        Throws:
        +
        NullPointerException - if the input parameter is null
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(InputStream input)
        +                          throws IOException
        +
        Gets the contents of an InputStream as a byte[]. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        input - the InputStream to read from
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(InputStream input,
        +                 long size)
        +                          throws IOException
        +
        Gets contents of an InputStream as a byte[]. + Use this method instead of toByteArray(InputStream) + when InputStream size is known. + NOTE: the method checks that the length can safely be cast to an int without truncation + before using toByteArray(java.io.InputStream, int) to read into the byte array. + (Arrays can have no more than Integer.MAX_VALUE entries anyway)
        +
        Parameters:
        input - the InputStream to read from
        size - the size of InputStream
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        IOException - if an I/O error occurs or InputStream size differ from parameter + size
        +
        IllegalArgumentException - if size is less than zero or size is greater than Integer.MAX_VALUE
        Since:
        +
        2.1
        +
        See Also:
        toByteArray(java.io.InputStream, int)
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(InputStream input,
        +                 int size)
        +                          throws IOException
        +
        Gets the contents of an InputStream as a byte[]. + Use this method instead of toByteArray(InputStream) + when InputStream size is known
        +
        Parameters:
        input - the InputStream to read from
        size - the size of InputStream
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        IOException - if an I/O error occurs or InputStream size differ from parameter + size
        +
        IllegalArgumentException - if size is less than zero
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        @Deprecated
        +public static byte[] toByteArray(Reader input)
        +                          throws IOException
        +
        Deprecated. 2.5 use toByteArray(Reader, Charset) instead
        +
        Gets the contents of a Reader as a byte[] + using the default character encoding of the platform. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader.

        +
        Parameters:
        input - the Reader to read from
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(Reader input,
        +                 Charset encoding)
        +                          throws IOException
        +
        Gets the contents of a Reader as a byte[] + using the specified character encoding. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader.

        +
        Parameters:
        input - the Reader to read from
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(Reader input,
        +                 String encoding)
        +                          throws IOException
        +
        Gets the contents of a Reader as a byte[] + using the specified character encoding. +

        + Character encoding names can be found at + IANA. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader.

        +
        Parameters:
        input - the Reader to read from
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        @Deprecated
        +public static byte[] toByteArray(String input)
        +                          throws IOException
        +
        Deprecated. 2.5 Use String.getBytes() instead
        +
        Gets the contents of a String as a byte[] + using the default character encoding of the platform. +

        + This is the same as String.getBytes().

        +
        Parameters:
        input - the String to convert
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs (never occurs)
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(URI uri)
        +                          throws IOException
        +
        Gets the contents of a URI as a byte[].
        +
        Parameters:
        uri - the URI to read
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the uri is null
        +
        IOException - if an I/O exception occurs
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(URL url)
        +                          throws IOException
        +
        Gets the contents of a URL as a byte[].
        +
        Parameters:
        url - the URL to read
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O exception occurs
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public static byte[] toByteArray(URLConnection urlConn)
        +                          throws IOException
        +
        Gets the contents of a URLConnection as a byte[].
        +
        Parameters:
        urlConn - the URLConnection to read
        +
        Returns:
        the requested byte array
        +
        Throws:
        +
        NullPointerException - if the urlConn is null
        +
        IOException - if an I/O exception occurs
        Since:
        +
        2.4
        +
      • +
      + + + +
        +
      • +

        toCharArray

        +
        @Deprecated
        +public static char[] toCharArray(InputStream is)
        +                          throws IOException
        +
        Deprecated. 2.5 use toCharArray(InputStream, Charset) instead
        +
        Gets the contents of an InputStream as a character array + using the default character encoding of the platform. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        is - the InputStream to read from
        +
        Returns:
        the requested character array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        toCharArray

        +
        public static char[] toCharArray(InputStream is,
        +                 Charset encoding)
        +                          throws IOException
        +
        Gets the contents of an InputStream as a character array + using the specified character encoding. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        is - the InputStream to read from
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the requested character array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        toCharArray

        +
        public static char[] toCharArray(InputStream is,
        +                 String encoding)
        +                          throws IOException
        +
        Gets the contents of an InputStream as a character array + using the specified character encoding. +

        + Character encoding names can be found at + IANA. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        is - the InputStream to read from
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the requested character array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        toCharArray

        +
        public static char[] toCharArray(Reader input)
        +                          throws IOException
        +
        Gets the contents of a Reader as a character array. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader.

        +
        Parameters:
        input - the Reader to read from
        +
        Returns:
        the requested character array
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        toString

        +
        @Deprecated
        +public static String toString(InputStream input)
        +                       throws IOException
        +
        Deprecated. 2.5 use toString(InputStream, Charset) instead
        +
        Gets the contents of an InputStream as a String + using the default character encoding of the platform. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        input - the InputStream to read from
        +
        Returns:
        the requested String
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(InputStream input,
        +              Charset encoding)
        +                       throws IOException
        +
        Gets the contents of an InputStream as a String + using the specified character encoding. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream. +

        +
        Parameters:
        input - the InputStream to read from
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the requested String
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(InputStream input,
        +              String encoding)
        +                       throws IOException
        +
        Gets the contents of an InputStream as a String + using the specified character encoding. +

        + Character encoding names can be found at + IANA. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        input - the InputStream to read from
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the requested String
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(Reader input)
        +                       throws IOException
        +
        Gets the contents of a Reader as a String. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader.

        +
        Parameters:
        input - the Reader to read from
        +
        Returns:
        the requested String
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        toString

        +
        @Deprecated
        +public static String toString(URI uri)
        +                       throws IOException
        +
        Deprecated. 2.5 use toString(URI, Charset) instead
        +
        Gets the contents at the given URI.
        +
        Parameters:
        uri - The URI source.
        +
        Returns:
        The contents of the URL as a String.
        +
        Throws:
        +
        IOException - if an I/O exception occurs.
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(URI uri,
        +              Charset encoding)
        +                       throws IOException
        +
        Gets the contents at the given URI.
        +
        Parameters:
        uri - The URI source.
        encoding - The encoding name for the URL contents.
        +
        Returns:
        The contents of the URL as a String.
        +
        Throws:
        +
        IOException - if an I/O exception occurs.
        Since:
        +
        2.3.
        +
      • +
      + + + + + + + +
        +
      • +

        toString

        +
        @Deprecated
        +public static String toString(URL url)
        +                       throws IOException
        +
        Deprecated. 2.5 use toString(URL, Charset) instead
        +
        Gets the contents at the given URL.
        +
        Parameters:
        url - The URL source.
        +
        Returns:
        The contents of the URL as a String.
        +
        Throws:
        +
        IOException - if an I/O exception occurs.
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(URL url,
        +              Charset encoding)
        +                       throws IOException
        +
        Gets the contents at the given URL.
        +
        Parameters:
        url - The URL source.
        encoding - The encoding name for the URL contents.
        +
        Returns:
        The contents of the URL as a String.
        +
        Throws:
        +
        IOException - if an I/O exception occurs.
        Since:
        +
        2.3
        +
      • +
      + + + + + + + +
        +
      • +

        toString

        +
        @Deprecated
        +public static String toString(byte[] input)
        +                       throws IOException
        +
        Deprecated. 2.5 Use String.String(byte[]) instead
        +
        Gets the contents of a byte[] as a String + using the default character encoding of the platform.
        +
        Parameters:
        input - the byte array to read from
        +
        Returns:
        the requested String
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs (never occurs)
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public static String toString(byte[] input,
        +              String encoding)
        +                       throws IOException
        +
        Gets the contents of a byte[] as a String + using the specified character encoding. +

        + Character encoding names can be found at + IANA.

        +
        Parameters:
        input - the byte array to read from
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the requested String
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs (never occurs)
        +
      • +
      + + + +
        +
      • +

        readLines

        +
        @Deprecated
        +public static List<String> readLines(InputStream input)
        +                              throws IOException
        +
        Deprecated. 2.5 use readLines(InputStream, Charset) instead
        +
        Gets the contents of an InputStream as a list of Strings, + one entry per line, using the default character encoding of the platform. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        input - the InputStream to read from, not null
        +
        Returns:
        the list of Strings, never null
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        readLines

        +
        public static List<String> readLines(InputStream input,
        +                     Charset encoding)
        +                              throws IOException
        +
        Gets the contents of an InputStream as a list of Strings, + one entry per line, using the specified character encoding. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        input - the InputStream to read from, not null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the list of Strings, never null
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        readLines

        +
        public static List<String> readLines(InputStream input,
        +                     String encoding)
        +                              throws IOException
        +
        Gets the contents of an InputStream as a list of Strings, + one entry per line, using the specified character encoding. +

        + Character encoding names can be found at + IANA. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.

        +
        Parameters:
        input - the InputStream to read from, not null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        the list of Strings, never null
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        readLines

        +
        public static List<String> readLines(Reader input)
        +                              throws IOException
        +
        Gets the contents of a Reader as a list of Strings, + one entry per line. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader.

        +
        Parameters:
        input - the Reader to read from, not null
        +
        Returns:
        the list of Strings, never null
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        lineIterator

        +
        public static LineIterator lineIterator(Reader reader)
        +
        Returns an Iterator for the lines in a Reader. +

        + LineIterator holds a reference to the open + Reader specified here. 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 + LineIterator.close() or LineIterator.closeQuietly(LineIterator). +

        + The recommended usage pattern is: +

        + try {
        +   LineIterator it = IOUtils.lineIterator(reader);
        +   while (it.hasNext()) {
        +     String line = it.nextLine();
        +     /// do something with line
        +   }
        + } finally {
        +   IOUtils.closeQuietly(reader);
        + }
        + 
        +
        Parameters:
        reader - the Reader to read from, not null
        +
        Returns:
        an Iterator of the lines in the reader, never null
        +
        Throws:
        +
        IllegalArgumentException - if the reader is null
        Since:
        +
        1.2
        +
      • +
      + + + +
        +
      • +

        lineIterator

        +
        public static LineIterator lineIterator(InputStream input,
        +                        Charset encoding)
        +                                 throws IOException
        +
        Returns an Iterator for the lines in an InputStream, using + the character encoding specified (or default encoding if null). +

        + LineIterator holds a reference to the open + InputStream specified here. When you have finished with + the iterator you should close the stream to free internal resources. + This can be done by closing the stream directly, or by calling + LineIterator.close() or LineIterator.closeQuietly(LineIterator). +

        + The recommended usage pattern is: +

        + try {
        +   LineIterator it = IOUtils.lineIterator(stream, charset);
        +   while (it.hasNext()) {
        +     String line = it.nextLine();
        +     /// do something with line
        +   }
        + } finally {
        +   IOUtils.closeQuietly(stream);
        + }
        + 
        +
        Parameters:
        input - the InputStream to read from, not null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        an Iterator of the lines in the reader, never null
        +
        Throws:
        +
        IllegalArgumentException - if the input is null
        +
        IOException - if an I/O error occurs, such as if the encoding is invalid
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        lineIterator

        +
        public static LineIterator lineIterator(InputStream input,
        +                        String encoding)
        +                                 throws IOException
        +
        Returns an Iterator for the lines in an InputStream, using + the character encoding specified (or default encoding if null). +

        + LineIterator holds a reference to the open + InputStream specified here. When you have finished with + the iterator you should close the stream to free internal resources. + This can be done by closing the stream directly, or by calling + LineIterator.close() or LineIterator.closeQuietly(LineIterator). +

        + The recommended usage pattern is: +

        + try {
        +   LineIterator it = IOUtils.lineIterator(stream, "UTF-8");
        +   while (it.hasNext()) {
        +     String line = it.nextLine();
        +     /// do something with line
        +   }
        + } finally {
        +   IOUtils.closeQuietly(stream);
        + }
        + 
        +
        Parameters:
        input - the InputStream to read from, not null
        encoding - the encoding to use, null means platform default
        +
        Returns:
        an Iterator of the lines in the reader, never null
        +
        Throws:
        +
        IllegalArgumentException - if the input is null
        +
        IOException - if an I/O error occurs, such as if the encoding is invalid
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.2
        +
      • +
      + + + +
        +
      • +

        toInputStream

        +
        @Deprecated
        +public static InputStream toInputStream(CharSequence input)
        +
        Deprecated. 2.5 use toInputStream(CharSequence, Charset) instead
        +
        Converts the specified CharSequence to an input stream, encoded as bytes + using the default character encoding of the platform.
        +
        Parameters:
        input - the CharSequence to convert
        +
        Returns:
        an input stream
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        toInputStream

        +
        public static InputStream toInputStream(CharSequence input,
        +                        Charset encoding)
        +
        Converts the specified CharSequence to an input stream, encoded as bytes + using the specified character encoding.
        +
        Parameters:
        input - the CharSequence to convert
        encoding - the encoding to use, null means platform default
        +
        Returns:
        an input stream
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        toInputStream

        +
        public static InputStream toInputStream(CharSequence input,
        +                        String encoding)
        +                                 throws IOException
        +
        Converts the specified CharSequence to an input stream, encoded as bytes + using the specified character encoding. +

        + Character encoding names can be found at + IANA.

        +
        Parameters:
        input - the CharSequence to convert
        encoding - the encoding to use, null means platform default
        +
        Returns:
        an input stream
        +
        Throws:
        +
        IOException - if the encoding is invalid
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        toInputStream

        +
        @Deprecated
        +public static InputStream toInputStream(String input)
        +
        Deprecated. 2.5 use toInputStream(String, Charset) instead
        +
        Converts the specified string to an input stream, encoded as bytes + using the default character encoding of the platform.
        +
        Parameters:
        input - the string to convert
        +
        Returns:
        an input stream
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        toInputStream

        +
        public static InputStream toInputStream(String input,
        +                        Charset encoding)
        +
        Converts the specified string to an input stream, encoded as bytes + using the specified character encoding.
        +
        Parameters:
        input - the string to convert
        encoding - the encoding to use, null means platform default
        +
        Returns:
        an input stream
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        toInputStream

        +
        public static InputStream toInputStream(String input,
        +                        String encoding)
        +                                 throws IOException
        +
        Converts the specified string to an input stream, encoded as bytes + using the specified character encoding. +

        + Character encoding names can be found at + IANA.

        +
        Parameters:
        input - the string to convert
        encoding - the encoding to use, null means platform default
        +
        Returns:
        an input stream
        +
        Throws:
        +
        IOException - if the encoding is invalid
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        write

        +
        public static void write(byte[] data,
        +         OutputStream output)
        +                  throws IOException
        +
        Writes bytes from a byte[] to an OutputStream.
        +
        Parameters:
        data - the byte array to write, do not modify during output, + null ignored
        output - the OutputStream to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        writeChunked

        +
        public static void writeChunked(byte[] data,
        +                OutputStream output)
        +                         throws IOException
        +
        Writes bytes from a byte[] to an OutputStream using chunked writes. + This is intended for writing very large byte arrays which might otherwise cause excessive + memory usage if the native code has to allocate a copy.
        +
        Parameters:
        data - the byte array to write, do not modify during output, + null ignored
        output - the OutputStream to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.5
        +
      • +
      + + + + + + + +
        +
      • +

        write

        +
        public static void write(byte[] data,
        +         Writer output,
        +         Charset encoding)
        +                  throws IOException
        +
        Writes bytes from a byte[] to chars on a Writer + using the specified character encoding. +

        + This method uses String.String(byte[], String).

        +
        Parameters:
        data - the byte array to write, do not modify during output, + null ignored
        output - the Writer to write to
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        write

        +
        public static void write(byte[] data,
        +         Writer output,
        +         String encoding)
        +                  throws IOException
        +
        Writes bytes from a byte[] to chars on a Writer + using the specified character encoding. +

        + Character encoding names can be found at + IANA. +

        + This method uses String.String(byte[], String).

        +
        Parameters:
        data - the byte array to write, do not modify during output, + null ignored
        output - the Writer to write to
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        write

        +
        public static void write(char[] data,
        +         Writer output)
        +                  throws IOException
        +
        Writes chars from a char[] to a Writer
        +
        Parameters:
        data - the char array to write, do not modify during output, + null ignored
        output - the Writer to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        writeChunked

        +
        public static void writeChunked(char[] data,
        +                Writer output)
        +                         throws IOException
        +
        Writes chars from a char[] to a Writer using chunked writes. + This is intended for writing very large byte arrays which might otherwise cause excessive + memory usage if the native code has to allocate a copy.
        +
        Parameters:
        data - the char array to write, do not modify during output, + null ignored
        output - the Writer to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.5
        +
      • +
      + + + + + + + +
        +
      • +

        write

        +
        public static void write(char[] data,
        +         OutputStream output,
        +         Charset encoding)
        +                  throws IOException
        +
        Writes chars from a char[] to bytes on an + OutputStream using the specified character encoding. +

        + This method uses String.String(char[]) and + String.getBytes(String).

        +
        Parameters:
        data - the char array to write, do not modify during output, + null ignored
        output - the OutputStream to write to
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + + + + + +
        +
      • +

        write

        +
        public static void write(CharSequence data,
        +         Writer output)
        +                  throws IOException
        +
        Writes chars from a CharSequence to a Writer.
        +
        Parameters:
        data - the CharSequence to write, null ignored
        output - the Writer to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      + + + + + + + +
        +
      • +

        write

        +
        public static void write(CharSequence data,
        +         OutputStream output,
        +         Charset encoding)
        +                  throws IOException
        +
        Writes chars from a CharSequence to bytes on an + OutputStream using the specified character encoding. +

        + This method uses String.getBytes(String).

        +
        Parameters:
        data - the CharSequence to write, null ignored
        output - the OutputStream to write to
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + + + + + +
        +
      • +

        write

        +
        public static void write(String data,
        +         Writer output)
        +                  throws IOException
        +
        Writes chars from a String to a Writer.
        +
        Parameters:
        data - the String to write, null ignored
        output - the Writer to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + + + + + +
        +
      • +

        write

        +
        public static void write(String data,
        +         OutputStream output,
        +         Charset encoding)
        +                  throws IOException
        +
        Writes chars from a String to bytes on an + OutputStream using the specified character encoding. +

        + This method uses String.getBytes(String).

        +
        Parameters:
        data - the String to write, null ignored
        output - the OutputStream to write to
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + + + + + +
        +
      • +

        write

        +
        @Deprecated
        +public static void write(StringBuffer data,
        +                    Writer output)
        +                  throws IOException
        +
        Deprecated. replaced by write(CharSequence, Writer)
        +
        Writes chars from a StringBuffer to a Writer.
        +
        Parameters:
        data - the StringBuffer to write, null ignored
        output - the Writer to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        write

        +
        @Deprecated
        +public static void write(StringBuffer data,
        +                    OutputStream output)
        +                  throws IOException
        +
        Deprecated. replaced by write(CharSequence, OutputStream)
        +
        Writes chars from a StringBuffer to bytes on an + OutputStream using the default character encoding of the + platform. +

        + This method uses String.getBytes().

        +
        Parameters:
        data - the StringBuffer to write, null ignored
        output - the OutputStream to write to
        +
        Throws:
        +
        NullPointerException - if output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + + + + + +
        +
      • +

        writeLines

        +
        @Deprecated
        +public static void writeLines(Collection<?> lines,
        +                         String lineEnding,
        +                         OutputStream output)
        +                       throws IOException
        + +
        Writes the toString() value of each item in a collection to + an OutputStream line by line, using the default character + encoding of the platform and the specified line ending.
        +
        Parameters:
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        output - the OutputStream to write to, not null, not closed
        +
        Throws:
        +
        NullPointerException - if the output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(Collection<?> lines,
        +              String lineEnding,
        +              OutputStream output,
        +              Charset encoding)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + an OutputStream line by line, using the specified character + encoding and the specified line ending.
        +
        Parameters:
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        output - the OutputStream to write to, not null, not closed
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if the output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(Collection<?> lines,
        +              String lineEnding,
        +              OutputStream output,
        +              String encoding)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + an OutputStream line by line, using the specified character + encoding and the specified line ending. +

        + Character encoding names can be found at + IANA.

        +
        Parameters:
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        output - the OutputStream to write to, not null, not closed
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if the output is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        writeLines

        +
        public static void writeLines(Collection<?> lines,
        +              String lineEnding,
        +              Writer writer)
        +                       throws IOException
        +
        Writes the toString() value of each item in a collection to + a Writer line by line, using the specified line ending.
        +
        Parameters:
        lines - the lines to write, null entries produce blank lines
        lineEnding - the line separator to use, null is system default
        writer - the Writer to write to, not null, not closed
        +
        Throws:
        +
        NullPointerException - if the input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static int copy(InputStream input,
        +       OutputStream output)
        +                throws IOException
        +
        Copies bytes from an InputStream to an + OutputStream. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream. +

        + Large streams (over 2GB) will return a bytes copied value of + -1 after the copy has completed since the correct + number of bytes cannot be returned as an int. For large streams + use the copyLarge(InputStream, OutputStream) method.

        +
        Parameters:
        input - the InputStream to read from
        output - the OutputStream to write to
        +
        Returns:
        the number of bytes copied, or -1 if > Integer.MAX_VALUE
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static long copy(InputStream input,
        +        OutputStream output,
        +        int bufferSize)
        +                 throws IOException
        +
        Copies bytes from an InputStream to an OutputStream using an internal buffer of the + given size. +

        + This method buffers the input internally, so there is no need to use a BufferedInputStream. +

        +
        Parameters:
        input - the InputStream to read from
        output - the OutputStream to write to
        bufferSize - the bufferSize used to copy from the input to the output
        +
        Returns:
        the number of bytes copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(InputStream input,
        +             OutputStream output)
        +                      throws IOException
        +
        Copies bytes from a large (over 2GB) InputStream to an + OutputStream. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream. +

        + The buffer size is given by DEFAULT_BUFFER_SIZE.

        +
        Parameters:
        input - the InputStream to read from
        output - the OutputStream to write to
        +
        Returns:
        the number of bytes copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(InputStream input,
        +             OutputStream output,
        +             byte[] buffer)
        +                      throws IOException
        +
        Copies bytes from a large (over 2GB) InputStream to an + OutputStream. +

        + This method uses the provided buffer, so there is no need to use a + BufferedInputStream. +

        +
        Parameters:
        input - the InputStream to read from
        output - the OutputStream to write to
        buffer - the buffer to use for the copy
        +
        Returns:
        the number of bytes copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(InputStream input,
        +             OutputStream output,
        +             long inputOffset,
        +             long length)
        +                      throws IOException
        +
        Copies some or all bytes from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input bytes. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream. +

        +

        + Note that the implementation uses skip(InputStream, long). + This means that the method may be considerably less efficient than using the actual skip implementation, + this is done to guarantee that the correct number of characters are skipped. +

        + The buffer size is given by DEFAULT_BUFFER_SIZE.
        +
        Parameters:
        input - the InputStream to read from
        output - the OutputStream to write to
        inputOffset - : number of bytes to skip from input before copying + -ve values are ignored
        length - : number of bytes to copy. -ve means all
        +
        Returns:
        the number of bytes copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(InputStream input,
        +             OutputStream output,
        +             long inputOffset,
        +             long length,
        +             byte[] buffer)
        +                      throws IOException
        +
        Copies some or all bytes from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input bytes. +

        + This method uses the provided buffer, so there is no need to use a + BufferedInputStream. +

        +

        + Note that the implementation uses skip(InputStream, long). + This means that the method may be considerably less efficient than using the actual skip implementation, + this is done to guarantee that the correct number of characters are skipped. +

        +
        Parameters:
        input - the InputStream to read from
        output - the OutputStream to write to
        inputOffset - : number of bytes to skip from input before copying + -ve values are ignored
        length - : number of bytes to copy. -ve means all
        buffer - the buffer to use for the copy
        +
        Returns:
        the number of bytes copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        copy

        +
        @Deprecated
        +public static void copy(InputStream input,
        +                   Writer output)
        +                 throws IOException
        +
        Deprecated. 2.5 use copy(InputStream, Writer, Charset) instead
        +
        Copies bytes from an InputStream to chars on a + Writer using the default character encoding of the platform. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream. +

        + This method uses InputStreamReader.

        +
        Parameters:
        input - the InputStream to read from
        output - the Writer to write to
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(InputStream input,
        +        Writer output,
        +        Charset inputEncoding)
        +                 throws IOException
        +
        Copies bytes from an InputStream to chars on a + Writer using the specified character encoding. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream. +

        + This method uses InputStreamReader.

        +
        Parameters:
        input - the InputStream to read from
        output - the Writer to write to
        inputEncoding - the encoding to use for the input stream, null means platform default
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(InputStream input,
        +        Writer output,
        +        String inputEncoding)
        +                 throws IOException
        +
        Copies bytes from an InputStream to chars on a + Writer using the specified character encoding. +

        + This method buffers the input internally, so there is no need to use a + BufferedInputStream. +

        + Character encoding names can be found at + IANA. +

        + This method uses InputStreamReader.

        +
        Parameters:
        input - the InputStream to read from
        output - the Writer to write to
        inputEncoding - the encoding to use for the InputStream, null means platform default
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static int copy(Reader input,
        +       Writer output)
        +                throws IOException
        +
        Copies chars from a Reader to a Writer. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader. +

        + Large streams (over 2GB) will return a chars copied value of + -1 after the copy has completed since the correct + number of chars cannot be returned as an int. For large streams + use the copyLarge(Reader, Writer) method.

        +
        Parameters:
        input - the Reader to read from
        output - the Writer to write to
        +
        Returns:
        the number of characters copied, or -1 if > Integer.MAX_VALUE
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(Reader input,
        +             Writer output)
        +                      throws IOException
        +
        Copies chars from a large (over 2GB) Reader to a Writer. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader. +

        + The buffer size is given by DEFAULT_BUFFER_SIZE.

        +
        Parameters:
        input - the Reader to read from
        output - the Writer to write to
        +
        Returns:
        the number of characters copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(Reader input,
        +             Writer output,
        +             char[] buffer)
        +                      throws IOException
        +
        Copies chars from a large (over 2GB) Reader to a Writer. +

        + This method uses the provided buffer, so there is no need to use a + BufferedReader. +

        +
        Parameters:
        input - the Reader to read from
        output - the Writer to write to
        buffer - the buffer to be used for the copy
        +
        Returns:
        the number of characters copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(Reader input,
        +             Writer output,
        +             long inputOffset,
        +             long length)
        +                      throws IOException
        +
        Copies some or all chars from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input chars. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader. +

        + The buffer size is given by DEFAULT_BUFFER_SIZE.

        +
        Parameters:
        input - the Reader to read from
        output - the Writer to write to
        inputOffset - : number of chars to skip from input before copying + -ve values are ignored
        length - : number of chars to copy. -ve means all
        +
        Returns:
        the number of chars copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        copyLarge

        +
        public static long copyLarge(Reader input,
        +             Writer output,
        +             long inputOffset,
        +             long length,
        +             char[] buffer)
        +                      throws IOException
        +
        Copies some or all chars from a large (over 2GB) InputStream to an + OutputStream, optionally skipping input chars. +

        + This method uses the provided buffer, so there is no need to use a + BufferedReader. +

        +
        Parameters:
        input - the Reader to read from
        output - the Writer to write to
        inputOffset - : number of chars to skip from input before copying + -ve values are ignored
        length - : number of chars to copy. -ve means all
        buffer - the buffer to be used for the copy
        +
        Returns:
        the number of chars copied
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        copy

        +
        @Deprecated
        +public static void copy(Reader input,
        +                   OutputStream output)
        +                 throws IOException
        +
        Deprecated. 2.5 use copy(Reader, OutputStream, Charset) instead
        +
        Copies chars from a Reader to bytes on an + OutputStream using the default character encoding of the + platform, and calling flush. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader. +

        + Due to the implementation of OutputStreamWriter, this method performs a + flush. +

        + This method uses OutputStreamWriter.

        +
        Parameters:
        input - the Reader to read from
        output - the OutputStream to write to
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(Reader input,
        +        OutputStream output,
        +        Charset outputEncoding)
        +                 throws IOException
        +
        Copies chars from a Reader to bytes on an + OutputStream using the specified character encoding, and + calling flush. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader. +

        +

        + Due to the implementation of OutputStreamWriter, this method performs a + flush. +

        +

        + This method uses OutputStreamWriter. +

        +
        Parameters:
        input - the Reader to read from
        output - the OutputStream to write to
        outputEncoding - the encoding to use for the OutputStream, null means platform default
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        copy

        +
        public static void copy(Reader input,
        +        OutputStream output,
        +        String outputEncoding)
        +                 throws IOException
        +
        Copies chars from a Reader to bytes on an + OutputStream using the specified character encoding, and + calling flush. +

        + This method buffers the input internally, so there is no need to use a + BufferedReader. +

        + Character encoding names can be found at + IANA. +

        + Due to the implementation of OutputStreamWriter, this method performs a + flush. +

        + This method uses OutputStreamWriter.

        +
        Parameters:
        input - the Reader to read from
        output - the OutputStream to write to
        outputEncoding - the encoding to use for the OutputStream, null means platform default
        +
        Throws:
        +
        NullPointerException - if the input or output is null
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of .UnsupportedEncodingException in version 2.2 if the + encoding is not supported.
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        contentEquals

        +
        public static boolean contentEquals(InputStream input1,
        +                    InputStream input2)
        +                             throws IOException
        +
        Compares the contents of two Streams to determine if they are equal or + not. +

        + This method buffers the input internally using + BufferedInputStream if they are not already buffered.

        +
        Parameters:
        input1 - the first stream
        input2 - the second stream
        +
        Returns:
        true if the content of the streams are equal or they both don't + exist, false otherwise
        +
        Throws:
        +
        NullPointerException - if either input is null
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        contentEquals

        +
        public static boolean contentEquals(Reader input1,
        +                    Reader input2)
        +                             throws IOException
        +
        Compares the contents of two Readers to determine if they are equal or + not. +

        + This method buffers the input internally using + BufferedReader if they are not already buffered.

        +
        Parameters:
        input1 - the first reader
        input2 - the second reader
        +
        Returns:
        true if the content of the readers are equal or they both don't + exist, false otherwise
        +
        Throws:
        +
        NullPointerException - if either input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        contentEqualsIgnoreEOL

        +
        public static boolean contentEqualsIgnoreEOL(Reader input1,
        +                             Reader input2)
        +                                      throws IOException
        +
        Compares the contents of two Readers to determine if they are equal or + not, ignoring EOL characters. +

        + This method buffers the input internally using + BufferedReader if they are not already buffered.

        +
        Parameters:
        input1 - the first reader
        input2 - the second reader
        +
        Returns:
        true if the content of the readers are equal (ignoring EOL differences), false otherwise
        +
        Throws:
        +
        NullPointerException - if either input is null
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.2
        +
      • +
      + + + + + + + +
        +
      • +

        skip

        +
        public static long skip(ReadableByteChannel input,
        +        long toSkip)
        +                 throws IOException
        +
        Skips bytes from a ReadableByteChannel. + This implementation guarantees that it will read as many bytes + as possible before giving up.
        +
        Parameters:
        input - ReadableByteChannel to skip
        toSkip - number of bytes to skip.
        +
        Returns:
        number of bytes actually skipped.
        +
        Throws:
        +
        IOException - if there is a problem reading the ReadableByteChannel
        +
        IllegalArgumentException - if toSkip is negative
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        skip

        +
        public static long skip(Reader input,
        +        long toSkip)
        +                 throws IOException
        +
        Skips characters from an input character stream. + This implementation guarantees that it will read as many characters + as possible before giving up; this may not always be the case for + skip() implementations in subclasses of Reader. +

        + Note that the implementation uses Reader.read(char[], int, int) rather + than delegating to Reader.skip(long). + This means that the method may be considerably less efficient than using the actual skip implementation, + this is done to guarantee that the correct number of characters are skipped. +

        +
        Parameters:
        input - character stream to skip
        toSkip - number of characters to skip.
        +
        Returns:
        number of characters actually skipped.
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if toSkip is negative
        Since:
        +
        2.0
        +
        See Also:
        Reader.skip(long), +IO-203 - Add skipFully() method for InputStreams
        +
      • +
      + + + +
        +
      • +

        skipFully

        +
        public static void skipFully(InputStream input,
        +             long toSkip)
        +                      throws IOException
        +
        Skips the requested number of bytes or fail if there are not enough left. +

        + This allows for the possibility that InputStream.skip(long) may + not skip as many bytes as requested (most likely because of reaching EOF). +

        + Note that the implementation uses skip(InputStream, long). + This means that the method may be considerably less efficient than using the actual skip implementation, + this is done to guarantee that the correct number of characters are skipped. +

        +
        Parameters:
        input - stream to skip
        toSkip - the number of bytes to skip
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if toSkip is negative
        +
        EOFException - if the number of bytes skipped was incorrect
        Since:
        +
        2.0
        +
        See Also:
        InputStream.skip(long)
        +
      • +
      + + + +
        +
      • +

        skipFully

        +
        public static void skipFully(ReadableByteChannel input,
        +             long toSkip)
        +                      throws IOException
        +
        Skips the requested number of bytes or fail if there are not enough left.
        +
        Parameters:
        input - ReadableByteChannel to skip
        toSkip - the number of bytes to skip
        +
        Throws:
        +
        IOException - if there is a problem reading the ReadableByteChannel
        +
        IllegalArgumentException - if toSkip is negative
        +
        EOFException - if the number of bytes skipped was incorrect
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        skipFully

        +
        public static void skipFully(Reader input,
        +             long toSkip)
        +                      throws IOException
        +
        Skips the requested number of characters or fail if there are not enough left. +

        + This allows for the possibility that Reader.skip(long) may + not skip as many characters as requested (most likely because of reaching EOF). +

        + Note that the implementation uses skip(Reader, long). + This means that the method may be considerably less efficient than using the actual skip implementation, + this is done to guarantee that the correct number of characters are skipped. +

        +
        Parameters:
        input - stream to skip
        toSkip - the number of characters to skip
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if toSkip is negative
        +
        EOFException - if the number of characters skipped was incorrect
        Since:
        +
        2.0
        +
        See Also:
        Reader.skip(long)
        +
      • +
      + + + +
        +
      • +

        read

        +
        public static int read(Reader input,
        +       char[] buffer,
        +       int offset,
        +       int length)
        +                throws IOException
        +
        Reads characters from an input character stream. + This implementation guarantees that it will read as many characters + as possible before giving up; this may not always be the case for + subclasses of Reader.
        +
        Parameters:
        input - where to read input from
        buffer - destination
        offset - initial offset into buffer
        length - length to read, must be >= 0
        +
        Returns:
        actual length read; may be less than requested if EOF was reached
        +
        Throws:
        +
        IOException - if a read error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        read

        +
        public static int read(Reader input,
        +       char[] buffer)
        +                throws IOException
        +
        Reads characters from an input character stream. + This implementation guarantees that it will read as many characters + as possible before giving up; this may not always be the case for + subclasses of Reader.
        +
        Parameters:
        input - where to read input from
        buffer - destination
        +
        Returns:
        actual length read; may be less than requested if EOF was reached
        +
        Throws:
        +
        IOException - if a read error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        read

        +
        public static int read(InputStream input,
        +       byte[] buffer,
        +       int offset,
        +       int length)
        +                throws IOException
        +
        Reads bytes from an input stream. + This implementation guarantees that it will read as many bytes + as possible before giving up; this may not always be the case for + subclasses of InputStream.
        +
        Parameters:
        input - where to read input from
        buffer - destination
        offset - initial offset into buffer
        length - length to read, must be >= 0
        +
        Returns:
        actual length read; may be less than requested if EOF was reached
        +
        Throws:
        +
        IOException - if a read error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        read

        +
        public static int read(InputStream input,
        +       byte[] buffer)
        +                throws IOException
        +
        Reads bytes from an input stream. + This implementation guarantees that it will read as many bytes + as possible before giving up; this may not always be the case for + subclasses of InputStream.
        +
        Parameters:
        input - where to read input from
        buffer - destination
        +
        Returns:
        actual length read; may be less than requested if EOF was reached
        +
        Throws:
        +
        IOException - if a read error occurs
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        read

        +
        public static int read(ReadableByteChannel input,
        +       ByteBuffer buffer)
        +                throws IOException
        +
        Reads bytes from a ReadableByteChannel. +

        + This implementation guarantees that it will read as many bytes + as possible before giving up; this may not always be the case for + subclasses of ReadableByteChannel.

        +
        Parameters:
        input - the byte channel to read
        buffer - byte buffer destination
        +
        Returns:
        the actual length read; may be less than requested if EOF was reached
        +
        Throws:
        +
        IOException - if a read error occurs
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        readFully

        +
        public static void readFully(Reader input,
        +             char[] buffer,
        +             int offset,
        +             int length)
        +                      throws IOException
        +
        Reads the requested number of characters or fail if there are not enough left. +

        + This allows for the possibility that Reader.read(char[], int, int) may + not read as many characters as requested (most likely because of reaching EOF).

        +
        Parameters:
        input - where to read input from
        buffer - destination
        offset - initial offset into buffer
        length - length to read, must be >= 0
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if length is negative
        +
        EOFException - if the number of characters read was incorrect
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        readFully

        +
        public static void readFully(Reader input,
        +             char[] buffer)
        +                      throws IOException
        +
        Reads the requested number of characters or fail if there are not enough left. +

        + This allows for the possibility that Reader.read(char[], int, int) may + not read as many characters as requested (most likely because of reaching EOF).

        +
        Parameters:
        input - where to read input from
        buffer - destination
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if length is negative
        +
        EOFException - if the number of characters read was incorrect
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        readFully

        +
        public static void readFully(InputStream input,
        +             byte[] buffer,
        +             int offset,
        +             int length)
        +                      throws IOException
        +
        Reads the requested number of bytes or fail if there are not enough left. +

        + This allows for the possibility that InputStream.read(byte[], int, int) may + not read as many bytes as requested (most likely because of reaching EOF).

        +
        Parameters:
        input - where to read input from
        buffer - destination
        offset - initial offset into buffer
        length - length to read, must be >= 0
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if length is negative
        +
        EOFException - if the number of bytes read was incorrect
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        readFully

        +
        public static void readFully(InputStream input,
        +             byte[] buffer)
        +                      throws IOException
        +
        Reads the requested number of bytes or fail if there are not enough left. +

        + This allows for the possibility that InputStream.read(byte[], int, int) may + not read as many bytes as requested (most likely because of reaching EOF).

        +
        Parameters:
        input - where to read input from
        buffer - destination
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if length is negative
        +
        EOFException - if the number of bytes read was incorrect
        Since:
        +
        2.2
        +
      • +
      + + + +
        +
      • +

        readFully

        +
        public static byte[] readFully(InputStream input,
        +               int length)
        +                        throws IOException
        +
        Reads the requested number of bytes or fail if there are not enough left. +

        + This allows for the possibility that InputStream.read(byte[], int, int) may + not read as many bytes as requested (most likely because of reaching EOF).

        +
        Parameters:
        input - where to read input from
        length - length to read, must be >= 0
        +
        Returns:
        the bytes read from input
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        IllegalArgumentException - if length is negative
        +
        EOFException - if the number of bytes read was incorrect
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        readFully

        +
        public static void readFully(ReadableByteChannel input,
        +             ByteBuffer buffer)
        +                      throws IOException
        +
        Reads the requested number of bytes or fail if there are not enough left. +

        + This allows for the possibility that ReadableByteChannel.read(ByteBuffer) may + not read as many bytes as requested (most likely because of reaching EOF).

        +
        Parameters:
        input - the byte channel to read
        buffer - byte buffer destination
        +
        Throws:
        +
        IOException - if there is a problem reading the file
        +
        EOFException - if the number of bytes read was incorrect
        Since:
        +
        2.5
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/LineIterator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/LineIterator.html" new file mode 100644 index 0000000000000000000000000000000000000000..e640dd469e82d9b492184abd6c4be8f46f11a99d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/LineIterator.html" @@ -0,0 +1,421 @@ + + + + + +LineIterator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class LineIterator

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Iterator<String>
    +
    +
    +
    +
    public class LineIterator
    +extends Object
    +implements Iterator<String>
    +
    An Iterator over the lines in a Reader. +

    + LineIterator holds a reference to an open Reader. + 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 close() or closeQuietly(LineIterator) + method on the iterator. +

    + The recommended usage pattern is: +

    + LineIterator it = FileUtils.lineIterator(file, "UTF-8");
    + try {
    +   while (it.hasNext()) {
    +     String line = it.nextLine();
    +     // do something with line
    +   }
    + } finally {
    +   it.close();
    + }
    + 
    +
    Since:
    +
    1.2
    +
    Version:
    +
    $Id: LineIterator.java 1471767 2013-04-24 23:24:19Z sebb $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      LineIterator(Reader reader) +
      Constructs an iterator of the lines for a Reader.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        hasNext

        +
        public boolean hasNext()
        +
        Indicates whether the Reader has more lines. + If there is an IOException then close() will + be called on this instance.
        +
        +
        Specified by:
        +
        hasNext in interface Iterator<String>
        +
        Returns:
        true if the Reader has more lines
        +
        Throws:
        +
        IllegalStateException - if an IO exception occurs
        +
      • +
      + + + +
        +
      • +

        isValidLine

        +
        protected boolean isValidLine(String line)
        +
        Overridable method to validate each line that is returned. + This implementation always returns true.
        +
        Parameters:
        line - the line that is to be validated
        +
        Returns:
        true if valid, false to remove from the iterator
        +
      • +
      + + + +
        +
      • +

        next

        +
        public String next()
        +
        Returns the next line in the wrapped Reader.
        +
        +
        Specified by:
        +
        next in interface Iterator<String>
        +
        Returns:
        the next line from the input
        +
        Throws:
        +
        NoSuchElementException - if there is no line to return
        +
      • +
      + + + +
        +
      • +

        nextLine

        +
        public String nextLine()
        +
        Returns the next line in the wrapped Reader.
        +
        Returns:
        the next line from the input
        +
        Throws:
        +
        NoSuchElementException - if there is no line to return
        +
      • +
      + + + +
        +
      • +

        close

        +
        public void close()
        +
        Closes the underlying Reader 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 Reader remains open. + This method can safely be called multiple times.
        +
      • +
      + + + + + + + +
        +
      • +

        closeQuietly

        +
        public static void closeQuietly(LineIterator iterator)
        +
        Closes the iterator, handling null and ignoring exceptions.
        +
        Parameters:
        iterator - the iterator to close
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/TaggedIOException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/TaggedIOException.html" new file mode 100644 index 0000000000000000000000000000000000000000..90d07a23bc92d7859da4effb1261d9b4756c2f00 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/TaggedIOException.html" @@ -0,0 +1,403 @@ + + + + + +TaggedIOException (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io
+

Class TaggedIOException

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable
    +
    +
    +
    +
    public class TaggedIOException
    +extends IOExceptionWithCause
    +
    An 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
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TaggedIOException

        +
        public TaggedIOException(IOException original,
        +                 Serializable tag)
        +
        Creates a tagged wrapper for the given exception.
        +
        Parameters:
        original - the exception to be tagged
        tag - tag of this exception
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        isTaggedWith

        +
        public static boolean isTaggedWith(Throwable throwable,
        +                   Object tag)
        +
        Checks whether the given throwable is tagged with the given tag. +

        + This check can only succeed if the throwable is a + TaggedIOException and the tag is Serializable, but + the argument types are intentionally more generic to make it easier + to use this method without type casts. +

        + A typical use for this method is in a catch block to + determine how a caught exception should be handled: +

        + Serializable tag = ...;
        + try {
        +     ...;
        + } catch (Throwable t) {
        +     if (TaggedIOExcepton.isTaggedWith(t, tag)) {
        +         // special processing for tagged exception
        +     } else {
        +         // handling of other kinds of exceptions
        +     }
        + }
        + 
        +
        Parameters:
        throwable - The Throwable object to check
        tag - tag object
        +
        Returns:
        true if the throwable has the specified tag, + otherwise false
        +
      • +
      + + + +
        +
      • +

        throwCauseIfTaggedWith

        +
        public static void throwCauseIfTaggedWith(Throwable throwable,
        +                          Object tag)
        +                                   throws IOException
        +
        Throws the original IOException if the given throwable is + a 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. +

        + This method is typically used in a catch block to + selectively rethrow tagged exceptions. +

        + Serializable tag = ...;
        + try {
        +     ...;
        + } catch (Throwable t) {
        +     TaggedIOExcepton.throwCauseIfTagged(t, tag);
        +     // handle other kinds of exceptions
        + }
        + 
        +
        Parameters:
        throwable - an exception
        tag - tag object
        +
        Throws:
        +
        IOException - original exception from the tagged decorator, if any
        +
      • +
      + + + +
        +
      • +

        getTag

        +
        public Serializable getTag()
        +
        Returns the serializable tag object.
        +
        Returns:
        tag object
        +
      • +
      + + + +
        +
      • +

        getCause

        +
        public IOException getCause()
        +
        Returns the wrapped exception. The only difference to the overridden + Throwable.getCause() method is the narrower return type.
        +
        +
        Overrides:
        +
        getCause in class Throwable
        +
        Returns:
        wrapped exception
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/ByteOrderMark.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/ByteOrderMark.html" index 5b044ffab7bb567be3c2e144cd0323ba77a1fbf6..a44a753b24210b90dfffd0b8f366494598fe7614 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/ByteOrderMark.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/ByteOrderMark.html" @@ -1,3 +1,249 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d9b9fe4e9c065be8612b5115edb9811313a11256fb42b6b8564cadfbe7fe7856 -size 12785 + + + + + +Uses of Class org.apache.commons.io.ByteOrderMark (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.ByteOrderMark

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/Charsets.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/Charsets.html" index 6c44c4fd6bf4db800af7afe71b2cf46177863ec7..3fd29469c8eb4396be5e510565d5a719027d72ef 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/Charsets.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/Charsets.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:77f53f7bb2d49efda83e8d7e484473aac9dea394d2a895824ab80b94212053a3 -size 4227 + + + + + +Uses of Class org.apache.commons.io.Charsets (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.Charsets

+
+
No usage of org.apache.commons.io.Charsets
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/CopyUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/CopyUtils.html" index c0a41b56db05fc7b8d6797e47c7c743cfe225b9e..5e1a6f77f908d4a01b4fc19bab17979cd118288d 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/CopyUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/CopyUtils.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d40199ed38d7564d86036e30780a3ff380853ddc31b541f7d7dc6a917b60217f -size 4238 + + + + + +Uses of Class org.apache.commons.io.CopyUtils (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.CopyUtils

+
+
No usage of org.apache.commons.io.CopyUtils
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.CancelException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.CancelException.html" index 724b214e201d1b9918d5ecca8fc90388592bae01..e2f947d658a5ffd8e452b4b3264e07b0fc20f2a2 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.CancelException.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.CancelException.html" @@ -1,3 +1,163 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:40decc71f882b7fbb4b1a769ed43f0e51493506d8ba38c9ccf4a97ff2c28aa30 -size 7355 + + + + + +Uses of Class org.apache.commons.io.DirectoryWalker.CancelException (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.DirectoryWalker.CancelException

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.html" index 2c9579b52b82668235c37610112e9130229d6c3b..69eeddb4b5d3e0ca065fcc1024c9ae1f00f2d7d6 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/DirectoryWalker.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b2da7197cb18f9091a729c989c9af10b9eb662d301dcca39c19a518f3861a5dc -size 4304 + + + + + +Uses of Class org.apache.commons.io.DirectoryWalker (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.DirectoryWalker

+
+
No usage of org.apache.commons.io.DirectoryWalker
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/EndianUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/EndianUtils.html" index 0fb224ccbff45747e3cde1caf2fd6ed371c16e88..b47407564beaf15bbe03bae6936aebf0edf0232b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/EndianUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/EndianUtils.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0f7aa9205b260c88b5713ba193d4d33a0c1df926dc5f83748deba32777b1ace8 -size 4260 + + + + + +Uses of Class org.apache.commons.io.EndianUtils (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.EndianUtils

+
+
No usage of org.apache.commons.io.EndianUtils
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaner.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaner.html" index 5b210b7d75994f6ceecce821a6e15ffa122ef50c..9953f42f263b51ba45652ab0fa051614a0b6ead0 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaner.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaner.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4be5444dda2a668b8ef661a615b227d5018ba22766df493f3cd013756972ccf5 -size 4260 + + + + + +Uses of Class org.apache.commons.io.FileCleaner (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.FileCleaner

+
+
No usage of org.apache.commons.io.FileCleaner
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaningTracker.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaningTracker.html" index 8f8f6399ab0df130946fa41f0488976c07e2d0f7..2af5c8872d0d49de78b783158a54965e2f3a0cb8 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaningTracker.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileCleaningTracker.html" @@ -1,3 +1,162 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8d532308cc23458b92fa258f6cabf15b650fa54275ea38ba4b0143d9fc93e6d6 -size 6601 + + + + + +Uses of Class org.apache.commons.io.FileCleaningTracker (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.FileCleaningTracker

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileDeleteStrategy.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileDeleteStrategy.html" index b29697014e6ea12611c0a5011ee6e8f7601ea8f6..1fc88b518e924995992362583437c75cf2a28586 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileDeleteStrategy.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileDeleteStrategy.html" @@ -1,3 +1,216 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dfd75b5c6d7a4e3d62d827d4d45c8b437fc8cf620ec801705267407aeee73b17 -size 11871 + + + + + +Uses of Class org.apache.commons.io.FileDeleteStrategy (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.FileDeleteStrategy

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileExistsException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileExistsException.html" index 727d205f47efbff7b7afd27ac5712705e7180a7b..0c852bf0d38594d964bcc89f2f27b5d7c593da0b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileExistsException.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileExistsException.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6ed41ab4e5caa7d6e22d780f4cc4ed51bb4905b8985ceaab5240a3680552ffe3 -size 4348 + + + + + +Uses of Class org.apache.commons.io.FileExistsException (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.FileExistsException

+
+
No usage of org.apache.commons.io.FileExistsException
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileSystemUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileSystemUtils.html" index f1291799e9defc1f55fb1676cf48f4af9c316077..19e53b3330b05959dd9ca3ac4e761562867c4018 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileSystemUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileSystemUtils.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ae54fe3a42adb24b2a5a1f96f4aa232e1f0a29d1e699026583375a306daf377a -size 4304 + + + + + +Uses of Class org.apache.commons.io.FileSystemUtils (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.FileSystemUtils

+
+
No usage of org.apache.commons.io.FileSystemUtils
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileUtils.html" index b0b634dfbff1ea1926292c9619ab1c3c162d563d..34356e4d4e08257d461a6b5f5bdeeeb0a0d6b94f 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FileUtils.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4c3cdf6ad292a55aa261a271bc081cf0b00b0d15c319872d1ac1f8a07d252c2d -size 4238 + + + + + +Uses of Class org.apache.commons.io.FileUtils (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.FileUtils

+
+
No usage of org.apache.commons.io.FileUtils
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FilenameUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FilenameUtils.html" index eb418ad0af7b91e7894e8363ea658191a9f6d0e0..8f321ac78724aeebe2415cd1eae3eed3274429f0 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FilenameUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/FilenameUtils.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:034cde7b886c69f147d311b9ae40c4248cc9b176ae6c622dd9e71646bf75b266 -size 4282 + + + + + +Uses of Class org.apache.commons.io.FilenameUtils (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.FilenameUtils

+
+
No usage of org.apache.commons.io.FilenameUtils
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/HexDump.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/HexDump.html" index e67218ad354d2a4f5aca13ff760dae9cd612bb7e..28e314fd0b58d717a8fe32395321f60af01959fd 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/HexDump.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/HexDump.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9d68980e1e549c082b2d8910a495384fa2894a15f6b360dd44ff05c76a40eeac -size 4216 + + + + + +Uses of Class org.apache.commons.io.HexDump (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.HexDump

+
+
No usage of org.apache.commons.io.HexDump
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOCase.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOCase.html" index 8c78299d6e6575ccaa84b7d53f3f12406ad8279c..fa397e1463dc7fb9fef05c89ac6359ad8da0bbd9 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOCase.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOCase.html" @@ -1,3 +1,416 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ac9e44c8999cae9711c49a6d3a9dba0749fa1b9c2de64f4a709afc58f40c3dae -size 30626 + + + + + +Uses of Class org.apache.commons.io.IOCase (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.IOCase

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOExceptionWithCause.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOExceptionWithCause.html" index 30d26df75b8323112e0d9a457c5f58680d3ff239..a6340ec09b43f38ac9ae290f86ab30afd3d7a817 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOExceptionWithCause.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOExceptionWithCause.html" @@ -1,3 +1,162 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5caf12901a7c83d720e72a30c4191c4cb5433ad65556b88846d9eab63af8bfc7 -size 6566 + + + + + +Uses of Class org.apache.commons.io.IOExceptionWithCause (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.IOExceptionWithCause

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOUtils.html" index fcf733d8dcf27bdb6bd556dde6c2ebf0b759b03b..3ebfe63aef1c316eeaed1d55d3362f3b0b5522c8 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/IOUtils.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cf4398de6fe593b8c157ece376541d8a0c17c4f92fe59cb876d7a94eefe58594 -size 4216 + + + + + +Uses of Class org.apache.commons.io.IOUtils (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.IOUtils

+
+
No usage of org.apache.commons.io.IOUtils
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/LineIterator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/LineIterator.html" index c70fe60348f3f61f7bbbe54ad1493c071e2f0284..61722d0fb8d6cb18e618091b87f3fdca28c86380 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/LineIterator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/LineIterator.html" @@ -1,3 +1,205 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:45c8dea559db21983d5b02a54c4a7b52e10ab75c6c24bb93ec340abc375fed00 -size 10963 + + + + + +Uses of Class org.apache.commons.io.LineIterator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.LineIterator

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/TaggedIOException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/TaggedIOException.html" index f14ac3867e219b5a5bd7c83ea2ff90848eb4679b..8eff34959c54adf543c9192a0610e597437b5f77 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/TaggedIOException.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/class-use/TaggedIOException.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f1799ff9522c0a28207e6dc1bb195c90ad14d668ea7f2fdebafc4a3ba35c8c5e -size 4326 + + + + + +Uses of Class org.apache.commons.io.TaggedIOException (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.TaggedIOException

+
+
No usage of org.apache.commons.io.TaggedIOException
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/CompositeFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/CompositeFileComparator.html" index fb9524bdb4e9d30c1d16a451431d4b59e9bc611b..9a7c2b05980491f14c53f904bceedd64a0d32e46 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/CompositeFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/CompositeFileComparator.html" @@ -1,3 +1,380 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:95b4d7ae1048d568b292bfb5f306e2a8d3607bb8d5556be099faee1c4b4f4a05 -size 21574 + + + + + +CompositeFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class CompositeFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.CompositeFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class CompositeFileComparator
    +extends Object
    +implements Serializable
    +
    Compare two files using a set of delegate file Comparator. +

    + This comparator can be used to sort lists or arrays of files + by combining a number other comparators. +

    + Example of sorting a list of files by type (i.e. directory or file) + and then by name: +

    +       CompositeFileComparator comparator =
    +                       new CompositeFileComparator(
    +                                 (AbstractFileComparator) DirectoryFileComparator.DIRECTORY_COMPARATOR,
    +                                 (AbstractFileComparator) NameFileComparator.NAME_COMPARATOR);
    +       List<File> list = ...
    +       comparator.sort(list);
    + 
    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: CompositeFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CompositeFileComparator

        +
        public CompositeFileComparator(Comparator<File>... delegates)
        +
        Create a composite comparator for the set of delegate comparators.
        +
        Parameters:
        delegates - The delegate file comparators
        +
      • +
      + + + +
        +
      • +

        CompositeFileComparator

        +
        public CompositeFileComparator(Iterable<Comparator<File>> delegates)
        +
        Create a composite comparator for the set of delegate comparators.
        +
        Parameters:
        delegates - The delegate file comparators
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the two files using delegate comparators.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        the first non-zero result returned from + the delegate comparators or zero.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        Returns:
        String representation of this file comparator
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DefaultFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DefaultFileComparator.html" index e0ab77ad9ba36c76dc26e5b904803dce71e8bb1b..4fdae248d8200c03e8c62f7a1d9ae0c02e6a11ba 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DefaultFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DefaultFileComparator.html" @@ -1,3 +1,422 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e3b4b192931e44ef31e134a8e7e853837199f2d795cc22be5b85a91ce916d158 -size 23515 + + + + + +DefaultFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class DefaultFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.DefaultFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class DefaultFileComparator
    +extends Object
    +implements Serializable
    +
    Compare two files using the default File.compareTo(File) method. +

    + This comparator can be used to sort lists or arrays of files + by using the default file comparison. +

    + Example of sorting a list of files using the + DEFAULT_COMPARATOR singleton instance: +

    +       List<File> list = ...
    +       ((AbstractFileComparator) DefaultFileComparator.DEFAULT_COMPARATOR).sort(list);
    + 
    +

    + Example of doing a reverse sort of an array of files using the + DEFAULT_REVERSE singleton instance: +

    +       File[] array = ...
    +       ((AbstractFileComparator) DefaultFileComparator.DEFAULT_REVERSE).sort(array);
    + 
    +

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: DefaultFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        DEFAULT_COMPARATOR

        +
        public static final Comparator<File> DEFAULT_COMPARATOR
        +
        Singleton default comparator instance
        +
      • +
      + + + +
        +
      • +

        DEFAULT_REVERSE

        +
        public static final Comparator<File> DEFAULT_REVERSE
        +
        Singleton reverse default comparator instance
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DefaultFileComparator

        +
        public DefaultFileComparator()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the two files using the File.compareTo(File) method.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        the result of calling file1's + File.compareTo(File) with file2 as the parameter.
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        String representation of this file comparator
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DirectoryFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DirectoryFileComparator.html" index 5adfaa4e5fb6f76b3ffb10a915ea5acaac90f2e4..8969eaee62b3ca5f31cd59640d58767b9ea1136c 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DirectoryFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/DirectoryFileComparator.html" @@ -1,3 +1,421 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:72a882c649b7af866dca1f6b24cbe7e48b9861dbab899289650ea8a00b8e8a3f -size 23554 + + + + + +DirectoryFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class DirectoryFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.DirectoryFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class DirectoryFileComparator
    +extends Object
    +implements Serializable
    +
    Compare two files using the File.isDirectory() method. +

    + This comparator can be used to sort lists or arrays by directories and files. +

    + Example of sorting a list of files/directories using the + DIRECTORY_COMPARATOR singleton instance: +

    +       List<File> list = ...
    +       ((AbstractFileComparator) DirectoryFileComparator.DIRECTORY_COMPARATOR).sort(list);
    + 
    +

    + Example of doing a reverse sort of an array of files/directories using the + DIRECTORY_REVERSE singleton instance: +

    +       File[] array = ...
    +       ((AbstractFileComparator) DirectoryFileComparator.DIRECTORY_REVERSE).sort(array);
    + 
    +

    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: DirectoryFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        DIRECTORY_COMPARATOR

        +
        public static final Comparator<File> DIRECTORY_COMPARATOR
        +
        Singleton default comparator instance
        +
      • +
      + + + +
        +
      • +

        DIRECTORY_REVERSE

        +
        public static final Comparator<File> DIRECTORY_REVERSE
        +
        Singleton reverse default comparator instance
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DirectoryFileComparator

        +
        public DirectoryFileComparator()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the two files using the File.isDirectory() method.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        the result of calling file1's + File.compareTo(File) with file2 as the parameter.
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        String representation of this file comparator
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/ExtensionFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/ExtensionFileComparator.html" index 102c543b82145c5dbd34bcb846e0e61a16dd9e43..3806fdc386ea5e1dbac066b92995020219bc4950 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/ExtensionFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/ExtensionFileComparator.html" @@ -1,3 +1,508 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a1f8eca10b16eff12815058eb70aad0980f3f98bc744a5f6b43951f3208a8502 -size 30709 + + + + + +ExtensionFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class ExtensionFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.ExtensionFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class ExtensionFileComparator
    +extends Object
    +implements Serializable
    +
    Compare the file name extensions for order + (see FilenameUtils.getExtension(String)). +

    + 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 IOCase) + and the reverse of those options. +

    + Example of a case-sensitive file extension sort using the + EXTENSION_COMPARATOR singleton instance: +

    +       List<File> list = ...
    +       ((AbstractFileComparator) ExtensionFileComparator.EXTENSION_COMPARATOR).sort(list);
    + 
    +

    + Example of a reverse case-insensitive file extension sort using the + EXTENSION_INSENSITIVE_REVERSE singleton instance: +

    +       File[] array = ...
    +       ((AbstractFileComparator) ExtensionFileComparator.EXTENSION_INSENSITIVE_REVERSE).sort(array);
    + 
    +

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: ExtensionFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        EXTENSION_COMPARATOR

        +
        public static final Comparator<File> EXTENSION_COMPARATOR
        +
        Case-sensitive extension comparator instance (see IOCase.SENSITIVE)
        +
      • +
      + + + +
        +
      • +

        EXTENSION_REVERSE

        +
        public static final Comparator<File> EXTENSION_REVERSE
        +
        Reverse case-sensitive extension comparator instance (see IOCase.SENSITIVE)
        +
      • +
      + + + +
        +
      • +

        EXTENSION_INSENSITIVE_COMPARATOR

        +
        public static final Comparator<File> EXTENSION_INSENSITIVE_COMPARATOR
        +
        Case-insensitive extension comparator instance (see IOCase.INSENSITIVE)
        +
      • +
      + + + +
        +
      • +

        EXTENSION_INSENSITIVE_REVERSE

        +
        public static final Comparator<File> EXTENSION_INSENSITIVE_REVERSE
        +
        Reverse case-insensitive extension comparator instance (see IOCase.INSENSITIVE)
        +
      • +
      + + + +
        +
      • +

        EXTENSION_SYSTEM_COMPARATOR

        +
        public static final Comparator<File> EXTENSION_SYSTEM_COMPARATOR
        +
        System sensitive extension comparator instance (see IOCase.SYSTEM)
        +
      • +
      + + + +
        +
      • +

        EXTENSION_SYSTEM_REVERSE

        +
        public static final Comparator<File> EXTENSION_SYSTEM_REVERSE
        +
        Reverse system sensitive path comparator instance (see IOCase.SYSTEM)
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ExtensionFileComparator

        +
        public ExtensionFileComparator()
        +
        Construct a case sensitive file extension comparator instance.
        +
      • +
      + + + +
        +
      • +

        ExtensionFileComparator

        +
        public ExtensionFileComparator(IOCase caseSensitivity)
        +
        Construct a file extension comparator instance with the specified case-sensitivity.
        +
        Parameters:
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the extensions of two files the specified case sensitivity.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        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.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        Returns:
        String representation of this file comparator
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/LastModifiedFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/LastModifiedFileComparator.html" index d30af9b695916c9b86e2b6a024285a0a1575bbb6..677a3f0b578eb37322bf54c034fe0b6ef5748858 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/LastModifiedFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/LastModifiedFileComparator.html" @@ -1,3 +1,425 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ee4ec6c524a890052843b7562d4c0d329461473d776b6221bcc2b300c1188876 -size 23381 + + + + + +LastModifiedFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class LastModifiedFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.LastModifiedFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class LastModifiedFileComparator
    +extends Object
    +implements Serializable
    +
    Compare the last modified date/time of two files for order + (see File.lastModified()). +

    + This comparator can be used to sort lists or arrays of files + by their last modified date/time. +

    + Example of sorting a list of files using the + LASTMODIFIED_COMPARATOR singleton instance: +

    +       List<File> list = ...
    +       ((AbstractFileComparator) LastModifiedFileComparator.LASTMODIFIED_COMPARATOR).sort(list);
    + 
    +

    + Example of doing a reverse sort of an array of files using the + LASTMODIFIED_REVERSE singleton instance: +

    +       File[] array = ...
    +       ((AbstractFileComparator) LastModifiedFileComparator.LASTMODIFIED_REVERSE).sort(array);
    + 
    +

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: LastModifiedFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        LASTMODIFIED_COMPARATOR

        +
        public static final Comparator<File> LASTMODIFIED_COMPARATOR
        +
        Last modified comparator instance
        +
      • +
      + + + +
        +
      • +

        LASTMODIFIED_REVERSE

        +
        public static final Comparator<File> LASTMODIFIED_REVERSE
        +
        Reverse last modified comparator instance
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        LastModifiedFileComparator

        +
        public LastModifiedFileComparator()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the last the last modified date/time of two files.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        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.
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        String representation of this file comparator
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/NameFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/NameFileComparator.html" index d8c4d828837c6394eb96fa2620563a91cf41fcf8..d2018552b7e0ec9223d0a7f2c6eb5811a6032c80 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/NameFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/NameFileComparator.html" @@ -1,3 +1,507 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4bc421ac810bbbc4941b12f882590704992de0eb66dcb6e94dc490dc179afde8 -size 30228 + + + + + +NameFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class NameFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.NameFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class NameFileComparator
    +extends Object
    +implements Serializable
    +
    Compare the names of two files for order (see File.getName()). +

    + 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 IOCase) + and the reverse of those options. +

    + Example of a case-sensitive file name sort using the + NAME_COMPARATOR singleton instance: +

    +       List<File> list = ...
    +       ((AbstractFileComparator) NameFileComparator.NAME_COMPARATOR).sort(list);
    + 
    +

    + Example of a reverse case-insensitive file name sort using the + NAME_INSENSITIVE_REVERSE singleton instance: +

    +       File[] array = ...
    +       ((AbstractFileComparator) NameFileComparator.NAME_INSENSITIVE_REVERSE).sort(array);
    + 
    +

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: NameFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NameFileComparator

        +
        public NameFileComparator()
        +
        Construct a case sensitive file name comparator instance.
        +
      • +
      + + + +
        +
      • +

        NameFileComparator

        +
        public NameFileComparator(IOCase caseSensitivity)
        +
        Construct a file name comparator instance with the specified case-sensitivity.
        +
        Parameters:
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the names of two files with the specified case sensitivity.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        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.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        Returns:
        String representation of this file comparator
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/PathFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/PathFileComparator.html" index 71da9e8c828d8c0b572fbaf9d2e5cd7468c7f680..e3464f71a3e1bd6d46cc2f3683120f4cc825ae21 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/PathFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/PathFileComparator.html" @@ -1,3 +1,507 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e6d2228e9a34ce5a60271a00577f75d256867840096b7940fc47bbb694448036 -size 30201 + + + + + +PathFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class PathFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.PathFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class PathFileComparator
    +extends Object
    +implements Serializable
    +
    Compare the path of two files for order (see File.getPath()). +

    + 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 IOCase) + and the reverse of those options. +

    + Example of a case-sensitive file path sort using the + PATH_COMPARATOR singleton instance: +

    +       List<File> list = ...
    +       ((AbstractFileComparator) PathFileComparator.PATH_COMPARATOR).sort(list);
    + 
    +

    + Example of a reverse case-insensitive file path sort using the + PATH_INSENSITIVE_REVERSE singleton instance: +

    +       File[] array = ...
    +       ((AbstractFileComparator) PathFileComparator.PATH_INSENSITIVE_REVERSE).sort(array);
    + 
    +

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: PathFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        PathFileComparator

        +
        public PathFileComparator()
        +
        Construct a case sensitive file path comparator instance.
        +
      • +
      + + + +
        +
      • +

        PathFileComparator

        +
        public PathFileComparator(IOCase caseSensitivity)
        +
        Construct a file path comparator instance with the specified case-sensitivity.
        +
        Parameters:
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the paths of two files the specified case sensitivity.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        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.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        Returns:
        String representation of this file comparator
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/SizeFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/SizeFileComparator.html" index 8bb9233c3395b39fc3efd37471e70b6cc9ee9f81..652c7cf3573b6bbd723d271aacfe96de1c05da2f 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/SizeFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/SizeFileComparator.html" @@ -1,3 +1,486 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:04da04f05bf28fbad526a05af6ab05c225bbe30c69cc06801216cad02b704016 -size 27226 + + + + + +SizeFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.comparator
+

Class SizeFileComparator

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.comparator.SizeFileComparator
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable, Comparator<File>
    +
    +
    +
    +
    public class SizeFileComparator
    +extends Object
    +implements Serializable
    +
    Compare the length/size of two files for order (see + File.length() and FileUtils.sizeOfDirectory(File)). +

    + This comparator can be used to sort lists or arrays of files + by their length/size. +

    + Example of sorting a list of files using the + SIZE_COMPARATOR singleton instance: +

    +       List<File> list = ...
    +       ((AbstractFileComparator) SizeFileComparator.SIZE_COMPARATOR).sort(list);
    + 
    +

    + Example of doing a reverse sort of an array of files using the + SIZE_REVERSE singleton instance: +

    +       File[] array = ...
    +       ((AbstractFileComparator) SizeFileComparator.SIZE_REVERSE).sort(array);
    + 
    +

    + N.B. Directories are treated as zero size unless + sumDirectoryContents is true.

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: SizeFileComparator.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        SIZE_COMPARATOR

        +
        public static final Comparator<File> SIZE_COMPARATOR
        +
        Size comparator instance - directories are treated as zero size
        +
      • +
      + + + +
        +
      • +

        SIZE_REVERSE

        +
        public static final Comparator<File> SIZE_REVERSE
        +
        Reverse size comparator instance - directories are treated as zero size
        +
      • +
      + + + + + + + + +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        SizeFileComparator

        +
        public SizeFileComparator()
        +
        Construct a file size comparator instance (directories treated as zero size).
        +
      • +
      + + + +
        +
      • +

        SizeFileComparator

        +
        public SizeFileComparator(boolean sumDirectoryContents)
        +
        Construct a file size comparator instance specifying whether the size of + the directory contents should be aggregated. +

        + If the sumDirectoryContents is true The size of + directories is calculated using FileUtils.sizeOfDirectory(File).

        +
        Parameters:
        sumDirectoryContents - true if the sum of the directoryies contents + should be calculated, otherwise false if directories should be treated + as size zero (see FileUtils.sizeOfDirectory(File)).
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        compare

        +
        public int compare(File file1,
        +          File file2)
        +
        Compare the length of two files.
        +
        +
        Specified by:
        +
        compare in interface Comparator<File>
        +
        Parameters:
        file1 - The first file to compare
        file2 - The second file to compare
        +
        Returns:
        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.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        String representation of this file comparator.
        +
        Returns:
        String representation of this file comparator
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public File[] sort(File... files)
        +
        Sort an array of files. +

        + This method uses Arrays.sort(Object[], Comparator) + and returns the original array.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted array
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        sort

        +
        public List<File> sort(List<File> files)
        +
        Sort a List of files. +

        + This method uses Collections.sort(List, Comparator) + and returns the original list.

        +
        Parameters:
        files - The files to sort, may be null
        +
        Returns:
        The sorted list
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/CompositeFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/CompositeFileComparator.html" index 873838d20253e630a4b65243f9f893218d374efb..c3222d5b2a1dc276fda21c19492fe8df83bef4f6 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/CompositeFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/CompositeFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7049920935ed704c3e0edfa3c5e3308767f45636d5eadd99fd35dd768f7f176d -size 4558 + + + + + +Uses of Class org.apache.commons.io.comparator.CompositeFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.CompositeFileComparator

+
+
No usage of org.apache.commons.io.comparator.CompositeFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DefaultFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DefaultFileComparator.html" index ec609155532b8b73e347e1ca7387c53611b1cbd4..85b67e1d7fd532a7c35416e5840bb365df322355 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DefaultFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DefaultFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:70ae45c32096bfccde199d3c9f98fb0e41a5dbb30da86af90b441c152156c99e -size 4536 + + + + + +Uses of Class org.apache.commons.io.comparator.DefaultFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.DefaultFileComparator

+
+
No usage of org.apache.commons.io.comparator.DefaultFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DirectoryFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DirectoryFileComparator.html" index e4f7c95bf0efd44cb36fdc16b2814ad41a542b07..86a37e3daa51359c743151456759aa14f0afe153 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DirectoryFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/DirectoryFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5627bf2f335f8d09930677eab648709ee4a5253ac1bfa0398eac9089ce71c0f1 -size 4558 + + + + + +Uses of Class org.apache.commons.io.comparator.DirectoryFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.DirectoryFileComparator

+
+
No usage of org.apache.commons.io.comparator.DirectoryFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/ExtensionFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/ExtensionFileComparator.html" index 5cd7a6531b00fb7dd0ea7b80f6eef02e826184cb..2964be626fa04aaf8e3ddef128dd6afb7481ee23 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/ExtensionFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/ExtensionFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:88c7f38c4f05be44c9488535b63f6de20a7af4d220304e14f01064d085800f64 -size 4558 + + + + + +Uses of Class org.apache.commons.io.comparator.ExtensionFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.ExtensionFileComparator

+
+
No usage of org.apache.commons.io.comparator.ExtensionFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/LastModifiedFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/LastModifiedFileComparator.html" index 805e3e2d30c98f94dbb2bc034f6e9a50ede5c909..47976654dd4887c66d60e7fae3b4181b766c7946 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/LastModifiedFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/LastModifiedFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5228d53f0ce806477af843f6bc0de543ae01798c6b8a9a43e67b92bb69d0f9a1 -size 4591 + + + + + +Uses of Class org.apache.commons.io.comparator.LastModifiedFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.LastModifiedFileComparator

+
+
No usage of org.apache.commons.io.comparator.LastModifiedFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/NameFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/NameFileComparator.html" index 8b8c67f7618be6ff4162397c3a290b54f86a8fdf..c56e28c7829be0cb573a073732abb22c670ed1a9 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/NameFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/NameFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0d1f5d1d73f9945045bb7683ea56646ede1def3eaaf3b5c743506c0d439dbb3e -size 4503 + + + + + +Uses of Class org.apache.commons.io.comparator.NameFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.NameFileComparator

+
+
No usage of org.apache.commons.io.comparator.NameFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/PathFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/PathFileComparator.html" index 231d81ea56d7bc614032d2bad5d93b0952157c52..8d6d0453b2c721f479eeacecb905efc93e8086a8 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/PathFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/PathFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c1b5bd8a0d88f47be802a4c39dd58efaebc0b57a604ef5c16a24d38234c02e9c -size 4503 + + + + + +Uses of Class org.apache.commons.io.comparator.PathFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.PathFileComparator

+
+
No usage of org.apache.commons.io.comparator.PathFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/SizeFileComparator.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/SizeFileComparator.html" index e9bd94735bcc02bc5888b89d2f438f42e24310fe..4acbc13e7651008705321899530dd2924159d44b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/SizeFileComparator.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/class-use/SizeFileComparator.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2122f1d754174c3afb7699209e569b036f7f495236c9ab166906f25009aa3f5f -size 4503 + + + + + +Uses of Class org.apache.commons.io.comparator.SizeFileComparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.comparator.SizeFileComparator

+
+
No usage of org.apache.commons.io.comparator.SizeFileComparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-frame.html" index a5484dfba3ca2fe33366f57c4bba899d2b06d5c1..48570e60cb5b01b66617c6e8ba0055b9a1239efd 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-frame.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-frame.html" @@ -1,3 +1,25 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:55946b0fd9980efd112966b80a15493c1b9f2b9bc773d826816c73cd972b1b09 -size 1808 + + + + + +org.apache.commons.io.comparator (Apache Commons IO 2.5 API) + + + +

org.apache.commons.io.comparator

+ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-summary.html" index a98439314fa97f8241c6502587b1e550e72452f0..0044608e8198c85df5e4f9ef5897f1ca67b3cc86 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-summary.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-summary.html" @@ -1,3 +1,355 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3be07959286fa0a1b7f7b6d115386da738a06392b047999ef251ed12b83ca8cf -size 18045 + + + + + +org.apache.commons.io.comparator (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Package org.apache.commons.io.comparator

+
+
This package provides various Comparator implementations +for Files.
+
+

See: Description

+
+
+ + + + +

Package org.apache.commons.io.comparator Description

+

This package provides various Comparator implementations +for Files. +

+

Sorting

+

+ All the compartors include convenience utility sort(File...) and + sort(List) methods. +

+

+ For example, to sort the files in a directory by name: +

+
+        File[] files = dir.listFiles();
+        NameFileComparator.NAME_COMPARATOR.sort(files);
+  
+

+ ...alternatively you can do this in one line: +

+

+

+        File[] files = NameFileComparator.NAME_COMPARATOR.sort(dir.listFiles());
+  
+

+ +

Composite Comparator

+

+ The CompositeFileComparator can be used + to compare (and sort lists or arrays of files) by combining a number other comparators. +

+

+ For example, to sort an array of files by type (i.e. directory or file) + and then by name: +

+

+

+        CompositeFileComparator comparator =
+                        new CompositeFileComparator(
+                                    DirectoryFileComparator.DIRECTORY_COMPARATOR,
+                                    NameFileComparator.NAME_COMPARATOR);
+        File[] files = dir.listFiles();
+        comparator.sort(files);
+  
+

+ +

Singleton Instances (thread-safe)

+

+ The Comparator implementations have some convenience + singleton(thread-safe) instances ready to use: +

+

+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-tree.html" index d4fefe0d13a247615481f09bf87a7125dda4308f..3eb671bb5f7002b0240f03a47cd6b5b933895ecd 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-tree.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-tree.html" @@ -1,3 +1,135 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:70d8b941a67e67df3808e714fea8f8725b39a51ce595b58ae449195e9ec77a17 -size 7926 + + + + + +org.apache.commons.io.comparator Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package org.apache.commons.io.comparator

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-use.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-use.html" index 442eed46f0fd42e8a932fbea63b74a4164981cca..8058348414ed36d284ea1808031c49480b073a6c 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-use.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/comparator/package-use.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:82a843fea84504f8f0b5c2d78f3573b3ee1ecee225a51a1857d043867def4599 -size 4038 + + + + + +Uses of Package org.apache.commons.io.comparator (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Package
org.apache.commons.io.comparator

+
+
No usage of org.apache.commons.io.comparator
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AbstractFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AbstractFileFilter.html" index c54501ea53226e81598b396ebe82b93c5f45311e..b53c303dd4a214b14eaba3b9f93d96fa990eb7a6 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AbstractFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AbstractFileFilter.html" @@ -1,3 +1,329 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b3a7da05c1c6b89360d60789a98be7674d1c60b014b9fa980a9215ee3c7be483 -size 19268 + + + + + +AbstractFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class AbstractFileFilter

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.filefilter.AbstractFileFilter
    • +
    +
  • +
+
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        AbstractFileFilter

        +
        public AbstractFileFilter()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the File should be accepted by this filter.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File dir,
        +             String name)
        +
        Checks to see if the File should be accepted by this filter.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Parameters:
        dir - the directory File to check
        name - the filename within the directory to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AgeFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AgeFileFilter.html" index 9730f6d11e02f9ebceb90b0b7caaed8349df8d19..1ba320044cb51a5622279298a3f891e974282900 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AgeFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AgeFileFilter.html" @@ -1,3 +1,447 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6b6932f1dec889ea0f5a38ec017414e3df6431ca51bbbae444fcf24deac8ce7c -size 23484 + + + + + +AgeFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class AgeFileFilter

+
+
+ +
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      AgeFileFilter(Date cutoffDate) +
      Constructs a new age file filter for files older than (at or before) + a certain cutoff date.
      +
      AgeFileFilter(Date cutoffDate, + boolean acceptOlder) +
      Constructs a new age file filter for files on any one side + of a certain cutoff date.
      +
      AgeFileFilter(File cutoffReference) +
      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).
      +
      AgeFileFilter(File cutoffReference, + boolean acceptOlder) +
      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).
      +
      AgeFileFilter(long cutoff) +
      Constructs a new age file filter for files equal to or older than + a certain cutoff
      +
      AgeFileFilter(long cutoff, + boolean acceptOlder) +
      Constructs a new age file filter for files on any one side + of a certain cutoff.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        AgeFileFilter

        +
        public AgeFileFilter(long cutoff)
        +
        Constructs a new age file filter for files equal to or older than + a certain cutoff
        +
        Parameters:
        cutoff - the threshold age of the files
        +
      • +
      + + + +
        +
      • +

        AgeFileFilter

        +
        public AgeFileFilter(long cutoff,
        +             boolean acceptOlder)
        +
        Constructs a new age file filter for files on any one side + of a certain cutoff.
        +
        Parameters:
        cutoff - the threshold age of the files
        acceptOlder - if true, older files (at or before the cutoff) + are accepted, else newer ones (after the cutoff).
        +
      • +
      + + + +
        +
      • +

        AgeFileFilter

        +
        public AgeFileFilter(Date cutoffDate)
        +
        Constructs a new age file filter for files older than (at or before) + a certain cutoff date.
        +
        Parameters:
        cutoffDate - the threshold age of the files
        +
      • +
      + + + +
        +
      • +

        AgeFileFilter

        +
        public AgeFileFilter(Date cutoffDate,
        +             boolean acceptOlder)
        +
        Constructs a new age file filter for files on any one side + of a certain cutoff date.
        +
        Parameters:
        cutoffDate - the threshold age of the files
        acceptOlder - if true, older files (at or before the cutoff) + are accepted, else newer ones (after the cutoff).
        +
      • +
      + + + +
        +
      • +

        AgeFileFilter

        +
        public AgeFileFilter(File cutoffReference)
        +
        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).
        +
        Parameters:
        cutoffReference - the file whose last modification + time is usesd as the threshold age of the files
        +
      • +
      + + + +
        +
      • +

        AgeFileFilter

        +
        public AgeFileFilter(File cutoffReference,
        +             boolean acceptOlder)
        +
        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).
        +
        Parameters:
        cutoffReference - the file whose last modification + time is usesd as the threshold age of the files
        acceptOlder - if true, older files (at or before the cutoff) + are accepted, else newer ones (after the cutoff).
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the last modification of the file matches cutoff + favorably. +

        + If last modification time equals cutoff and newer files are required, + file IS NOT selected. + If last modification time equals cutoff and older files are required, + file IS selected.

        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the filename matches
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AndFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AndFileFilter.html" index 53bb494e16d208228d15eebfbea2fd80eed9150a..e6a7e13176650dc844324c78e5f59b2b8d715df2 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AndFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/AndFileFilter.html" @@ -1,3 +1,466 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:90ca66d60518879f9663532768c69af0780aa832233eaa7a670b4e762930e938 -size 28802 + + + + + +AndFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class AndFileFilter

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        AndFileFilter

        +
        public AndFileFilter()
        +
        Constructs a new instance of AndFileFilter.
        +
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        AndFileFilter

        +
        public AndFileFilter(List<IOFileFilter> fileFilters)
        +
        Constructs a new instance of AndFileFilter + with the specified list of filters.
        +
        Parameters:
        fileFilters - a List of IOFileFilter instances, copied, null ignored
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        AndFileFilter

        +
        public AndFileFilter(IOFileFilter filter1,
        +             IOFileFilter filter2)
        +
        Constructs a new file filter that ANDs the result of two other filters.
        +
        Parameters:
        filter1 - the first filter, must not be null
        filter2 - the second filter, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if either filter is null
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        addFileFilter

        +
        public void addFileFilter(IOFileFilter ioFileFilter)
        +
        Adds the specified file filter to the list of file filters at the end of + the list.
        +
        +
        Specified by:
        +
        addFileFilter in interface ConditionalFileFilter
        +
        Parameters:
        ioFileFilter - the filter to be added
        +
      • +
      + + + + + + + +
        +
      • +

        removeFileFilter

        +
        public boolean removeFileFilter(IOFileFilter ioFileFilter)
        +
        Removes the specified file filter.
        +
        +
        Specified by:
        +
        removeFileFilter in interface ConditionalFileFilter
        +
        Parameters:
        ioFileFilter - filter to be removed
        +
        Returns:
        true if the filter was found in the list, + false otherwise
        +
      • +
      + + + +
        +
      • +

        setFileFilters

        +
        public void setFileFilters(List<IOFileFilter> fileFilters)
        +
        Sets the list of file filters, replacing any previously configured + file filters on this filter.
        +
        +
        Specified by:
        +
        setFileFilters in interface ConditionalFileFilter
        +
        Parameters:
        fileFilters - the list of filters
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the File should be accepted by this filter.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file,
        +             String name)
        +
        Checks to see if the File should be accepted by this filter.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the directory File to check
        name - the filename within the directory to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanReadFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanReadFileFilter.html" index da36b5ef59b92fe62dcf91e1a2242feadbcbecf6..fe7b0065bea3ec5ace7332dbc2edcdf654ac8fb0 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanReadFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanReadFileFilter.html" @@ -1,3 +1,403 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:61e2d6075b14a655efd1ec4aeb44df89c383ab799c9eb6eaa770c4a12d167380 -size 18794 + + + + + +CanReadFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class CanReadFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class CanReadFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    This filter accepts Files that can be read. +

    + Example, showing how to print out a list of the + current directory's readable files: + +

    + File dir = new File(".");
    + String[] files = dir.list( CanReadFileFilter.CAN_READ );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    + +

    + Example, showing how to print out a list of the + current directory's un-readable files: + +

    + File dir = new File(".");
    + String[] files = dir.list( CanReadFileFilter.CANNOT_READ );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    + +

    + Example, showing how to print out a list of the + current directory's read-only files: + +

    + File dir = new File(".");
    + String[] files = dir.list( CanReadFileFilter.READ_ONLY );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: CanReadFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        CAN_READ

        +
        public static final IOFileFilter CAN_READ
        +
        Singleton instance of readable filter
        +
      • +
      + + + +
        +
      • +

        CANNOT_READ

        +
        public static final IOFileFilter CANNOT_READ
        +
        Singleton instance of not readable filter
        +
      • +
      + + + +
        +
      • +

        READ_ONLY

        +
        public static final IOFileFilter READ_ONLY
        +
        Singleton instance of read-only filter
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CanReadFileFilter

        +
        protected CanReadFileFilter()
        +
        Restrictive consructor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the file can be read.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check.
        +
        Returns:
        true if the file can be + read, otherwise false.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanWriteFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanWriteFileFilter.html" index 4acad91f672bc63459b8207ab64a70f9f49b9bd8..250097d8b77108dc55ff04bf7e6be3d637bea4e5 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanWriteFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/CanWriteFileFilter.html" @@ -1,3 +1,379 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:295a9c9b2025208f5c18143f8de7ef2297b5a85daabadbb2a4518829f35f6244 -size 17848 + + + + + +CanWriteFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class CanWriteFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class CanWriteFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    This filter accepts Files that can be written to. +

    + Example, showing how to print out a list of the + current directory's writable files: + +

    + File dir = new File(".");
    + String[] files = dir.list( CanWriteFileFilter.CAN_WRITE );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    + +

    + Example, showing how to print out a list of the + current directory's un-writable files: + +

    + File dir = new File(".");
    + String[] files = dir.list( CanWriteFileFilter.CANNOT_WRITE );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    + +

    + N.B. For read-only files, use + CanReadFileFilter.READ_ONLY.

    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: CanWriteFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        CAN_WRITE

        +
        public static final IOFileFilter CAN_WRITE
        +
        Singleton instance of writable filter
        +
      • +
      + + + +
        +
      • +

        CANNOT_WRITE

        +
        public static final IOFileFilter CANNOT_WRITE
        +
        Singleton instance of not writable filter
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CanWriteFileFilter

        +
        protected CanWriteFileFilter()
        +
        Restrictive consructor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the file can be written to.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the file can be + written to, otherwise false.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/ConditionalFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/ConditionalFileFilter.html" index b9ca27b6e8849aab0155266df51a3ffef6f0af60..d919c0f3ce5430602a209cdd647813d0fcbc548f 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/ConditionalFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/ConditionalFileFilter.html" @@ -1,3 +1,280 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:303e732c6acc609269863e8111131326688399d8773d56581acede15dbb31a05 -size 12533 + + + + + +ConditionalFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Interface ConditionalFileFilter

+
+
+
+
    +
  • +
    +
    All Known Implementing Classes:
    +
    AndFileFilter, OrFileFilter
    +
    +
    +
    +
    public interface ConditionalFileFilter
    +
    Defines operations for conditional file filters.
    +
    Since:
    +
    1.1
    +
    Version:
    +
    $Id: ConditionalFileFilter.java 1307462 2012-03-30 15:13:11Z ggregory $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidaddFileFilter(IOFileFilter ioFileFilter) +
      Adds the specified file filter to the list of file filters at the end of + the list.
      +
      List<IOFileFilter>getFileFilters() +
      Returns this conditional file filter's list of file filters.
      +
      booleanremoveFileFilter(IOFileFilter ioFileFilter) +
      Removes the specified file filter.
      +
      voidsetFileFilters(List<IOFileFilter> fileFilters) +
      Sets the list of file filters, replacing any previously configured + file filters on this filter.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        addFileFilter

        +
        void addFileFilter(IOFileFilter ioFileFilter)
        +
        Adds the specified file filter to the list of file filters at the end of + the list.
        +
        Parameters:
        ioFileFilter - the filter to be added
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        getFileFilters

        +
        List<IOFileFilter> getFileFilters()
        +
        Returns this conditional file filter's list of file filters.
        +
        Returns:
        the file filter list
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        removeFileFilter

        +
        boolean removeFileFilter(IOFileFilter ioFileFilter)
        +
        Removes the specified file filter.
        +
        Parameters:
        ioFileFilter - filter to be removed
        +
        Returns:
        true if the filter was found in the list, + false otherwise
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        setFileFilters

        +
        void setFileFilters(List<IOFileFilter> fileFilters)
        +
        Sets the list of file filters, replacing any previously configured + file filters on this filter.
        +
        Parameters:
        fileFilters - the list of filters
        Since:
        +
        1.1
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DelegateFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DelegateFileFilter.html" index 8f5f66d1571f0b71287e213a597bc2c0399e29db..ed9439420368deffa56876b3b42e52f2f9ea0de8 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DelegateFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DelegateFileFilter.html" @@ -1,3 +1,353 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0d19966be29b976031dbe14ff58afddb15cce1f11835cdb789f3c0e52cbf664d -size 19641 + + + + + +DelegateFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class DelegateFileFilter

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DelegateFileFilter

        +
        public DelegateFileFilter(FilenameFilter filter)
        +
        Constructs a delegate file filter around an existing FilenameFilter.
        +
        Parameters:
        filter - the filter to decorate
        +
      • +
      + + + +
        +
      • +

        DelegateFileFilter

        +
        public DelegateFileFilter(FileFilter filter)
        +
        Constructs a delegate file filter around an existing FileFilter.
        +
        Parameters:
        filter - the filter to decorate
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DirectoryFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DirectoryFileFilter.html" index 9d6ff631fa97c11505235426f24e467555e39136..ddcec4b91f4953c3c326a1970718cb46e8d4a091 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DirectoryFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/DirectoryFileFilter.html" @@ -1,3 +1,368 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c539c4e96ece5de9f96da9891536abfdb93106a98f8323248b68653d5f0f468b -size 17760 + + + + + +DirectoryFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class DirectoryFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class DirectoryFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    This filter accepts Files that are directories. +

    + For example, here is how to print out a list of the + current directory's subdirectories: + +

    + File dir = new File(".");
    + String[] files = dir.list( DirectoryFileFilter.INSTANCE );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.0
    +
    Version:
    +
    $Id: DirectoryFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    FileFilterUtils.directoryFileFilter(), +Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        DIRECTORY

        +
        public static final IOFileFilter DIRECTORY
        +
        Singleton instance of directory filter.
        +
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        INSTANCE

        +
        public static final IOFileFilter INSTANCE
        +
        Singleton instance of directory filter. + Please use the identical DirectoryFileFilter.DIRECTORY constant. + The new name is more JDK 1.5 friendly as it doesn't clash with other + values when using static imports.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DirectoryFileFilter

        +
        protected DirectoryFileFilter()
        +
        Restrictive consructor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the file is a directory.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the file is a directory
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/EmptyFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/EmptyFileFilter.html" index cedd9148d0ccace8af2887e62dd26dab06ac2973..21cd2d9538d7e959152e5e0eadc42b42247e1560 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/EmptyFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/EmptyFileFilter.html" @@ -1,3 +1,378 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c33ed522a68cf6c6ba0f979362e6d0c6668a1991f8cd86ac8629722ceee240ec -size 17702 + + + + + +EmptyFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class EmptyFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class EmptyFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    This filter accepts files or directories that are empty. +

    + If the File is a directory it checks that + it contains no files. +

    + Example, showing how to print out a list of the + current directory's empty files/directories: + +

    + File dir = new File(".");
    + String[] files = dir.list( EmptyFileFilter.EMPTY );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    + +

    + Example, showing how to print out a list of the + current directory's non-empty files/directories: + +

    + File dir = new File(".");
    + String[] files = dir.list( EmptyFileFilter.NOT_EMPTY );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: EmptyFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        EMPTY

        +
        public static final IOFileFilter EMPTY
        +
        Singleton instance of empty filter
        +
      • +
      + + + +
        +
      • +

        NOT_EMPTY

        +
        public static final IOFileFilter NOT_EMPTY
        +
        Singleton instance of not-empty filter
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        EmptyFileFilter

        +
        protected EmptyFileFilter()
        +
        Restrictive consructor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the file is empty.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the file or directory to check
        +
        Returns:
        true if the file or directory + is empty, otherwise false.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FalseFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FalseFileFilter.html" index ca64415351c7d3fcf3d5da1131d3ce3a9a982abf..dc8dbb0da82720f164cea5b12abf6e87f0baacdc 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FalseFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FalseFileFilter.html" @@ -1,3 +1,368 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:50454b2d560fe9c2687299ef845426d14d385423f549ef8126672c8e95f6b05b -size 18449 + + + + + +FalseFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class FalseFileFilter

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        FALSE

        +
        public static final IOFileFilter FALSE
        +
        Singleton instance of false filter.
        +
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        INSTANCE

        +
        public static final IOFileFilter INSTANCE
        +
        Singleton instance of false filter. + Please use the identical FalseFileFilter.FALSE constant. + The new name is more JDK 1.5 friendly as it doesn't clash with other + values when using static imports.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FalseFileFilter

        +
        protected FalseFileFilter()
        +
        Restrictive consructor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Returns false.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Parameters:
        file - the file to check (ignored)
        +
        Returns:
        false
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File dir,
        +             String name)
        +
        Returns false.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Parameters:
        dir - the directory to check (ignored)
        name - the filename (ignored)
        +
        Returns:
        false
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFileFilter.html" index 8fc83ab2bac86546a6e06a0c98598208b4ee6098..71b691e9163fa6d2491d4d05a59fda59d004841f 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFileFilter.html" @@ -1,3 +1,347 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fd426f42966508db77a52a933c59178bb565f63501333c69c0dddfa29eb2b8e2 -size 16534 + + + + + +FileFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class FileFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class FileFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    This filter accepts Files that are files (not directories). +

    + For example, here is how to print out a list of the real files + within the current directory: + +

    + File dir = new File(".");
    + String[] files = dir.list( FileFileFilter.FILE );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: FileFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    FileFilterUtils.fileFileFilter(), +Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        FILE

        +
        public static final IOFileFilter FILE
        +
        Singleton instance of file filter
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileFileFilter

        +
        protected FileFileFilter()
        +
        Restrictive consructor.
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFilterUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFilterUtils.html" index 2697ef4468c0f3eafd588cc88514ab1f31c3ecac..d3d65760d0dd6c812b82e7a18ba924d19f74ef0c 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFilterUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/FileFilterUtils.html" @@ -1,3 +1,1259 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0bbd59155b73a92820de8a23dabb5e3a9acdecbfc2437da5217c41f0f8848808 -size 98048 + + + + + +FileFilterUtils (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class FileFilterUtils

+
+
+ +
+
    +
  • +
    +
    +
    public class FileFilterUtils
    +extends Object
    +
    Useful utilities for working with file filters. It provides access to all + file filter implementations in this package so you don't have to import + every class you use.
    +
    Since:
    +
    1.0
    +
    Version:
    +
    $Id: FileFilterUtils.java 1471767 2013-04-24 23:24:19Z sebb $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileFilterUtils

        +
        public FileFilterUtils()
        +
        FileFilterUtils is not normally instantiated.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        filter

        +
        public static File[] filter(IOFileFilter filter,
        +            File... files)
        +

        + Applies an IOFileFilter to the provided File + objects. The resulting array is a subset of the original file list that + matches the provided filter. +

        + +

        + The Set returned by this method is not guaranteed to be thread safe. +

        + +
        + Set<File> allFiles = ...
        + Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
        +     FileFilterUtils.suffixFileFilter(".java"));
        + 
        +
        Parameters:
        filter - the filter to apply to the set of files.
        files - the array of files to apply the filter to.
        +
        Returns:
        a subset of files that is accepted by the + file filter.
        +
        Throws:
        +
        IllegalArgumentException - if the filter is null + or files contains a null value.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        filter

        +
        public static File[] filter(IOFileFilter filter,
        +            Iterable<File> files)
        +

        + Applies an IOFileFilter to the provided File + objects. The resulting array is a subset of the original file list that + matches the provided filter. +

        + +

        + The Set returned by this method is not guaranteed to be thread safe. +

        + +
        + Set<File> allFiles = ...
        + Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
        +     FileFilterUtils.suffixFileFilter(".java"));
        + 
        +
        Parameters:
        filter - the filter to apply to the set of files.
        files - the array of files to apply the filter to.
        +
        Returns:
        a subset of files that is accepted by the + file filter.
        +
        Throws:
        +
        IllegalArgumentException - if the filter is null + or files contains a null value.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        filterList

        +
        public static List<File> filterList(IOFileFilter filter,
        +                    Iterable<File> files)
        +

        + Applies an IOFileFilter to the provided File + objects. The resulting list is a subset of the original files that + matches the provided filter. +

        + +

        + The List returned by this method is not guaranteed to be thread safe. +

        + +
        + List<File> filesAndDirectories = ...
        + List<File> directories = FileFilterUtils.filterList(filesAndDirectories,
        +     FileFilterUtils.directoryFileFilter());
        + 
        +
        Parameters:
        filter - the filter to apply to each files in the list.
        files - the collection of files to apply the filter to.
        +
        Returns:
        a subset of files that is accepted by the + file filter.
        +
        Throws:
        +
        IllegalArgumentException - if the filter is null + or files contains a null value.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        filterList

        +
        public static List<File> filterList(IOFileFilter filter,
        +                    File... files)
        +

        + Applies an IOFileFilter to the provided File + objects. The resulting list is a subset of the original files that + matches the provided filter. +

        + +

        + The List returned by this method is not guaranteed to be thread safe. +

        + +
        + List<File> filesAndDirectories = ...
        + List<File> directories = FileFilterUtils.filterList(filesAndDirectories,
        +     FileFilterUtils.directoryFileFilter());
        + 
        +
        Parameters:
        filter - the filter to apply to each files in the list.
        files - the collection of files to apply the filter to.
        +
        Returns:
        a subset of files that is accepted by the + file filter.
        +
        Throws:
        +
        IllegalArgumentException - if the filter is null + or files contains a null value.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        filterSet

        +
        public static Set<File> filterSet(IOFileFilter filter,
        +                  File... files)
        +

        + Applies an IOFileFilter to the provided File + objects. The resulting set is a subset of the original file list that + matches the provided filter. +

        + +

        + The Set returned by this method is not guaranteed to be thread safe. +

        + +
        + Set<File> allFiles = ...
        + Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
        +     FileFilterUtils.suffixFileFilter(".java"));
        + 
        +
        Parameters:
        filter - the filter to apply to the set of files.
        files - the collection of files to apply the filter to.
        +
        Returns:
        a subset of files that is accepted by the + file filter.
        +
        Throws:
        +
        IllegalArgumentException - if the filter is null + or files contains a null value.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        filterSet

        +
        public static Set<File> filterSet(IOFileFilter filter,
        +                  Iterable<File> files)
        +

        + Applies an IOFileFilter to the provided File + objects. The resulting set is a subset of the original file list that + matches the provided filter. +

        + +

        + The Set returned by this method is not guaranteed to be thread safe. +

        + +
        + Set<File> allFiles = ...
        + Set<File> javaFiles = FileFilterUtils.filterSet(allFiles,
        +     FileFilterUtils.suffixFileFilter(".java"));
        + 
        +
        Parameters:
        filter - the filter to apply to the set of files.
        files - the collection of files to apply the filter to.
        +
        Returns:
        a subset of files that is accepted by the + file filter.
        +
        Throws:
        +
        IllegalArgumentException - if the filter is null + or files contains a null value.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        prefixFileFilter

        +
        public static IOFileFilter prefixFileFilter(String prefix)
        +
        Returns a filter that returns true if the filename starts with the specified text.
        +
        Parameters:
        prefix - the filename prefix
        +
        Returns:
        a prefix checking filter
        See Also:
        PrefixFileFilter
        +
      • +
      + + + +
        +
      • +

        prefixFileFilter

        +
        public static IOFileFilter prefixFileFilter(String prefix,
        +                            IOCase caseSensitivity)
        +
        Returns a filter that returns true if the filename starts with the specified text.
        +
        Parameters:
        prefix - the filename prefix
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Returns:
        a prefix checking filter
        Since:
        +
        2.0
        +
        See Also:
        PrefixFileFilter
        +
      • +
      + + + +
        +
      • +

        suffixFileFilter

        +
        public static IOFileFilter suffixFileFilter(String suffix)
        +
        Returns a filter that returns true if the filename ends with the specified text.
        +
        Parameters:
        suffix - the filename suffix
        +
        Returns:
        a suffix checking filter
        See Also:
        SuffixFileFilter
        +
      • +
      + + + +
        +
      • +

        suffixFileFilter

        +
        public static IOFileFilter suffixFileFilter(String suffix,
        +                            IOCase caseSensitivity)
        +
        Returns a filter that returns true if the filename ends with the specified text.
        +
        Parameters:
        suffix - the filename suffix
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Returns:
        a suffix checking filter
        Since:
        +
        2.0
        +
        See Also:
        SuffixFileFilter
        +
      • +
      + + + +
        +
      • +

        nameFileFilter

        +
        public static IOFileFilter nameFileFilter(String name)
        +
        Returns a filter that returns true if the filename matches the specified text.
        +
        Parameters:
        name - the filename
        +
        Returns:
        a name checking filter
        See Also:
        NameFileFilter
        +
      • +
      + + + +
        +
      • +

        nameFileFilter

        +
        public static IOFileFilter nameFileFilter(String name,
        +                          IOCase caseSensitivity)
        +
        Returns a filter that returns true if the filename matches the specified text.
        +
        Parameters:
        name - the filename
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Returns:
        a name checking filter
        Since:
        +
        2.0
        +
        See Also:
        NameFileFilter
        +
      • +
      + + + +
        +
      • +

        directoryFileFilter

        +
        public static IOFileFilter directoryFileFilter()
        +
        Returns a filter that checks if the file is a directory.
        +
        Returns:
        file filter that accepts only directories and not files
        See Also:
        DirectoryFileFilter.DIRECTORY
        +
      • +
      + + + +
        +
      • +

        fileFileFilter

        +
        public static IOFileFilter fileFileFilter()
        +
        Returns a filter that checks if the file is a file (and not a directory).
        +
        Returns:
        file filter that accepts only files and not directories
        See Also:
        FileFileFilter.FILE
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        and

        +
        public static IOFileFilter and(IOFileFilter... filters)
        +
        Returns a filter that ANDs the specified filters.
        +
        Parameters:
        filters - the IOFileFilters that will be ANDed together.
        +
        Returns:
        a filter that ANDs the specified filters
        +
        Throws:
        +
        IllegalArgumentException - if the filters are null or contain a + null value.
        Since:
        +
        2.0
        +
        See Also:
        AndFileFilter
        +
      • +
      + + + +
        +
      • +

        or

        +
        public static IOFileFilter or(IOFileFilter... filters)
        +
        Returns a filter that ORs the specified filters.
        +
        Parameters:
        filters - the IOFileFilters that will be ORed together.
        +
        Returns:
        a filter that ORs the specified filters
        +
        Throws:
        +
        IllegalArgumentException - if the filters are null or contain a + null value.
        Since:
        +
        2.0
        +
        See Also:
        OrFileFilter
        +
      • +
      + + + +
        +
      • +

        toList

        +
        public static List<IOFileFilter> toList(IOFileFilter... filters)
        +
        Create a List of file filters.
        +
        Parameters:
        filters - The file filters
        +
        Returns:
        The list of file filters
        +
        Throws:
        +
        IllegalArgumentException - if the filters are null or contain a + null value.
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        notFileFilter

        +
        public static IOFileFilter notFileFilter(IOFileFilter filter)
        +
        Returns a filter that NOTs the specified filter.
        +
        Parameters:
        filter - the filter to invert
        +
        Returns:
        a filter that NOTs the specified filter
        See Also:
        NotFileFilter
        +
      • +
      + + + +
        +
      • +

        trueFileFilter

        +
        public static IOFileFilter trueFileFilter()
        +
        Returns a filter that always returns true.
        +
        Returns:
        a true filter
        See Also:
        TrueFileFilter.TRUE
        +
      • +
      + + + +
        +
      • +

        falseFileFilter

        +
        public static IOFileFilter falseFileFilter()
        +
        Returns a filter that always returns false.
        +
        Returns:
        a false filter
        See Also:
        FalseFileFilter.FALSE
        +
      • +
      + + + +
        +
      • +

        asFileFilter

        +
        public static IOFileFilter asFileFilter(FileFilter filter)
        +
        Returns an IOFileFilter that wraps the + FileFilter instance.
        +
        Parameters:
        filter - the filter to be wrapped
        +
        Returns:
        a new filter that implements IOFileFilter
        See Also:
        DelegateFileFilter
        +
      • +
      + + + +
        +
      • +

        asFileFilter

        +
        public static IOFileFilter asFileFilter(FilenameFilter filter)
        +
        Returns an IOFileFilter that wraps the + FilenameFilter instance.
        +
        Parameters:
        filter - the filter to be wrapped
        +
        Returns:
        a new filter that implements IOFileFilter
        See Also:
        DelegateFileFilter
        +
      • +
      + + + +
        +
      • +

        ageFileFilter

        +
        public static IOFileFilter ageFileFilter(long cutoff)
        +
        Returns a filter that returns true if the file was last modified after + the specified cutoff time.
        +
        Parameters:
        cutoff - the time threshold
        +
        Returns:
        an appropriately configured age file filter
        Since:
        +
        1.2
        +
        See Also:
        AgeFileFilter
        +
      • +
      + + + +
        +
      • +

        ageFileFilter

        +
        public static IOFileFilter ageFileFilter(long cutoff,
        +                         boolean acceptOlder)
        +
        Returns a filter that filters files based on a cutoff time.
        +
        Parameters:
        cutoff - the time threshold
        acceptOlder - if true, older files get accepted, if false, newer
        +
        Returns:
        an appropriately configured age file filter
        Since:
        +
        1.2
        +
        See Also:
        AgeFileFilter
        +
      • +
      + + + +
        +
      • +

        ageFileFilter

        +
        public static IOFileFilter ageFileFilter(Date cutoffDate)
        +
        Returns a filter that returns true if the file was last modified after + the specified cutoff date.
        +
        Parameters:
        cutoffDate - the time threshold
        +
        Returns:
        an appropriately configured age file filter
        Since:
        +
        1.2
        +
        See Also:
        AgeFileFilter
        +
      • +
      + + + +
        +
      • +

        ageFileFilter

        +
        public static IOFileFilter ageFileFilter(Date cutoffDate,
        +                         boolean acceptOlder)
        +
        Returns a filter that filters files based on a cutoff date.
        +
        Parameters:
        cutoffDate - the time threshold
        acceptOlder - if true, older files get accepted, if false, newer
        +
        Returns:
        an appropriately configured age file filter
        Since:
        +
        1.2
        +
        See Also:
        AgeFileFilter
        +
      • +
      + + + +
        +
      • +

        ageFileFilter

        +
        public static IOFileFilter ageFileFilter(File cutoffReference)
        +
        Returns a filter that returns true if the file was last modified after + the specified reference file.
        +
        Parameters:
        cutoffReference - the file whose last modification + time is usesd as the threshold age of the files
        +
        Returns:
        an appropriately configured age file filter
        Since:
        +
        1.2
        +
        See Also:
        AgeFileFilter
        +
      • +
      + + + +
        +
      • +

        ageFileFilter

        +
        public static IOFileFilter ageFileFilter(File cutoffReference,
        +                         boolean acceptOlder)
        +
        Returns a filter that filters files based on a cutoff reference file.
        +
        Parameters:
        cutoffReference - the file whose last modification + time is usesd as the threshold age of the files
        acceptOlder - if true, older files get accepted, if false, newer
        +
        Returns:
        an appropriately configured age file filter
        Since:
        +
        1.2
        +
        See Also:
        AgeFileFilter
        +
      • +
      + + + +
        +
      • +

        sizeFileFilter

        +
        public static IOFileFilter sizeFileFilter(long threshold)
        +
        Returns a filter that returns true if the file is bigger than a certain size.
        +
        Parameters:
        threshold - the file size threshold
        +
        Returns:
        an appropriately configured SizeFileFilter
        Since:
        +
        1.2
        +
        See Also:
        SizeFileFilter
        +
      • +
      + + + +
        +
      • +

        sizeFileFilter

        +
        public static IOFileFilter sizeFileFilter(long threshold,
        +                          boolean acceptLarger)
        +
        Returns a filter that filters based on file size.
        +
        Parameters:
        threshold - the file size threshold
        acceptLarger - if true, larger files get accepted, if false, smaller
        +
        Returns:
        an appropriately configured SizeFileFilter
        Since:
        +
        1.2
        +
        See Also:
        SizeFileFilter
        +
      • +
      + + + +
        +
      • +

        sizeRangeFileFilter

        +
        public static IOFileFilter sizeRangeFileFilter(long minSizeInclusive,
        +                               long maxSizeInclusive)
        +
        Returns a filter that accepts files whose size is >= minimum size + and <= maximum size.
        +
        Parameters:
        minSizeInclusive - the minimum file size (inclusive)
        maxSizeInclusive - the maximum file size (inclusive)
        +
        Returns:
        an appropriately configured IOFileFilter
        Since:
        +
        1.3
        +
        See Also:
        SizeFileFilter
        +
      • +
      + + + +
        +
      • +

        magicNumberFileFilter

        +
        public static IOFileFilter magicNumberFileFilter(String magicNumber)
        +
        Returns a filter that accepts files that begin with the provided magic + number.
        +
        Parameters:
        magicNumber - the magic number (byte sequence) to match at the + beginning of each file.
        +
        Returns:
        an IOFileFilter that accepts files beginning with the provided + magic number.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null or the empty String.
        Since:
        +
        2.0
        +
        See Also:
        MagicNumberFileFilter
        +
      • +
      + + + +
        +
      • +

        magicNumberFileFilter

        +
        public static IOFileFilter magicNumberFileFilter(String magicNumber,
        +                                 long offset)
        +
        Returns a filter that accepts files that contains the provided magic + number at a specified offset within the file.
        +
        Parameters:
        magicNumber - the magic number (byte sequence) to match at the + provided offset in each file.
        offset - the offset within the files to look for the magic number.
        +
        Returns:
        an IOFileFilter that accepts files containing the magic number + at the specified offset.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null or the empty String, or if offset is a + negative number.
        Since:
        +
        2.0
        +
        See Also:
        MagicNumberFileFilter
        +
      • +
      + + + +
        +
      • +

        magicNumberFileFilter

        +
        public static IOFileFilter magicNumberFileFilter(byte[] magicNumber)
        +
        Returns a filter that accepts files that begin with the provided magic + number.
        +
        Parameters:
        magicNumber - the magic number (byte sequence) to match at the + beginning of each file.
        +
        Returns:
        an IOFileFilter that accepts files beginning with the provided + magic number.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null or is of length zero.
        Since:
        +
        2.0
        +
        See Also:
        MagicNumberFileFilter
        +
      • +
      + + + +
        +
      • +

        magicNumberFileFilter

        +
        public static IOFileFilter magicNumberFileFilter(byte[] magicNumber,
        +                                 long offset)
        +
        Returns a filter that accepts files that contains the provided magic + number at a specified offset within the file.
        +
        Parameters:
        magicNumber - the magic number (byte sequence) to match at the + provided offset in each file.
        offset - the offset within the files to look for the magic number.
        +
        Returns:
        an IOFileFilter that accepts files containing the magic number + at the specified offset.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null, or contains no bytes, or offset + is a negative number.
        Since:
        +
        2.0
        +
        See Also:
        MagicNumberFileFilter
        +
      • +
      + + + +
        +
      • +

        makeCVSAware

        +
        public static IOFileFilter makeCVSAware(IOFileFilter filter)
        +
        Decorates a filter to make it ignore CVS directories. + Passing in null will return a filter that accepts everything + except CVS directories.
        +
        Parameters:
        filter - the filter to decorate, null means an unrestricted filter
        +
        Returns:
        the decorated filter, never null
        Since:
        +
        1.1 (method existed but had bug in 1.0)
        +
      • +
      + + + +
        +
      • +

        makeSVNAware

        +
        public static IOFileFilter makeSVNAware(IOFileFilter filter)
        +
        Decorates a filter to make it ignore SVN directories. + Passing in null will return a filter that accepts everything + except SVN directories.
        +
        Parameters:
        filter - the filter to decorate, null means an unrestricted filter
        +
        Returns:
        the decorated filter, never null
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        makeDirectoryOnly

        +
        public static IOFileFilter makeDirectoryOnly(IOFileFilter filter)
        +
        Decorates a filter so that it only applies to directories and not to files.
        +
        Parameters:
        filter - the filter to decorate, null means an unrestricted filter
        +
        Returns:
        the decorated filter, never null
        Since:
        +
        1.3
        +
        See Also:
        DirectoryFileFilter.DIRECTORY
        +
      • +
      + + + +
        +
      • +

        makeFileOnly

        +
        public static IOFileFilter makeFileOnly(IOFileFilter filter)
        +
        Decorates a filter so that it only applies to files and not to directories.
        +
        Parameters:
        filter - the filter to decorate, null means an unrestricted filter
        +
        Returns:
        the decorated filter, never null
        Since:
        +
        1.3
        +
        See Also:
        FileFileFilter.FILE
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/HiddenFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/HiddenFileFilter.html" index 366c662597226a8c8f9f4447ddd6ee805e427c6a..4bca46d4d80475e168c879d6a3c8947aa8a2adca 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/HiddenFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/HiddenFileFilter.html" @@ -1,3 +1,375 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:22ea32ae68095997c0d384d76058ac084d3374ca1d1a3d97cbbe6b217e655a24 -size 17612 + + + + + +HiddenFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class HiddenFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class HiddenFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    This filter accepts Files that are hidden. +

    + Example, showing how to print out a list of the + current directory's hidden files: + +

    + File dir = new File(".");
    + String[] files = dir.list( HiddenFileFilter.HIDDEN );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    + +

    + Example, showing how to print out a list of the + current directory's visible (i.e. not hidden) files: + +

    + File dir = new File(".");
    + String[] files = dir.list( HiddenFileFilter.VISIBLE );
    + for ( int i = 0; i < files.length; i++ ) {
    +     System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: HiddenFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        HIDDEN

        +
        public static final IOFileFilter HIDDEN
        +
        Singleton instance of hidden filter
        +
      • +
      + + + +
        +
      • +

        VISIBLE

        +
        public static final IOFileFilter VISIBLE
        +
        Singleton instance of visible filter
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        HiddenFileFilter

        +
        protected HiddenFileFilter()
        +
        Restrictive consructor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the file is hidden.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the file is + hidden, otherwise false.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/IOFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/IOFileFilter.html" index d9b665c1638a7a3044725ff3a1360174b8bed74b..9f68c30bb3e99370e0ce86d48a98739a4e13b3c1 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/IOFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/IOFileFilter.html" @@ -1,3 +1,256 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:403c7d0b46093e0b8ff538f272d7eb560af89c4afec9b9c77868bc00ea7fd16d -size 14606 + + + + + +IOFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Interface IOFileFilter

+
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      booleanaccept(File file) +
      Checks to see if the File should be accepted by this filter.
      +
      booleanaccept(File dir, + String name) +
      Checks to see if the File should be accepted by this filter.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        boolean accept(File file)
        +
        Checks to see if the File should be accepted by this filter. +

        + Defined in FileFilter.

        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      + + + +
        +
      • +

        accept

        +
        boolean accept(File dir,
        +             String name)
        +
        Checks to see if the File should be accepted by this filter. +

        + Defined in FilenameFilter.

        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Parameters:
        dir - the directory File to check
        name - the filename within the directory to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/MagicNumberFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/MagicNumberFileFilter.html" index 2cae64e564bda46fd0ff79f95b255e7fd67946df..c600a89d459528aeab999524021f417e0588ede7 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/MagicNumberFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/MagicNumberFileFilter.html" @@ -1,3 +1,490 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2d5e5184642a626110ff4925df3b950aa385276af5abc8066ac4e28c465a5a46 -size 24639 + + + + + +MagicNumberFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class MagicNumberFileFilter

+
+
+ +
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      MagicNumberFileFilter(byte[] magicNumber) +
      + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files.
      +
      MagicNumberFileFilter(byte[] magicNumber, + long offset) +
      + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files and the byte offset location in the file to + to look for that magic number.
      +
      MagicNumberFileFilter(String magicNumber) +
      + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files.
      +
      MagicNumberFileFilter(String magicNumber, + long offset) +
      + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files and the byte offset location in the file to + to look for that magic number.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        MagicNumberFileFilter

        +
        public MagicNumberFileFilter(byte[] magicNumber)
        +

        + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files. This constructor assumes a starting offset + of 0. +

        + +

        + It is important to note that the array is not cloned and that + any changes to the magic number array after construction will affect the + behavior of this file filter. +

        + +
        + MagicNumberFileFilter javaClassFileFilter =
        +     MagicNumberFileFilter(new byte[] {(byte) 0xCA, (byte) 0xFE,
        +       (byte) 0xBA, (byte) 0xBE});
        + 
        +
        Parameters:
        magicNumber - the magic number to look for in the file.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null, or contains no bytes.
        +
      • +
      + + + +
        +
      • +

        MagicNumberFileFilter

        +
        public MagicNumberFileFilter(String magicNumber)
        +

        + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files. This constructor assumes a starting offset + of 0. +

        + + Example usage: +
        + MagicNumberFileFilter xmlFileFilter =
        +     MagicNumberFileFilter("<?xml");
        + 
        + 
        +
        Parameters:
        magicNumber - the magic number to look for in the file. + The string is converted to bytes using the platform default charset.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null or the empty String.
        +
      • +
      + + + +
        +
      • +

        MagicNumberFileFilter

        +
        public MagicNumberFileFilter(String magicNumber,
        +                     long offset)
        +

        + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files and the byte offset location in the file to + to look for that magic number. +

        + +
        + MagicNumberFileFilter tarFileFilter =
        +     MagicNumberFileFilter("ustar", 257);
        + 
        +
        Parameters:
        magicNumber - the magic number to look for in the file. + The string is converted to bytes using the platform default charset.
        offset - the byte offset in the file to start comparing bytes.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null or the empty String, or offset is + a negative number.
        +
      • +
      + + + +
        +
      • +

        MagicNumberFileFilter

        +
        public MagicNumberFileFilter(byte[] magicNumber,
        +                     long offset)
        +

        + Constructs a new MagicNumberFileFilter and associates it with the magic + number to test for in files and the byte offset location in the file to + to look for that magic number. +

        + +
        + MagicNumberFileFilter tarFileFilter =
        +     MagicNumberFileFilter(new byte[] {0x75, 0x73, 0x74, 0x61, 0x72}, 257);
        + 
        + +
        + MagicNumberFileFilter javaClassFileFilter =
        +     MagicNumberFileFilter(new byte[] {0xCA, 0xFE, 0xBA, 0xBE}, 0);
        + 
        +
        Parameters:
        magicNumber - the magic number to look for in the file.
        offset - the byte offset in the file to start comparing bytes.
        +
        Throws:
        +
        IllegalArgumentException - if magicNumber is + null, or contains no bytes, or offset + is a negative number.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +

        + Accepts the provided file if the file contains the file filter's magic + number at the specified offset. +

        + +

        + If any IOExceptions occur while reading the file, the file will + be rejected. +

        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the file to accept or reject.
        +
        Returns:
        true if the file contains the filter's magic number + at the specified offset, false otherwise.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Returns a String representation of the file filter, which includes the + magic number bytes and byte offset.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representation of the file filter.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NameFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NameFileFilter.html" index b151bb65df649b9ab9b7f8a86a41e76e58dd18cb..39d17ad198d2b892df5941e49ebe2bc5b9a3454e 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NameFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NameFileFilter.html" @@ -1,3 +1,451 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e99d5d2e0d4e6413313451c7a50c4b4ce62bdd00c6af65f11bcee1d5675fda5b -size 28063 + + + + + +NameFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class NameFileFilter

+
+
+ +
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      NameFileFilter(List<String> names) +
      Constructs a new case-sensitive name file filter for a list of names.
      +
      NameFileFilter(List<String> names, + IOCase caseSensitivity) +
      Constructs a new name file filter for a list of names specifying case-sensitivity.
      +
      NameFileFilter(String name) +
      Constructs a new case-sensitive name file filter for a single name.
      +
      NameFileFilter(String[] names) +
      Constructs a new case-sensitive name file filter for an array of names.
      +
      NameFileFilter(String[] names, + IOCase caseSensitivity) +
      Constructs a new name file filter for an array of names specifying case-sensitivity.
      +
      NameFileFilter(String name, + IOCase caseSensitivity) +
      Construct a new name file filter specifying case-sensitivity.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NameFileFilter

        +
        public NameFileFilter(String name)
        +
        Constructs a new case-sensitive name file filter for a single name.
        +
        Parameters:
        name - the name to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the name is null
        +
      • +
      + + + +
        +
      • +

        NameFileFilter

        +
        public NameFileFilter(String name,
        +              IOCase caseSensitivity)
        +
        Construct a new name file filter specifying case-sensitivity.
        +
        Parameters:
        name - the name to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the name is null
        +
      • +
      + + + +
        +
      • +

        NameFileFilter

        +
        public NameFileFilter(String[] names)
        +
        Constructs a new case-sensitive name file filter for an array of names. +

        + The array is not cloned, so could be changed after constructing the + instance. This would be inadvisable however.

        +
        Parameters:
        names - the names to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the names array is null
        +
      • +
      + + + +
        +
      • +

        NameFileFilter

        +
        public NameFileFilter(String[] names,
        +              IOCase caseSensitivity)
        +
        Constructs a new name file filter for an array of names specifying case-sensitivity.
        +
        Parameters:
        names - the names to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the names array is null
        +
      • +
      + + + +
        +
      • +

        NameFileFilter

        +
        public NameFileFilter(List<String> names)
        +
        Constructs a new case-sensitive name file filter for a list of names.
        +
        Parameters:
        names - the names to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the name list is null
        +
        ClassCastException - if the list does not contain Strings
        +
      • +
      + + + +
        +
      • +

        NameFileFilter

        +
        public NameFileFilter(List<String> names,
        +              IOCase caseSensitivity)
        +
        Constructs a new name file filter for a list of names specifying case-sensitivity.
        +
        Parameters:
        names - the names to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the name list is null
        +
        ClassCastException - if the list does not contain Strings
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the filename matches.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the filename matches
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File dir,
        +             String name)
        +
        Checks to see if the filename matches.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        dir - the File directory (ignored)
        name - the filename
        +
        Returns:
        true if the filename matches
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NotFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NotFileFilter.html" index 2f505b8d752678270d5adca66efcd23e2ea27f6d..b80af6e3e5454300b3c355d7b9458c43b3c0d680 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NotFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/NotFileFilter.html" @@ -1,3 +1,338 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e04ecd3d927a0b66b69132adfbc468e3df964fa7accfeea3663500b54f6c111c -size 18875 + + + + + +NotFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class NotFileFilter

+
+
+ +
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      NotFileFilter(IOFileFilter filter) +
      Constructs a new file filter that NOTs the result of another filter.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NotFileFilter

        +
        public NotFileFilter(IOFileFilter filter)
        +
        Constructs a new file filter that NOTs the result of another filter.
        +
        Parameters:
        filter - the filter, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the filter is null
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Returns the logical NOT of the underlying filter's return value for the same File.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the filter returns false
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file,
        +             String name)
        +
        Returns the logical NOT of the underlying filter's return value for the same arguments.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File directory
        name - the filename
        +
        Returns:
        true if the filter returns false
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/OrFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/OrFileFilter.html" index e8fb7d2f5e35f985928e027206eabdbca783cf44..751ad8bdef1084ad3f5814340e1e159689b2b631 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/OrFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/OrFileFilter.html" @@ -1,3 +1,466 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2ab5c52d72b470b9d8638745703d40279ec69652fc749293341c5b27aed9c2ae -size 28733 + + + + + +OrFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class OrFileFilter

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        OrFileFilter

        +
        public OrFileFilter()
        +
        Constructs a new instance of OrFileFilter.
        +
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        OrFileFilter

        +
        public OrFileFilter(List<IOFileFilter> fileFilters)
        +
        Constructs a new instance of OrFileFilter + with the specified filters.
        +
        Parameters:
        fileFilters - the file filters for this filter, copied, null ignored
        Since:
        +
        1.1
        +
      • +
      + + + +
        +
      • +

        OrFileFilter

        +
        public OrFileFilter(IOFileFilter filter1,
        +            IOFileFilter filter2)
        +
        Constructs a new file filter that ORs the result of two other filters.
        +
        Parameters:
        filter1 - the first filter, must not be null
        filter2 - the second filter, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if either filter is null
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        addFileFilter

        +
        public void addFileFilter(IOFileFilter ioFileFilter)
        +
        Adds the specified file filter to the list of file filters at the end of + the list.
        +
        +
        Specified by:
        +
        addFileFilter in interface ConditionalFileFilter
        +
        Parameters:
        ioFileFilter - the filter to be added
        +
      • +
      + + + + + + + +
        +
      • +

        removeFileFilter

        +
        public boolean removeFileFilter(IOFileFilter ioFileFilter)
        +
        Removes the specified file filter.
        +
        +
        Specified by:
        +
        removeFileFilter in interface ConditionalFileFilter
        +
        Parameters:
        ioFileFilter - filter to be removed
        +
        Returns:
        true if the filter was found in the list, + false otherwise
        +
      • +
      + + + +
        +
      • +

        setFileFilters

        +
        public void setFileFilters(List<IOFileFilter> fileFilters)
        +
        Sets the list of file filters, replacing any previously configured + file filters on this filter.
        +
        +
        Specified by:
        +
        setFileFilters in interface ConditionalFileFilter
        +
        Parameters:
        fileFilters - the list of filters
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the File should be accepted by this filter.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file,
        +             String name)
        +
        Checks to see if the File should be accepted by this filter.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the directory File to check
        name - the filename within the directory to check
        +
        Returns:
        true if this file matches the test
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/PrefixFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/PrefixFileFilter.html" index ac5e909eeef870e6823e1556c7d71ab484de4bbb..080bfc330e872098a5f563ca03c45d1563e3d599 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/PrefixFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/PrefixFileFilter.html" @@ -1,3 +1,460 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f6deb4a418c2b51ba7dbd72270474fe00bfc08a77dd208cc260a63b6f301cd76 -size 28569 + + + + + +PrefixFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class PrefixFileFilter

+
+
+ +
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      PrefixFileFilter(List<String> prefixes) +
      Constructs a new Prefix file filter for a list of prefixes.
      +
      PrefixFileFilter(List<String> prefixes, + IOCase caseSensitivity) +
      Constructs a new Prefix file filter for a list of prefixes + specifying case-sensitivity.
      +
      PrefixFileFilter(String prefix) +
      Constructs a new Prefix file filter for a single prefix.
      +
      PrefixFileFilter(String[] prefixes) +
      Constructs a new Prefix file filter for any of an array of prefixes.
      +
      PrefixFileFilter(String[] prefixes, + IOCase caseSensitivity) +
      Constructs a new Prefix file filter for any of an array of prefixes + specifying case-sensitivity.
      +
      PrefixFileFilter(String prefix, + IOCase caseSensitivity) +
      Constructs a new Prefix file filter for a single prefix + specifying case-sensitivity.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        PrefixFileFilter

        +
        public PrefixFileFilter(String prefix)
        +
        Constructs a new Prefix file filter for a single prefix.
        +
        Parameters:
        prefix - the prefix to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the prefix is null
        +
      • +
      + + + +
        +
      • +

        PrefixFileFilter

        +
        public PrefixFileFilter(String prefix,
        +                IOCase caseSensitivity)
        +
        Constructs a new Prefix file filter for a single prefix + specifying case-sensitivity.
        +
        Parameters:
        prefix - the prefix to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the prefix is null
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        PrefixFileFilter

        +
        public PrefixFileFilter(String[] prefixes)
        +
        Constructs a new Prefix file filter for any of an array of prefixes. +

        + The array is not cloned, so could be changed after constructing the + instance. This would be inadvisable however.

        +
        Parameters:
        prefixes - the prefixes to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the prefix array is null
        +
      • +
      + + + +
        +
      • +

        PrefixFileFilter

        +
        public PrefixFileFilter(String[] prefixes,
        +                IOCase caseSensitivity)
        +
        Constructs a new Prefix file filter for any of an array of prefixes + specifying case-sensitivity.
        +
        Parameters:
        prefixes - the prefixes to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the prefix is null
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        PrefixFileFilter

        +
        public PrefixFileFilter(List<String> prefixes)
        +
        Constructs a new Prefix file filter for a list of prefixes.
        +
        Parameters:
        prefixes - the prefixes to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the prefix list is null
        +
        ClassCastException - if the list does not contain Strings
        +
      • +
      + + + +
        +
      • +

        PrefixFileFilter

        +
        public PrefixFileFilter(List<String> prefixes,
        +                IOCase caseSensitivity)
        +
        Constructs a new Prefix file filter for a list of prefixes + specifying case-sensitivity.
        +
        Parameters:
        prefixes - the prefixes to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the prefix list is null
        +
        ClassCastException - if the list does not contain Strings
        Since:
        +
        1.4
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the filename starts with the prefix.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the filename starts with one of our prefixes
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file,
        +             String name)
        +
        Checks to see if the filename starts with the prefix.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File directory
        name - the filename
        +
        Returns:
        true if the filename starts with one of our prefixes
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/RegexFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/RegexFileFilter.html" index 3ef8b5a3c0e125457c2ad1a52da0dd460e3e9f1a..8edca8e09d8756441f43b2ef94852b1ee4df9401 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/RegexFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/RegexFileFilter.html" @@ -1,3 +1,371 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:46d2410ba58b1eb10b8f74a9666e7090fbc1f79d1d13ee2636c203d385b266a0 -size 20798 + + + + + +RegexFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class RegexFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class RegexFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    Filters files using supplied regular expression(s). +

    + See java.util.regex.Pattern for regex matching rules +

    + +

    + e.g. +

    + File dir = new File(".");
    + FileFilter fileFilter = new RegexFileFilter("^.*[tT]est(-\\d+)?\\.java$");
    + File[] files = dir.listFiles(fileFilter);
    + for (int i = 0; i < files.length; i++) {
    +   System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: RegexFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        RegexFileFilter

        +
        public RegexFileFilter(String pattern)
        +
        Construct a new regular expression filter.
        +
        Parameters:
        pattern - regular string expression to match
        +
        Throws:
        +
        IllegalArgumentException - if the pattern is null
        +
      • +
      + + + +
        +
      • +

        RegexFileFilter

        +
        public RegexFileFilter(String pattern,
        +               IOCase caseSensitivity)
        +
        Construct a new regular expression filter with the specified flags case sensitivity.
        +
        Parameters:
        pattern - regular string expression to match
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the pattern is null
        +
      • +
      + + + +
        +
      • +

        RegexFileFilter

        +
        public RegexFileFilter(String pattern,
        +               int flags)
        +
        Construct a new regular expression filter with the specified flags.
        +
        Parameters:
        pattern - regular string expression to match
        flags - pattern flags - e.g. Pattern.CASE_INSENSITIVE
        +
        Throws:
        +
        IllegalArgumentException - if the pattern is null
        +
      • +
      + + + +
        +
      • +

        RegexFileFilter

        +
        public RegexFileFilter(Pattern pattern)
        +
        Construct a new regular expression filter for a compiled regular expression
        +
        Parameters:
        pattern - regular expression to match
        +
        Throws:
        +
        IllegalArgumentException - if the pattern is null
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File dir,
        +             String name)
        +
        Checks to see if the filename matches one of the regular expressions.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        dir - the file directory (ignored)
        name - the filename
        +
        Returns:
        true if the filename matches one of the regular expressions
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SizeFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SizeFileFilter.html" index 200d450ed747d9ed579228f647f72b62f636b264..51da99dc2b61bee44f0f47607520decffebcdb14 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SizeFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SizeFileFilter.html" @@ -1,3 +1,362 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b7a502936a24867f5925398de4d79f40feda39bc2e52c36e8750ce54410445ff -size 18416 + + + + + +SizeFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class SizeFileFilter

+
+
+ +
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      SizeFileFilter(long size) +
      Constructs a new size file filter for files equal to or + larger than a certain size.
      +
      SizeFileFilter(long size, + boolean acceptLarger) +
      Constructs a new size file filter for files based on a certain size + threshold.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        SizeFileFilter

        +
        public SizeFileFilter(long size)
        +
        Constructs a new size file filter for files equal to or + larger than a certain size.
        +
        Parameters:
        size - the threshold size of the files
        +
        Throws:
        +
        IllegalArgumentException - if the size is negative
        +
      • +
      + + + +
        +
      • +

        SizeFileFilter

        +
        public SizeFileFilter(long size,
        +              boolean acceptLarger)
        +
        Constructs a new size file filter for files based on a certain size + threshold.
        +
        Parameters:
        size - the threshold size of the files
        acceptLarger - if true, files equal to or larger are accepted, + otherwise smaller ones (but not equal to)
        +
        Throws:
        +
        IllegalArgumentException - if the size is negative
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the size of the file is favorable. +

        + If size equals threshold and smaller files are required, + file IS NOT selected. + If size equals threshold and larger files are required, + file IS selected.

        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the filename matches
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SuffixFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SuffixFileFilter.html" index f4d57b22b1d308b4a584b70bab939c9f8d1e28f0..e13679e740c13f051ab5a513a86069e0786e2c48 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SuffixFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/SuffixFileFilter.html" @@ -1,3 +1,461 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:116aeed8d73e23b9e324bfe076be0792ba6d6c255554c45eba577a06a1badc77 -size 28609 + + + + + +SuffixFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class SuffixFileFilter

+
+
+ +
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      SuffixFileFilter(List<String> suffixes) +
      Constructs a new Suffix file filter for a list of suffixes.
      +
      SuffixFileFilter(List<String> suffixes, + IOCase caseSensitivity) +
      Constructs a new Suffix file filter for a list of suffixes + specifying case-sensitivity.
      +
      SuffixFileFilter(String suffix) +
      Constructs a new Suffix file filter for a single extension.
      +
      SuffixFileFilter(String[] suffixes) +
      Constructs a new Suffix file filter for an array of suffixs.
      +
      SuffixFileFilter(String[] suffixes, + IOCase caseSensitivity) +
      Constructs a new Suffix file filter for an array of suffixs + specifying case-sensitivity.
      +
      SuffixFileFilter(String suffix, + IOCase caseSensitivity) +
      Constructs a new Suffix file filter for a single extension + specifying case-sensitivity.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        SuffixFileFilter

        +
        public SuffixFileFilter(String suffix)
        +
        Constructs a new Suffix file filter for a single extension.
        +
        Parameters:
        suffix - the suffix to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the suffix is null
        +
      • +
      + + + +
        +
      • +

        SuffixFileFilter

        +
        public SuffixFileFilter(String suffix,
        +                IOCase caseSensitivity)
        +
        Constructs a new Suffix file filter for a single extension + specifying case-sensitivity.
        +
        Parameters:
        suffix - the suffix to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the suffix is null
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        SuffixFileFilter

        +
        public SuffixFileFilter(String[] suffixes)
        +
        Constructs a new Suffix file filter for an array of suffixs. +

        + The array is not cloned, so could be changed after constructing the + instance. This would be inadvisable however.

        +
        Parameters:
        suffixes - the suffixes to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the suffix array is null
        +
      • +
      + + + +
        +
      • +

        SuffixFileFilter

        +
        public SuffixFileFilter(String[] suffixes,
        +                IOCase caseSensitivity)
        +
        Constructs a new Suffix file filter for an array of suffixs + specifying case-sensitivity.
        +
        Parameters:
        suffixes - the suffixes to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the suffix array is null
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        SuffixFileFilter

        +
        public SuffixFileFilter(List<String> suffixes)
        +
        Constructs a new Suffix file filter for a list of suffixes.
        +
        Parameters:
        suffixes - the suffixes to allow, must not be null
        +
        Throws:
        +
        IllegalArgumentException - if the suffix list is null
        +
        ClassCastException - if the list does not contain Strings
        +
      • +
      + + + +
        +
      • +

        SuffixFileFilter

        +
        public SuffixFileFilter(List<String> suffixes,
        +                IOCase caseSensitivity)
        +
        Constructs a new Suffix file filter for a list of suffixes + specifying case-sensitivity.
        +
        Parameters:
        suffixes - the suffixes to allow, must not be null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the suffix list is null
        +
        ClassCastException - if the list does not contain Strings
        Since:
        +
        1.4
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the filename ends with the suffix.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File to check
        +
        Returns:
        true if the filename ends with one of our suffixes
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file,
        +             String name)
        +
        Checks to see if the filename ends with the suffix.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the File directory
        name - the filename
        +
        Returns:
        true if the filename ends with one of our suffixes
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representaion of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representaion
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/TrueFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/TrueFileFilter.html" index c0d9525c30cfd2b2be34455250f5d3596b621815..cd19b18d7dc7aca1313f3e1327fdf08b6038035c 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/TrueFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/TrueFileFilter.html" @@ -1,3 +1,368 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:01984153f4f467d4f9ff45da52fe4fcb61da3af92272c879791a529aacff8107 -size 18417 + + + + + +TrueFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class TrueFileFilter

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        TRUE

        +
        public static final IOFileFilter TRUE
        +
        Singleton instance of true filter.
        +
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        INSTANCE

        +
        public static final IOFileFilter INSTANCE
        +
        Singleton instance of true filter. + Please use the identical TrueFileFilter.TRUE constant. + The new name is more JDK 1.5 friendly as it doesn't clash with other + values when using static imports.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TrueFileFilter

        +
        protected TrueFileFilter()
        +
        Restrictive constructor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Returns true.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Parameters:
        file - the file to check (ignored)
        +
        Returns:
        true
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File dir,
        +             String name)
        +
        Returns true.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Parameters:
        dir - the directory to check (ignored)
        name - the filename (ignored)
        +
        Returns:
        true
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFileFilter.html" index 9f3ffadffd29b7923724276d4e2706a90637c62b..3280902792be4b69afec78d3c3a8e25be73fb3a3 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFileFilter.html" @@ -1,3 +1,456 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:39666ebd0544250f035179ddeffd7769fce42f4fc6f5546557fdf5d036a8897e -size 28630 + + + + + +WildcardFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class WildcardFileFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    +
    public class WildcardFileFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    Filters files using the supplied wildcards. +

    + This filter selects files and directories based on one or more wildcards. + Testing is case-sensitive by default, but this can be configured. +

    + The wildcard matcher uses the characters '?' and '*' to represent a + single or multiple wildcard characters. + This is the same as often found on Dos/Unix command lines. + The check is case-sensitive by default. + See FilenameUtils.wildcardMatchOnSystem(java.lang.String, java.lang.String) for more information. +

    + For example: +

    + File dir = new File(".");
    + FileFilter fileFilter = new WildcardFileFilter("*test*.java~*~");
    + File[] files = dir.listFiles(fileFilter);
    + for (int i = 0; i < files.length; i++) {
    +   System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: WildcardFileFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      WildcardFileFilter(List<String> wildcards) +
      Construct a new case-sensitive wildcard filter for a list of wildcards.
      +
      WildcardFileFilter(List<String> wildcards, + IOCase caseSensitivity) +
      Construct a new wildcard filter for a list of wildcards specifying case-sensitivity.
      +
      WildcardFileFilter(String wildcard) +
      Construct a new case-sensitive wildcard filter for a single wildcard.
      +
      WildcardFileFilter(String[] wildcards) +
      Construct a new case-sensitive wildcard filter for an array of wildcards.
      +
      WildcardFileFilter(String[] wildcards, + IOCase caseSensitivity) +
      Construct a new wildcard filter for an array of wildcards specifying case-sensitivity.
      +
      WildcardFileFilter(String wildcard, + IOCase caseSensitivity) +
      Construct a new wildcard filter for a single wildcard specifying case-sensitivity.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        WildcardFileFilter

        +
        public WildcardFileFilter(String wildcard)
        +
        Construct a new case-sensitive wildcard filter for a single wildcard.
        +
        Parameters:
        wildcard - the wildcard to match
        +
        Throws:
        +
        IllegalArgumentException - if the pattern is null
        +
      • +
      + + + +
        +
      • +

        WildcardFileFilter

        +
        public WildcardFileFilter(String wildcard,
        +                  IOCase caseSensitivity)
        +
        Construct a new wildcard filter for a single wildcard specifying case-sensitivity.
        +
        Parameters:
        wildcard - the wildcard to match, not null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the pattern is null
        +
      • +
      + + + +
        +
      • +

        WildcardFileFilter

        +
        public WildcardFileFilter(String[] wildcards)
        +
        Construct a new case-sensitive wildcard filter for an array of wildcards. +

        +
        Parameters:
        wildcards - the array of wildcards to match
        +
        Throws:
        +
        IllegalArgumentException - if the pattern array is null
        +
      • +
      + + + +
        +
      • +

        WildcardFileFilter

        +
        public WildcardFileFilter(String[] wildcards,
        +                  IOCase caseSensitivity)
        +
        Construct a new wildcard filter for an array of wildcards specifying case-sensitivity. +

        +
        Parameters:
        wildcards - the array of wildcards to match, not null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the pattern array is null
        +
      • +
      + + + +
        +
      • +

        WildcardFileFilter

        +
        public WildcardFileFilter(List<String> wildcards)
        +
        Construct a new case-sensitive wildcard filter for a list of wildcards.
        +
        Parameters:
        wildcards - the list of wildcards to match, not null
        +
        Throws:
        +
        IllegalArgumentException - if the pattern list is null
        +
        ClassCastException - if the list does not contain Strings
        +
      • +
      + + + +
        +
      • +

        WildcardFileFilter

        +
        public WildcardFileFilter(List<String> wildcards,
        +                  IOCase caseSensitivity)
        +
        Construct a new wildcard filter for a list of wildcards specifying case-sensitivity.
        +
        Parameters:
        wildcards - the list of wildcards to match, not null
        caseSensitivity - how to handle case sensitivity, null means case-sensitive
        +
        Throws:
        +
        IllegalArgumentException - if the pattern list is null
        +
        ClassCastException - if the list does not contain Strings
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File dir,
        +             String name)
        +
        Checks to see if the filename matches one of the wildcards.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        dir - the file directory (ignored)
        name - the filename
        +
        Returns:
        true if the filename matches one of the wildcards
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Checks to see if the filename matches one of the wildcards.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the file to check
        +
        Returns:
        true if the filename matches one of the wildcards
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representation of this file filter.
        +
        +
        Overrides:
        +
        toString in class AbstractFileFilter
        +
        Returns:
        a String representation
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFilter.html" index 7cba0a73ca1838e026e95d7a91eb30687e49ef32..bdff64a85bbbb7b35a692628c7b32fc22123cc7e 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/WildcardFilter.html" @@ -1,3 +1,395 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:656804d28afc68c8af48ed2d5703ce2ccb9cf01e79cc791a1a87a32c6a1b39db -size 22447 + + + + + +WildcardFilter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.filefilter
+

Class WildcardFilter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    FileFilter, FilenameFilter, Serializable, IOFileFilter
    +
    +
    +
    Deprecated.  +
    Use WilcardFileFilter. Deprecated as this class performs directory + filtering which it shouldn't do, but that can't be removed due to compatability.
    +
    +
    +
    @Deprecated
    +public class WildcardFilter
    +extends AbstractFileFilter
    +implements Serializable
    +
    Filters files using the supplied wildcards. +

    + This filter selects files, but not directories, based on one or more wildcards + and using case-sensitive comparison. +

    + The wildcard matcher uses the characters '?' and '*' to represent a + single or multiple wildcard characters. + This is the same as often found on Dos/Unix command lines. + The extension check is case-sensitive. + See FilenameUtils.wildcardMatch(String, String) for more information. +

    + For example: +

    + File dir = new File(".");
    + FileFilter fileFilter = new WildcardFilter("*test*.java~*~");
    + File[] files = dir.listFiles(fileFilter);
    + for (int i = 0; i < files.length; i++) {
    +   System.out.println(files[i]);
    + }
    + 
    +
    Since:
    +
    1.1
    +
    Version:
    +
    $Id: WildcardFilter.java 1642757 2014-12-01 21:09:30Z sebb $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      WildcardFilter(List<String> wildcards) +
      Deprecated. 
      +
      Construct a new case-sensitive wildcard filter for a list of wildcards.
      +
      WildcardFilter(String wildcard) +
      Deprecated. 
      +
      Construct a new case-sensitive wildcard filter for a single wildcard.
      +
      WildcardFilter(String[] wildcards) +
      Deprecated. 
      +
      Construct a new case-sensitive wildcard filter for an array of wildcards.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        WildcardFilter

        +
        public WildcardFilter(String wildcard)
        +
        Deprecated. 
        +
        Construct a new case-sensitive wildcard filter for a single wildcard.
        +
        Parameters:
        wildcard - the wildcard to match
        +
        Throws:
        +
        IllegalArgumentException - if the pattern is null
        +
      • +
      + + + +
        +
      • +

        WildcardFilter

        +
        public WildcardFilter(String[] wildcards)
        +
        Deprecated. 
        +
        Construct a new case-sensitive wildcard filter for an array of wildcards.
        +
        Parameters:
        wildcards - the array of wildcards to match
        +
        Throws:
        +
        IllegalArgumentException - if the pattern array is null
        +
      • +
      + + + +
        +
      • +

        WildcardFilter

        +
        public WildcardFilter(List<String> wildcards)
        +
        Deprecated. 
        +
        Construct a new case-sensitive wildcard filter for a list of wildcards.
        +
        Parameters:
        wildcards - the list of wildcards to match
        +
        Throws:
        +
        IllegalArgumentException - if the pattern list is null
        +
        ClassCastException - if the list does not contain Strings
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        accept

        +
        public boolean accept(File dir,
        +             String name)
        +
        Deprecated. 
        +
        Checks to see if the filename matches one of the wildcards.
        +
        +
        Specified by:
        +
        accept in interface FilenameFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        dir - the file directory
        name - the filename
        +
        Returns:
        true if the filename matches one of the wildcards
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public boolean accept(File file)
        +
        Deprecated. 
        +
        Checks to see if the filename matches one of the wildcards.
        +
        +
        Specified by:
        +
        accept in interface FileFilter
        +
        Specified by:
        +
        accept in interface IOFileFilter
        +
        Overrides:
        +
        accept in class AbstractFileFilter
        +
        Parameters:
        file - the file to check
        +
        Returns:
        true if the filename matches one of the wildcards
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AbstractFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AbstractFileFilter.html" index 1ca6e2ed1ec1c795568698cd53b5f5a8b9fb05a5..15aa02189506f1646b5cacdc137fe378b3f6a1e8 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AbstractFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AbstractFileFilter.html" @@ -1,3 +1,276 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cc79a27000301b17efd1ed0f3e1b38ee12b2cf4c798a60644a2905115c8495af -size 14263 + + + + + +Uses of Class org.apache.commons.io.filefilter.AbstractFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.AbstractFileFilter

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AgeFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AgeFileFilter.html" index 5e3b1106bee200d7e8380d9a0d683d708075230b..474208623717e9d9efc5a448ce34893e827895e5 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AgeFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AgeFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4684307711cf6bae37479410ae022ad16c1839231b4a5b7ff9416405253125b5 -size 4448 + + + + + +Uses of Class org.apache.commons.io.filefilter.AgeFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.AgeFileFilter

+
+
No usage of org.apache.commons.io.filefilter.AgeFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AndFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AndFileFilter.html" index 32271deb2921aba521b0b9a73319f544fcacd4df..5ee7cde0da3980a018831889345a9ffc314d3360 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AndFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/AndFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f894689061d2ead38e01e288c900dd5e3ec611f25e5c782c4141bfd64cb9dffd -size 4448 + + + + + +Uses of Class org.apache.commons.io.filefilter.AndFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.AndFileFilter

+
+
No usage of org.apache.commons.io.filefilter.AndFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanReadFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanReadFileFilter.html" index 1c6992bf52844f600e57d88b43f15296697a5b45..ec47ee4860114a058be19ac513718a4a0e31e35a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanReadFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanReadFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a8c1961e0e946e3282e8ef8e96495a4c31a66cdc8d8db9f29ff4b1473fbf8ffa -size 4492 + + + + + +Uses of Class org.apache.commons.io.filefilter.CanReadFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.CanReadFileFilter

+
+
No usage of org.apache.commons.io.filefilter.CanReadFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanWriteFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanWriteFileFilter.html" index 9e5f0dc2dd432dbd879a6c9dcb17a70ce686fed5..ef36bfdb45fb29e031e8196c67500211991e3fa7 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanWriteFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/CanWriteFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b70759bbbdfefdfee4bde53e3ede2e218d4b6512b4f0a04e6d5c2a54684a61df -size 4503 + + + + + +Uses of Class org.apache.commons.io.filefilter.CanWriteFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.CanWriteFileFilter

+
+
No usage of org.apache.commons.io.filefilter.CanWriteFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/ConditionalFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/ConditionalFileFilter.html" index b26e75095c80280483a67c21013a8ba43d2f0a62..49c07e3509ec6b73803b61a743e05251ad038cde 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/ConditionalFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/ConditionalFileFilter.html" @@ -1,3 +1,168 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aea8528988057ab4c2c099239b495e1a90224367adb54f609a627ce941a5b8b6 -size 7784 + + + + + +Uses of Interface org.apache.commons.io.filefilter.ConditionalFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Interface
org.apache.commons.io.filefilter.ConditionalFileFilter

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DelegateFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DelegateFileFilter.html" index f8f86fcd86b022ea79ab5733469d64f4090d88a6..34e10b3fdae6436202abda3034610ba4eef93847 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DelegateFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DelegateFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d811695fd6ef5c59d777ad613b0f98c6a331c87ae789b0fb18c93e009ae48894 -size 4503 + + + + + +Uses of Class org.apache.commons.io.filefilter.DelegateFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.DelegateFileFilter

+
+
No usage of org.apache.commons.io.filefilter.DelegateFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DirectoryFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DirectoryFileFilter.html" index 6deea2cc92e3095401c4f585c39b8c4d4a2c6ea7..97f4c96a1e0d92b6aa2b827c84da57d46e0798a7 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DirectoryFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/DirectoryFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:709abe45625ca4b0b6e3d77ae063523bcf5384d911ccfdaeca5b584d2b4316ad -size 4514 + + + + + +Uses of Class org.apache.commons.io.filefilter.DirectoryFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.DirectoryFileFilter

+
+
No usage of org.apache.commons.io.filefilter.DirectoryFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/EmptyFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/EmptyFileFilter.html" index 903c3c959a8793a91013568abe643bc3bd469a4c..65b3712c8348e17986798711c5ad140c86261c69 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/EmptyFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/EmptyFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8c3fd278f10a2220979eb01f0bd3162fe0b0ab6a52b92957e627e6352df96d4e -size 4470 + + + + + +Uses of Class org.apache.commons.io.filefilter.EmptyFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.EmptyFileFilter

+
+
No usage of org.apache.commons.io.filefilter.EmptyFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FalseFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FalseFileFilter.html" index be6cc59c01fbbb354292dabefb5d7b6dc1e5b7ec..f6135bbc987985fea70599b23f17d6cf20296f15 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FalseFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FalseFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5a5012b6c3d3f28fda52d1996f750047d435e36d2b83de350cd6251b34432593 -size 4470 + + + + + +Uses of Class org.apache.commons.io.filefilter.FalseFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.FalseFileFilter

+
+
No usage of org.apache.commons.io.filefilter.FalseFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFileFilter.html" index f3359e39d8528dcfcedea69e1f5a5cab92ce835c..cf62f106c6723daae006939104489d7eb2f27c21 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cae350f7cd6ce9c2e85aaf6e1d022c0b8960ba8a6996a2740630f80fcd5c4718 -size 4459 + + + + + +Uses of Class org.apache.commons.io.filefilter.FileFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.FileFileFilter

+
+
No usage of org.apache.commons.io.filefilter.FileFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFilterUtils.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFilterUtils.html" index 75b59292af618e2a823fb505aa80a591c275f279..3f64fb72917186d2658da005bf628bbd5049155d 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFilterUtils.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/FileFilterUtils.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f4b5fe1748d1ccd1af03182142f9dbc399c134f5a96359819641a04a2f8961e7 -size 4470 + + + + + +Uses of Class org.apache.commons.io.filefilter.FileFilterUtils (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.FileFilterUtils

+
+
No usage of org.apache.commons.io.filefilter.FileFilterUtils
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/HiddenFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/HiddenFileFilter.html" index 70aaebfc4f3b8e65538846dec0161013e2a8418f..0c93531979f847c98f6e5a5c20a0a1bbdeb72324 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/HiddenFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/HiddenFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0db93bd3c53eebf435729a66c8b1805b32dd324011e34f3e7435faedcd460f69 -size 4481 + + + + + +Uses of Class org.apache.commons.io.filefilter.HiddenFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.HiddenFileFilter

+
+
No usage of org.apache.commons.io.filefilter.HiddenFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/IOFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/IOFileFilter.html" index dacc24b054d72ef65ffb4da7faedaf5c9a5c3977..290b7eff01d97fc5a2602370b737a83c144e2718 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/IOFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/IOFileFilter.html" @@ -1,3 +1,989 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:92b6325fdaa138a60cc6a8885f56e96dc61bdb1adaaddd78969fff149b77e973 -size 88148 + + + + + +Uses of Interface org.apache.commons.io.filefilter.IOFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Interface
org.apache.commons.io.filefilter.IOFileFilter

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/MagicNumberFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/MagicNumberFileFilter.html" index bb8f3b0aa65f7f5637f915c0411c8ac6f1d4b066..6022fcd322abf705c31b5199eb58a404687b016b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/MagicNumberFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/MagicNumberFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:76e8e891d71cc0d9be9cae67cfbca9427e52f3491a29c50c73dbcc1e0dc0f1f9 -size 4536 + + + + + +Uses of Class org.apache.commons.io.filefilter.MagicNumberFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.MagicNumberFileFilter

+
+
No usage of org.apache.commons.io.filefilter.MagicNumberFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NameFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NameFileFilter.html" index f3dbf36c3962271f9cc2c43c5d0a4fbfb4cacd5c..a706e07819e98ff985106b6ac0e85425c713e648 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NameFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NameFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:921b072041ab7dba54031ff8dc040ebc5fb8119e9919590a47e5025175db2b59 -size 4459 + + + + + +Uses of Class org.apache.commons.io.filefilter.NameFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.NameFileFilter

+
+
No usage of org.apache.commons.io.filefilter.NameFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NotFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NotFileFilter.html" index 73c326f87cf68758e632871e881e7ebc9809ffee..3992078e59ed20fca0b7c6dc3d8a668a6f8a73bf 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NotFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/NotFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bf07641c07215d7f861e70775f7523db483224b446a5ed34bb5952ac071138e8 -size 4448 + + + + + +Uses of Class org.apache.commons.io.filefilter.NotFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.NotFileFilter

+
+
No usage of org.apache.commons.io.filefilter.NotFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/OrFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/OrFileFilter.html" index 7eb341a3aaa73751a3cb0cedb71dbb9a5726c0b9..ab114b1d9be7edc34db0da367c56ed794a07406d 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/OrFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/OrFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:46e846fa2dac309aaff432f517a3c805533dfe593c759fef3ee52c54b6ce1d2d -size 4437 + + + + + +Uses of Class org.apache.commons.io.filefilter.OrFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.OrFileFilter

+
+
No usage of org.apache.commons.io.filefilter.OrFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/PrefixFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/PrefixFileFilter.html" index aa57977fedba2c40bcde89fbfc82c731773bc58d..96abd5c3039047bbe2c5cdc59c780429361c15ca 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/PrefixFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/PrefixFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:90aa34680fdf640250f5b3eae359c3eda8ccba2f0df99d2c4e1563d8c4bb3c65 -size 4481 + + + + + +Uses of Class org.apache.commons.io.filefilter.PrefixFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.PrefixFileFilter

+
+
No usage of org.apache.commons.io.filefilter.PrefixFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/RegexFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/RegexFileFilter.html" index 8f1493ebafc4f211d05c5ac9652ae6b09bd39310..0ef246f3d3ba11d1da51b59c413ff13941b1e754 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/RegexFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/RegexFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e673284fac07dcc0171e22436bbb28227025066a533c488a87aa05a1d8cc142e -size 4470 + + + + + +Uses of Class org.apache.commons.io.filefilter.RegexFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.RegexFileFilter

+
+
No usage of org.apache.commons.io.filefilter.RegexFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SizeFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SizeFileFilter.html" index 25f507c8a0d07e45176bdebd633c2e01ca1bab11..4825ed4d00f26fccdb200501bcc14eb8bcf958b4 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SizeFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SizeFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:55d32dea70336152b89ff5ad815c4c8d2adbe9eca6075d1a78bbc6852b42ef56 -size 4459 + + + + + +Uses of Class org.apache.commons.io.filefilter.SizeFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.SizeFileFilter

+
+
No usage of org.apache.commons.io.filefilter.SizeFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SuffixFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SuffixFileFilter.html" index d08621f627c37efa706dc5669e5013bfb0a9a35e..9586e40ea9a9ba4854b042d136245cda135aa733 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SuffixFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/SuffixFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5675d373d8908cd5c2e945b9f7ecbd59cfe640ed343172f5c0351b43fb2eca5c -size 4481 + + + + + +Uses of Class org.apache.commons.io.filefilter.SuffixFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.SuffixFileFilter

+
+
No usage of org.apache.commons.io.filefilter.SuffixFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/TrueFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/TrueFileFilter.html" index 61ba5293d97e1f6999eecb3a8733dd4844d6cfd5..1c84f852bc2c209900d4713d97a77ab5a526c455 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/TrueFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/TrueFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6c9cc34ee0b4634ea1a1b304cdeff27be632d7078ec75db4c2a5dd93b33cabb8 -size 4459 + + + + + +Uses of Class org.apache.commons.io.filefilter.TrueFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.TrueFileFilter

+
+
No usage of org.apache.commons.io.filefilter.TrueFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFileFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFileFilter.html" index 85b74b801fa7ac17d51358e8fc42f8dad3d2f6f4..ba72c0dea0fd20a88a16506305efa40635a9de59 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFileFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFileFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f395987d294d9368bc7f30cd4154dea52377f7b1cb6cb1fef7c1e3f97edc48ba -size 4503 + + + + + +Uses of Class org.apache.commons.io.filefilter.WildcardFileFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.WildcardFileFilter

+
+
No usage of org.apache.commons.io.filefilter.WildcardFileFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFilter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFilter.html" index e679e8d9e541e243a728ca2efa5f609762ddb1f6..6a83bfa57d6b91b6eff5858ccf3080aa49a2511e 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFilter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/class-use/WildcardFilter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:706f1b51bcfe17515d0aed6df1bcd8596b90cd65b956c439ac7af4828124c849 -size 4459 + + + + + +Uses of Class org.apache.commons.io.filefilter.WildcardFilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.filefilter.WildcardFilter

+
+
No usage of org.apache.commons.io.filefilter.WildcardFilter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-frame.html" index 9e2482619c8007c61f4557fdf6b3d36d9594f67d..ebe7587c57bf84808a0653571af22fa5a52c3dde 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-frame.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-frame.html" @@ -1,3 +1,45 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ceb2985b4180239c8c12a415a8e50ad41ea139dbf9775da7d42ee0f28638b492 -size 4041 + + + + + +org.apache.commons.io.filefilter (Apache Commons IO 2.5 API) + + + +

org.apache.commons.io.filefilter

+ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-summary.html" index 71fa5200c90f93ed885587fb1aaa1fc4f53bb030..6aed0ebbe7b6eb33f6784737c298185bc560a318 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-summary.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-summary.html" @@ -1,3 +1,428 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:86e53807c0267bd3450b5c687f751a2b728f8885db424f85502c781502a145fe -size 18254 + + + + + +org.apache.commons.io.filefilter (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Package org.apache.commons.io.filefilter

+
+
This package defines an interface (IOFileFilter) that combines both +FileFilter and FilenameFilter.
+
+

See: Description

+
+
+
    +
  • + + + + + + + + + + + + + + + + +
    Interface Summary 
    InterfaceDescription
    ConditionalFileFilter +
    Defines operations for conditional file filters.
    +
    IOFileFilter +
    An interface which brings the FileFilter and FilenameFilter + interfaces together.
    +
    +
  • +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    AbstractFileFilter +
    An abstract class which implements the Java FileFilter and FilenameFilter + interfaces via the IOFileFilter interface.
    +
    AgeFileFilter +
    Filters files based on a cutoff time, can filter either newer + files or files equal to or older.
    +
    AndFileFilter +
    A FileFilter providing conditional AND logic across a list of + file filters.
    +
    CanReadFileFilter +
    This filter accepts Files that can be read.
    +
    CanWriteFileFilter +
    This filter accepts Files that can be written to.
    +
    DelegateFileFilter +
    This class turns a Java FileFilter or FilenameFilter into an IO FileFilter.
    +
    DirectoryFileFilter +
    This filter accepts Files that are directories.
    +
    EmptyFileFilter +
    This filter accepts files or directories that are empty.
    +
    FalseFileFilter +
    A file filter that always returns false.
    +
    FileFileFilter +
    This filter accepts Files that are files (not directories).
    +
    FileFilterUtils +
    Useful utilities for working with file filters.
    +
    HiddenFileFilter +
    This filter accepts Files that are hidden.
    +
    MagicNumberFileFilter +
    + File filter for matching files containing a "magic number".
    +
    NameFileFilter +
    Filters filenames for a certain name.
    +
    NotFileFilter +
    This filter produces a logical NOT of the filters specified.
    +
    OrFileFilter +
    A FileFilter providing conditional OR logic across a list of + file filters.
    +
    PrefixFileFilter +
    Filters filenames for a certain prefix.
    +
    RegexFileFilter +
    Filters files using supplied regular expression(s).
    +
    SizeFileFilter +
    Filters files based on size, can filter either smaller files or + files equal to or larger than a given threshold.
    +
    SuffixFileFilter +
    Filters files based on the suffix (what the filename ends with).
    +
    TrueFileFilter +
    A file filter that always returns true.
    +
    WildcardFileFilter +
    Filters files using the supplied wildcards.
    +
    WildcardFilterDeprecated +
    Use WilcardFileFilter.
    +
    +
  • +
+ + + +

Package org.apache.commons.io.filefilter Description

+

This package defines an interface (IOFileFilter) that combines both +FileFilter and FilenameFilter. Besides +that the package offers a series of ready-to-use implementations of the +IOFileFilter interface including implementation that allow you to combine +other such filters.

+

These filter can be used to list files or in FileDialog, +for example.

+ +

There are a number of 'primitive' filters:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DirectoryFilterOnly accept directories
PrefixFileFilterFilter based on a prefix
SuffixFileFilterFilter based on a suffix
NameFileFilterFilter based on a filename
WildcardFileFilterFilter based on wildcards
AgeFileFilterFilter based on last modified time of file
SizeFileFilterFilter based on file size
+ +

And there are five 'boolean' filters:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
TrueFileFilterAccept all files
FalseFileFilterAccept no files
NotFileFilterApplies a logical NOT to an existing filter
AndFileFilterCombines two filters using a logical AND
OrFileFilterCombines two filter using a logical OR
+ +

These boolean FilenameFilters can be nested, to allow arbitrary expressions. +For example, here is how one could print all non-directory files in the +current directory, starting with "A", and ending in ".java" or ".class":

+ +
+  File dir = new File(".");
+  String[] files = dir.list( 
+    new AndFileFilter(
+      new AndFileFilter(
+        new PrefixFileFilter("A"),
+        new OrFileFilter(
+          new SuffixFileFilter(".class"),
+          new SuffixFileFilter(".java")
+        )
+      ),
+      new NotFileFilter(
+        new DirectoryFileFilter()
+      )
+    )
+  );
+  for ( int i=0; i<files.length; i++ ) {
+    System.out.println(files[i]);
+  }
+
+ +

This package also contains a utility class: +FileFilterUtils. It allows you to use all +file filters without having to put them in the import section. Here's how the +above example will look using FileFilterUtils:

+
+  File dir = new File(".");
+  String[] files = dir.list( 
+    FileFilterUtils.andFileFilter(
+      FileFilterUtils.andFileFilter(
+        FileFilterUtils.prefixFileFilter("A"),
+        FileFilterUtils.orFileFilter(
+          FileFilterUtils.suffixFileFilter(".class"),
+          FileFilterUtils.suffixFileFilter(".java")
+        )
+      ),
+      FileFilterUtils.notFileFilter(
+        FileFilterUtils.directoryFileFilter()
+      )
+    )
+  );
+  for ( int i=0; i<files.length; i++ ) {
+    System.out.println(files[i]);
+  }
+
+

There are a few other goodies in that class so please have a look at the +documentation in detail.

+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-tree.html" index 50df69a741541795ad941530dcd538c2aa166e72..5b33f332add1f6e743cb498b21de09f528f67aea 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-tree.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-tree.html" @@ -1,3 +1,167 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f5d393a79fdf93c23f3db8e58a431a50845dda6d843128ef5d521ca4bd133869 -size 16097 + + + + + +org.apache.commons.io.filefilter Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package org.apache.commons.io.filefilter

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-use.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-use.html" index cd295fb9a316918d501d2b149ab2bcab2713197d..ab5e3ccfaa3eccf42567f0830439bfef6408b4c1 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-use.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/filefilter/package-use.html" @@ -1,3 +1,191 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9df641574476246fc18344cfc2a9616bf1a1aad1e9cc2b1060876c8471e31afe -size 7726 + + + + + +Uses of Package org.apache.commons.io.filefilter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Package
org.apache.commons.io.filefilter

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/AutoCloseInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/AutoCloseInputStream.html" index f25ad65e766fd11bfcb461b7d7363785a818c9e9..3bb23e22e7f4eaadd33098fe5c99dafc237f0d1f 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/AutoCloseInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/AutoCloseInputStream.html" @@ -1,3 +1,385 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ff7a7e3c96c962f3c8acd71d96bb0051a6d32b4e04f475f15a484b2b13e629b7 -size 20431 + + + + + +AutoCloseInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class AutoCloseInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class AutoCloseInputStream
    +extends ProxyInputStream
    +
    Proxy stream that closes and discards the underlying stream as soon as the + end of input has been reached or when the stream is explicitly closed. + Not even a reference to the underlying stream is kept after it has been + closed, so any allocated in-memory buffers can be freed even if the + client application still keeps a reference to the proxy stream. +

    + This class is typically used to release any resources related to an open + stream as soon as possible even if the client application (by not explicitly + closing the stream when no longer needed) or the underlying stream (by not + releasing resources once the last byte has been read) do not do that.

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: AutoCloseInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        AutoCloseInputStream

        +
        public AutoCloseInputStream(InputStream in)
        +
        Creates an automatically closing proxy for the given input stream.
        +
        Parameters:
        in - underlying input stream
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        close

        +
        public void close()
        +           throws IOException
        +
        Closes the underlying input stream and replaces the reference to it + with a ClosedInputStream instance. +

        + This method is automatically called by the read methods when the end + of input has been reached. +

        + Note that it is safe to call this method any number of times. The original + underlying input stream is closed and discarded only once when this + method is first called.

        +
        +
        Specified by:
        +
        close in interface Closeable
        +
        Specified by:
        +
        close in interface AutoCloseable
        +
        Overrides:
        +
        close in class ProxyInputStream
        +
        Throws:
        +
        IOException - if the underlying input stream can not be closed
        +
      • +
      + + + +
        +
      • +

        afterRead

        +
        protected void afterRead(int n)
        +                  throws IOException
        +
        Automatically closes the stream if the end of stream was reached.
        +
        +
        Overrides:
        +
        afterRead in class ProxyInputStream
        +
        Parameters:
        n - number of bytes read, or -1 if no more bytes are available
        +
        Throws:
        +
        IOException - if the stream could not be closed
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        finalize

        +
        protected void finalize()
        +                 throws Throwable
        +
        Ensures that the stream is closed before it gets garbage-collected. + As mentioned in close(), this is a no-op if the stream has + already been closed.
        +
        +
        Overrides:
        +
        finalize in class Object
        +
        Throws:
        +
        Throwable - if an error occurs
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BOMInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BOMInputStream.html" index bfe823f507cd3ef25ad49f1739dd2c60a0e6431c..920b09b5cecc3d6a8fddd8eebf59713fe16d653e 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BOMInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BOMInputStream.html" @@ -1,3 +1,626 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f9a8d2a89147fb1976983f8b05db6ca2529fad1f8b2b859b1378d897aee5fa38 -size 35798 + + + + + +BOMInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class BOMInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class BOMInputStream
    +extends ProxyInputStream
    +
    This class is used to wrap a stream that includes an encoded ByteOrderMark as its first bytes. + + This class detects these bytes and, if required, can automatically skip them and return the subsequent byte as the + first byte in the stream. + + The ByteOrderMark implementation has the following pre-defined BOMs: + + + +

    Example 1 - Detect and exclude a UTF-8 BOM

    + +
    + BOMInputStream bomIn = new BOMInputStream(in);
    + if (bomIn.hasBOM()) {
    +     // has a UTF-8 BOM
    + }
    + 
    + +

    Example 2 - Detect a UTF-8 BOM (but don't exclude it)

    + +
    + boolean include = true;
    + BOMInputStream bomIn = new BOMInputStream(in, include);
    + if (bomIn.hasBOM()) {
    +     // has a UTF-8 BOM
    + }
    + 
    + +

    Example 3 - Detect Multiple BOMs

    + +
    + BOMInputStream bomIn = new BOMInputStream(in, 
    +   ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE,
    +   ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE
    +   );
    + if (bomIn.hasBOM() == false) {
    +     // No BOM found
    + } else if (bomIn.hasBOM(ByteOrderMark.UTF_16LE)) {
    +     // has a UTF-16LE BOM
    + } else if (bomIn.hasBOM(ByteOrderMark.UTF_16BE)) {
    +     // has a UTF-16BE BOM
    + } else if (bomIn.hasBOM(ByteOrderMark.UTF_32LE)) {
    +     // has a UTF-32LE BOM
    + } else if (bomIn.hasBOM(ByteOrderMark.UTF_32BE)) {
    +     // has a UTF-32BE BOM
    + }
    + 
    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: BOMInputStream.java 1686527 2015-06-20 06:31:39Z krosenvold $
    +
    See Also:
    ByteOrderMark, +Wikipedia - Byte Order Mark
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        BOMInputStream

        +
        public BOMInputStream(InputStream delegate)
        +
        Constructs a new BOM InputStream that excludes a ByteOrderMark.UTF_8 BOM.
        +
        Parameters:
        delegate - the InputStream to delegate to
        +
      • +
      + + + +
        +
      • +

        BOMInputStream

        +
        public BOMInputStream(InputStream delegate,
        +              boolean include)
        +
        Constructs a new BOM InputStream that detects a a ByteOrderMark.UTF_8 and optionally includes it.
        +
        Parameters:
        delegate - the InputStream to delegate to
        include - true to include the UTF-8 BOM or false to exclude it
        +
      • +
      + + + +
        +
      • +

        BOMInputStream

        +
        public BOMInputStream(InputStream delegate,
        +              ByteOrderMark... boms)
        +
        Constructs a new BOM InputStream that excludes the specified BOMs.
        +
        Parameters:
        delegate - the InputStream to delegate to
        boms - The BOMs to detect and exclude
        +
      • +
      + + + +
        +
      • +

        BOMInputStream

        +
        public BOMInputStream(InputStream delegate,
        +              boolean include,
        +              ByteOrderMark... boms)
        +
        Constructs a new BOM InputStream that detects the specified BOMs and optionally includes them.
        +
        Parameters:
        delegate - the InputStream to delegate to
        include - true to include the specified BOMs or false to exclude them
        boms - The BOMs to detect and optionally exclude
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        hasBOM

        +
        public boolean hasBOM()
        +               throws IOException
        +
        Indicates whether the stream contains one of the specified BOMs.
        +
        Returns:
        true if the stream has one of the specified BOMs, otherwise false if it does not
        +
        Throws:
        +
        IOException - if an error reading the first bytes of the stream occurs
        +
      • +
      + + + +
        +
      • +

        hasBOM

        +
        public boolean hasBOM(ByteOrderMark bom)
        +               throws IOException
        +
        Indicates whether the stream contains the specified BOM.
        +
        Parameters:
        bom - The BOM to check for
        +
        Returns:
        true if the stream has the specified BOM, otherwise false if it does not
        +
        Throws:
        +
        IllegalArgumentException - if the BOM is not one the stream is configured to detect
        +
        IOException - if an error reading the first bytes of the stream occurs
        +
      • +
      + + + +
        +
      • +

        getBOM

        +
        public ByteOrderMark getBOM()
        +                     throws IOException
        +
        Return the BOM (Byte Order Mark).
        +
        Returns:
        The BOM or null if none
        +
        Throws:
        +
        IOException - if an error reading the first bytes of the stream occurs
        +
      • +
      + + + + + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Invokes the delegate's read() method, detecting and optionally skipping BOM.
        +
        +
        Overrides:
        +
        read in class ProxyInputStream
        +
        Returns:
        the byte read (excluding BOM) or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] buf,
        +       int off,
        +       int len)
        +         throws IOException
        +
        Invokes the delegate's read(byte[], int, int) method, detecting and optionally skipping BOM.
        +
        +
        Overrides:
        +
        read in class ProxyInputStream
        +
        Parameters:
        buf - the buffer to read the bytes into
        off - The start offset
        len - The number of bytes to read (excluding BOM)
        +
        Returns:
        the number of bytes read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] buf)
        +         throws IOException
        +
        Invokes the delegate's read(byte[]) method, detecting and optionally skipping BOM.
        +
        +
        Overrides:
        +
        read in class ProxyInputStream
        +
        Parameters:
        buf - the buffer to read the bytes into
        +
        Returns:
        the number of bytes read (excluding BOM) or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        mark

        +
        public void mark(int readlimit)
        +
        Invokes the delegate's mark(int) method.
        +
        +
        Overrides:
        +
        mark in class ProxyInputStream
        +
        Parameters:
        readlimit - read ahead limit
        +
      • +
      + + + + + + + +
        +
      • +

        skip

        +
        public long skip(long n)
        +          throws IOException
        +
        Invokes the delegate's skip(long) method, detecting and optionallyskipping BOM.
        +
        +
        Overrides:
        +
        skip in class ProxyInputStream
        +
        Parameters:
        n - the number of bytes to skip
        +
        Returns:
        the number of bytes to skipped or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedInputStream.html" index 4ba7847c5c52b38f54b036c252ee954c3ca11d61..bf313613e7d7e021800fc045797d44dfcc48e0be 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedInputStream.html" @@ -1,3 +1,567 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:97b2f340aac28e60de726871e154382ba80047926b171f30223bd53be36f5801 -size 31338 + + + + + +BoundedInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class BoundedInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class BoundedInputStream
    +extends InputStream
    +
    This is a stream that will only supply bytes up to a certain length - if its + position goes above that, it will stop. +

    + This is useful to wrap ServletInputStreams. The ServletInputStream will block + if you try to read content from it that isn't there, because it doesn't know + whether the content hasn't arrived yet or whether the content has finished. + So, one of these, initialized with the Content-length sent in the + ServletInputStream's header, will stop it blocking, providing it's been sent + with a correct content length.

    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: BoundedInputStream.java 1586342 2014-04-10 15:36:29Z ggregory $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      BoundedInputStream(InputStream in) +
      Creates a new BoundedInputStream that wraps the given input + stream and is unlimited.
      +
      BoundedInputStream(InputStream in, + long size) +
      Creates a new BoundedInputStream that wraps the given input + stream and limits it to a certain size.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      intavailable()
      voidclose() +
      Invokes the delegate's close() method + if isPropagateClose() is true.
      +
      booleanisPropagateClose() +
      Indicates whether the close() method + should propagate to the underling InputStream.
      +
      voidmark(int readlimit) +
      Invokes the delegate's mark(int) method.
      +
      booleanmarkSupported() +
      Invokes the delegate's markSupported() method.
      +
      intread() +
      Invokes the delegate's read() method if + the current position is less than the limit.
      +
      intread(byte[] b) +
      Invokes the delegate's read(byte[]) method.
      +
      intread(byte[] b, + int off, + int len) +
      Invokes the delegate's read(byte[], int, int) method.
      +
      voidreset() +
      Invokes the delegate's reset() method.
      +
      voidsetPropagateClose(boolean propagateClose) +
      Set whether the close() method + should propagate to the underling InputStream.
      +
      longskip(long n) +
      Invokes the delegate's skip(long) method.
      +
      StringtoString() +
      Invokes the delegate's toString() method.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        BoundedInputStream

        +
        public BoundedInputStream(InputStream in,
        +                  long size)
        +
        Creates a new BoundedInputStream that wraps the given input + stream and limits it to a certain size.
        +
        Parameters:
        in - The wrapped input stream
        size - The maximum number of bytes to return
        +
      • +
      + + + +
        +
      • +

        BoundedInputStream

        +
        public BoundedInputStream(InputStream in)
        +
        Creates a new BoundedInputStream that wraps the given input + stream and is unlimited.
        +
        Parameters:
        in - The wrapped input stream
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Invokes the delegate's read() method if + the current position is less than the limit.
        +
        +
        Specified by:
        +
        read in class InputStream
        +
        Returns:
        the byte read or -1 if the end of stream or + the limit has been reached.
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] b)
        +         throws IOException
        +
        Invokes the delegate's read(byte[]) method.
        +
        +
        Overrides:
        +
        read in class InputStream
        +
        Parameters:
        b - the buffer to read the bytes into
        +
        Returns:
        the number of bytes read or -1 if the end of stream or + the limit has been reached.
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] b,
        +       int off,
        +       int len)
        +         throws IOException
        +
        Invokes the delegate's read(byte[], int, int) method.
        +
        +
        Overrides:
        +
        read in class InputStream
        +
        Parameters:
        b - the buffer to read the bytes into
        off - The start offset
        len - The number of bytes to read
        +
        Returns:
        the number of bytes read or -1 if the end of stream or + the limit has been reached.
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        skip

        +
        public long skip(long n)
        +          throws IOException
        +
        Invokes the delegate's skip(long) method.
        +
        +
        Overrides:
        +
        skip in class InputStream
        +
        Parameters:
        n - the number of bytes to skip
        +
        Returns:
        the actual number of bytes skipped
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Invokes the delegate's toString() method.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        the delegate's toString()
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        mark

        +
        public void mark(int readlimit)
        +
        Invokes the delegate's mark(int) method.
        +
        +
        Overrides:
        +
        mark in class InputStream
        +
        Parameters:
        readlimit - read ahead limit
        +
      • +
      + + + +
        +
      • +

        markSupported

        +
        public boolean markSupported()
        +
        Invokes the delegate's markSupported() method.
        +
        +
        Overrides:
        +
        markSupported in class InputStream
        +
        Returns:
        true if mark is supported, otherwise false
        +
      • +
      + + + +
        +
      • +

        isPropagateClose

        +
        public boolean isPropagateClose()
        +
        Indicates whether the close() method + should propagate to the underling InputStream.
        +
        Returns:
        true if calling close() + propagates to the close() method of the + underlying stream or false if it does not.
        +
      • +
      + + + +
        +
      • +

        setPropagateClose

        +
        public void setPropagateClose(boolean propagateClose)
        +
        Set whether the close() method + should propagate to the underling InputStream.
        +
        Parameters:
        propagateClose - true if calling + close() propagates to the close() + method of the underlying stream or + false if it does not.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedReader.html" index 5847a13c1b8524f8d62535e1961227197adea854..8023f7cfe8fc6ffc2f048c11db255d79a4e36246 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BoundedReader.html" @@ -1,3 +1,421 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6d9201720c8fc1c6de95202858e2d34125508d1163f0a916ea5a4d0b9408990a -size 22895 + + + + + +BoundedReader (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class BoundedReader

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable, Readable
    +
    +
    +
    +
    public class BoundedReader
    +extends Reader
    +
    A reader that imposes a limit to the number of characters that can be read from + an underlying reader, returning eof when this limit is reached -regardless of state of + underlying reader. + +

    + One use case is to avoid overrunning the readAheadLimit supplied to + java.io.Reader#mark(int), since reading too many characters removes the + ability to do a successful reset. +

    +
    Since:
    +
    2.5
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      BoundedReader(Reader target, + int maxCharsFromTargetReader) +
      Constructs a bounded reader
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidclose() +
      Closes the target
      +
      voidmark(int readAheadLimit) +
      marks the target stream, @see java.io.Reader#mark(int).
      +
      intread() +
      Reads a single character, @see java.io.Reader#read()
      +
      intread(char[] cbuf, + int off, + int len) +
      Reads into an array, @see java.io.Reader#read(char[], int, int)
      +
      voidreset() +
      Resets the target to the latest mark, @see java.io.Reader#reset()
      +
      + + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        BoundedReader

        +
        public BoundedReader(Reader target,
        +             int maxCharsFromTargetReader)
        +              throws IOException
        +
        Constructs a bounded reader
        +
        Parameters:
        target - The target stream that will be used
        maxCharsFromTargetReader - The maximum number of characters that can be read from target
        +
        Throws:
        +
        IOException - if mark fails
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + + + + + +
        +
      • +

        reset

        +
        public void reset()
        +           throws IOException
        +
        Resets the target to the latest mark, @see java.io.Reader#reset()
        +
        +
        Overrides:
        +
        reset in class Reader
        +
        Throws:
        +
        IOException - If an I/O error occurs while calling the underlying reader's reset method
        +
      • +
      + + + +
        +
      • +

        mark

        +
        public void mark(int readAheadLimit)
        +          throws IOException
        +
        marks the target stream, @see java.io.Reader#mark(int).
        +
        +
        Overrides:
        +
        mark in class Reader
        +
        Parameters:
        readAheadLimit - The number of characters that can be read while + still retaining the ability to do #reset(). + Note that this parameter is not validated with respect to + maxCharsFromTargetReader. There is no way to pass + past maxCharsFromTargetReader, even if this value is + greater.
        +
        Throws:
        +
        IOException - If an I/O error occurs while calling the underlying reader's mark method
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Reads a single character, @see java.io.Reader#read()
        +
        +
        Overrides:
        +
        read in class Reader
        +
        Returns:
        -1 on eof or the character read
        +
        Throws:
        +
        IOException - If an I/O error occurs while calling the underlying reader's read method
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(char[] cbuf,
        +       int off,
        +       int len)
        +         throws IOException
        +
        Reads into an array, @see java.io.Reader#read(char[], int, int)
        +
        +
        Specified by:
        +
        read in class Reader
        +
        Parameters:
        cbuf - The buffer to fill
        off - The offset
        len - The number of chars to read
        +
        Returns:
        the number of chars read
        +
        Throws:
        +
        IOException - If an I/O error occurs while calling the underlying reader's read method
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BrokenInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BrokenInputStream.html" index 2f9d8484bb4f94d7f8c05730040d6c1daa46c0aa..efbd53b823d676fdc10493e272406182bb4c2fbc 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BrokenInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/BrokenInputStream.html" @@ -1,3 +1,403 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:27602032df0af545fdb3efbc642a26a991453355e5cc008da297c1033191b771 -size 21356 + + + + + +BrokenInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class BrokenInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class BrokenInputStream
    +extends InputStream
    +
    Broken input stream. This stream always throws an IOException from + all the InputStream methods where the exception is declared. +

    + This class is mostly useful for testing error handling in code that uses an + input stream.

    +
    Since:
    +
    2.0
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        BrokenInputStream

        +
        public BrokenInputStream(IOException exception)
        +
        Creates a new stream that always throws the given exception.
        +
        Parameters:
        exception - the exception to be thrown
        +
      • +
      + + + +
        +
      • +

        BrokenInputStream

        +
        public BrokenInputStream()
        +
        Creates a new stream that always throws an IOException
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceInputStream.html" index b052b5e9a2756d6c68c34e898ad008c3a9ba1d0d..699e275145bd4d0bfeeca537487107ce3ff4e0de 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceInputStream.html" @@ -1,3 +1,513 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fa502a23eccb22660c9934e2ace150dc247b109109e5bf2745d88c0bdc4e2c33 -size 31214 + + + + + +CharSequenceInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class CharSequenceInputStream

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceReader.html" index 42235eb35cccc41c85b074541b02dc7c5277fbfe..1ca466e8a7344bdc7f3ccae43ee80065a649b446 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CharSequenceReader.html" @@ -1,3 +1,464 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e0d47b49c336b92b2ed9919347e2bf745fff6cb39ae41aabb166d0c6ba8da9e0 -size 23875 + + + + + +CharSequenceReader (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class CharSequenceReader

+
+
+ +
+ +
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      CharSequenceReader(CharSequence charSequence) +
      Construct a new instance with the specified character sequence.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidclose() +
      Close resets the file back to the start and removes any marked position.
      +
      voidmark(int readAheadLimit) +
      Mark the current position.
      +
      booleanmarkSupported() +
      Mark is supported (returns true).
      +
      intread() +
      Read a single character.
      +
      intread(char[] array, + int offset, + int length) +
      Read the sepcified number of characters into the array.
      +
      voidreset() +
      Reset the reader to the last marked position (or the beginning if + mark has not been called).
      +
      longskip(long n) +
      Skip the specified number of characters.
      +
      StringtoString() +
      Return a String representation of the underlying + character sequence.
      +
      + + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CharSequenceReader

        +
        public CharSequenceReader(CharSequence charSequence)
        +
        Construct a new instance with the specified character sequence.
        +
        Parameters:
        charSequence - The character sequence, may be null
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        close

        +
        public void close()
        +
        Close resets the file back to the start and removes any marked position.
        +
        +
        Specified by:
        +
        close in interface Closeable
        +
        Specified by:
        +
        close in interface AutoCloseable
        +
        Specified by:
        +
        close in class Reader
        +
        +
      • +
      + + + +
        +
      • +

        mark

        +
        public void mark(int readAheadLimit)
        +
        Mark the current position.
        +
        +
        Overrides:
        +
        mark in class Reader
        +
        Parameters:
        readAheadLimit - ignored
        +
      • +
      + + + +
        +
      • +

        markSupported

        +
        public boolean markSupported()
        +
        Mark is supported (returns true).
        +
        +
        Overrides:
        +
        markSupported in class Reader
        +
        Returns:
        true
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read()
        +
        Read a single character.
        +
        +
        Overrides:
        +
        read in class Reader
        +
        Returns:
        the next character from the character sequence + or -1 if the end has been reached.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(char[] array,
        +       int offset,
        +       int length)
        +
        Read the sepcified number of characters into the array.
        +
        +
        Specified by:
        +
        read in class Reader
        +
        Parameters:
        array - The array to store the characters in
        offset - The starting position in the array to store
        length - The maximum number of characters to read
        +
        Returns:
        The number of characters read or -1 if there are + no more
        +
      • +
      + + + +
        +
      • +

        reset

        +
        public void reset()
        +
        Reset the reader to the last marked position (or the beginning if + mark has not been called).
        +
        +
        Overrides:
        +
        reset in class Reader
        +
        +
      • +
      + + + +
        +
      • +

        skip

        +
        public long skip(long n)
        +
        Skip the specified number of characters.
        +
        +
        Overrides:
        +
        skip in class Reader
        +
        Parameters:
        n - The number of characters to skip
        +
        Returns:
        The actual number of characters skipped
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Return a String representation of the underlying + character sequence.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        The contents of the character sequence
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClassLoaderObjectInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClassLoaderObjectInputStream.html" index 6e0e2d8f99a64b315726c12ae941f9d2f480613d..04e743e04fb4afc5dd7f56d9555eff767cf30bc0 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClassLoaderObjectInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClassLoaderObjectInputStream.html" @@ -1,3 +1,385 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0da3005db0388ec302cb7b8652eddaca0085bdbea5a5454921bee30c2a52427c -size 33848 + + + + + +ClassLoaderObjectInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class ClassLoaderObjectInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, DataInput, ObjectInput, ObjectStreamConstants, AutoCloseable
    +
    +
    +
    +
    public class ClassLoaderObjectInputStream
    +extends ObjectInputStream
    +
    A special ObjectInputStream that loads a class based on a specified + ClassLoader rather than the system default. +

    + This is useful in dynamic container environments.

    +
    Since:
    +
    1.1
    +
    Version:
    +
    $Id: ClassLoaderObjectInputStream.java 1471767 2013-04-24 23:24:19Z sebb $
    +
  • +
+
+
+ +
+
+ +
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CloseShieldInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CloseShieldInputStream.html" index 3d61c5ba8d0a8fa5bc4aef25ec4a2cd377cbbf78..e145eca75cddfd0d8ccc083669e15063c54aee36 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CloseShieldInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CloseShieldInputStream.html" @@ -1,3 +1,326 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2657c79078148efaed9856fb767cddd885d03c854024d1735bf6a566121523a5 -size 16839 + + + + + +CloseShieldInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class CloseShieldInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class CloseShieldInputStream
    +extends ProxyInputStream
    +
    Proxy stream that prevents the underlying input stream from being closed. +

    + This class is typically used in cases where an input stream needs to be + passed to a component that wants to explicitly close the stream even if + more input would still be available to other components.

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: CloseShieldInputStream.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CloseShieldInputStream

        +
        public CloseShieldInputStream(InputStream in)
        +
        Creates a proxy that shields the given input stream from being + closed.
        +
        Parameters:
        in - underlying input stream
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClosedInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClosedInputStream.html" index 6e597228b544bbd49e54b31a14412aed5d22ac7f..37389939e2d90db1b7da877d5781ee7779826068 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClosedInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ClosedInputStream.html" @@ -1,3 +1,328 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e9dd06b30a5deafa4a71db6b6ec0a5ee52a19d9a27f6661fb45533a4bd216f2b -size 15463 + + + + + +ClosedInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class ClosedInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class ClosedInputStream
    +extends InputStream
    +
    Closed input stream. This stream returns EOF to all attempts to read + something from the stream. +

    + Typically uses of this class include testing for corner cases in methods + that accept input streams and acting as a sentinel value instead of a + null input stream.

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: ClosedInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        CLOSED_INPUT_STREAM

        +
        public static final ClosedInputStream CLOSED_INPUT_STREAM
        +
        A singleton.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ClosedInputStream

        +
        public ClosedInputStream()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        read

        +
        public int read()
        +
        Returns -1 to indicate that the stream is closed.
        +
        +
        Specified by:
        +
        read in class InputStream
        +
        Returns:
        always -1
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CountingInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CountingInputStream.html" index a805ae345b1ea7c69d60712f95e10682c69ea6e9..13f62cae6e1801d0ffd8f9b3fbf7d0e45aa54be3 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CountingInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/CountingInputStream.html" @@ -1,3 +1,432 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7712c645bdce0b7c454f3af5597909838589f1d1d0e306d9aea75513afdeba5f -size 21526 + + + + + +CountingInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class CountingInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class CountingInputStream
    +extends ProxyInputStream
    +
    A decorating input stream that counts the number of bytes that have passed + through the stream so far. +

    + A typical use case would be during debugging, to ensure that data is being + read as expected.

    +
    Version:
    +
    $Id: CountingInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CountingInputStream

        +
        public CountingInputStream(InputStream in)
        +
        Constructs a new CountingInputStream.
        +
        Parameters:
        in - the InputStream to delegate to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        skip

        +
        public long skip(long length)
        +          throws IOException
        +
        Skips the stream over the specified number of bytes, adding the skipped + amount to the count.
        +
        +
        Overrides:
        +
        skip in class ProxyInputStream
        +
        Parameters:
        length - the number of bytes to skip
        +
        Returns:
        the actual number of bytes skipped
        +
        Throws:
        +
        IOException - if an I/O error occurs
        See Also:
        InputStream.skip(long)
        +
      • +
      + + + +
        +
      • +

        afterRead

        +
        protected void afterRead(int n)
        +
        Adds the number of read bytes to the count.
        +
        +
        Overrides:
        +
        afterRead in class ProxyInputStream
        +
        Parameters:
        n - number of bytes read, or -1 if no more bytes are available
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        getCount

        +
        public int getCount()
        +
        The number of bytes that have passed through this stream. +

        + NOTE: From v1.3 this method throws an ArithmeticException if the + count is greater than can be expressed by an int. + See getByteCount() for a method using a long.

        +
        Returns:
        the number of bytes accumulated
        +
        Throws:
        +
        ArithmeticException - if the byte count is too large
        +
      • +
      + + + +
        +
      • +

        resetCount

        +
        public int resetCount()
        +
        Set the byte count back to 0. +

        + NOTE: From v1.3 this method throws an ArithmeticException if the + count is greater than can be expressed by an int. + See resetByteCount() for a method using a long.

        +
        Returns:
        the count previous to resetting
        +
        Throws:
        +
        ArithmeticException - if the byte count is too large
        +
      • +
      + + + +
        +
      • +

        getByteCount

        +
        public long getByteCount()
        +
        The number of bytes that have passed through this stream. +

        + NOTE: This method is an alternative for getCount() + and was added because that method returns an integer which will + result in incorrect count for files over 2GB.

        +
        Returns:
        the number of bytes accumulated
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        resetByteCount

        +
        public long resetByteCount()
        +
        Set the byte count back to 0. +

        + NOTE: This method is an alternative for resetCount() + and was added because that method returns an integer which will + result in incorrect count for files over 2GB.

        +
        Returns:
        the count previous to resetting
        Since:
        +
        1.3
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/DemuxInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/DemuxInputStream.html" index fff5d86f100a8cf5a724d3bf951002a62d79ebe4..1f9f799e3404eb4beed33e093a3a9ffa5cea5121 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/DemuxInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/DemuxInputStream.html" @@ -1,3 +1,330 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6f700e7eaab17f057a0536b95920e23bc339214ec5428bd945733054aad45f3d -size 17329 + + + + + +DemuxInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class DemuxInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class DemuxInputStream
    +extends InputStream
    +
    Data written to this stream is forwarded to a stream that has been associated + with this thread.
    +
    Version:
    +
    $Id: DemuxInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DemuxInputStream

        +
        public DemuxInputStream()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        bindStream

        +
        public InputStream bindStream(InputStream input)
        +
        Bind the specified stream to the current thread.
        +
        Parameters:
        input - the stream to bind
        +
        Returns:
        the InputStream that was previously active
        +
      • +
      + + + + + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Read byte from stream associated with current thread.
        +
        +
        Specified by:
        +
        read in class InputStream
        +
        Returns:
        the byte read from stream
        +
        Throws:
        +
        IOException - if an error occurs
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullInputStream.html" index 2ad6c27a7f0ddf89abba13c522c11bd13569d6be..4c253289e222daa2c64745cb8bf9cc1234fdec53 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullInputStream.html" @@ -1,3 +1,631 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:db05d2353dfb5bed0a43cf661205e21559654ed7f97cc30b52abb330e79f49b7 -size 33346 + + + + + +NullInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class NullInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class NullInputStream
    +extends InputStream
    +
    A functional, light weight InputStream that emulates + a stream of a specified size. +

    + This implementation provides a light weight + object for testing with an InputStream + where the contents don't matter. +

    + One use case would be for testing the handling of + large InputStream as it can emulate that + scenario without the overhead of actually processing + large numbers of bytes - significantly speeding up + test execution times. +

    + This implementation returns zero from the method that + reads a byte and leaves the array unchanged in the read + methods that are passed a byte array. + If alternative data is required the processByte() and + processBytes() methods can be implemented to generate + data, for example: + +

    +  public class TestInputStream extends NullInputStream {
    +      public TestInputStream(int size) {
    +          super(size);
    +      }
    +      protected int processByte() {
    +          return ... // return required value here
    +      }
    +      protected void processBytes(byte[] bytes, int offset, int length) {
    +          for (int i = offset; i < length; i++) {
    +              bytes[i] = ... // set array value here
    +          }
    +      }
    +  }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: NullInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      NullInputStream(long size) +
      Create an InputStream that emulates a specified size + which supports marking and does not throw EOFException.
      +
      NullInputStream(long size, + boolean markSupported, + boolean throwEofException) +
      Create an InputStream that emulates a specified + size with option settings.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      intavailable() +
      Return the number of bytes that can be read.
      +
      voidclose() +
      Close this input stream - resets the internal state to + the initial values.
      +
      longgetPosition() +
      Return the current position.
      +
      longgetSize() +
      Return the size this InputStream emulates.
      +
      voidmark(int readlimit) +
      Mark the current position.
      +
      booleanmarkSupported() +
      Indicates whether mark is supported.
      +
      protected intprocessByte() +
      Return a byte value for the read() method.
      +
      protected voidprocessBytes(byte[] bytes, + int offset, + int length) +
      Process the bytes for the read(byte[], offset, length) + method.
      +
      intread() +
      Read a byte.
      +
      intread(byte[] bytes) +
      Read some bytes into the specified array.
      +
      intread(byte[] bytes, + int offset, + int length) +
      Read the specified number bytes into an array.
      +
      voidreset() +
      Reset the stream to the point when mark was last called.
      +
      longskip(long numberOfBytes) +
      Skip a specified number of bytes.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NullInputStream

        +
        public NullInputStream(long size)
        +
        Create an InputStream that emulates a specified size + which supports marking and does not throw EOFException.
        +
        Parameters:
        size - The size of the input stream to emulate.
        +
      • +
      + + + +
        +
      • +

        NullInputStream

        +
        public NullInputStream(long size,
        +               boolean markSupported,
        +               boolean throwEofException)
        +
        Create an InputStream that emulates a specified + size with option settings.
        +
        Parameters:
        size - The size of the input stream to emulate.
        markSupported - Whether this instance will support + the mark() functionality.
        throwEofException - Whether this implementation + will throw an EOFException or return -1 when the + end of file is reached.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getPosition

        +
        public long getPosition()
        +
        Return the current position.
        +
        Returns:
        the current position.
        +
      • +
      + + + +
        +
      • +

        getSize

        +
        public long getSize()
        +
        Return the size this InputStream emulates.
        +
        Returns:
        The size of the input stream to emulate.
        +
      • +
      + + + +
        +
      • +

        available

        +
        public int available()
        +
        Return the number of bytes that can be read.
        +
        +
        Overrides:
        +
        available in class InputStream
        +
        Returns:
        The number of bytes that can be read.
        +
      • +
      + + + + + + + +
        +
      • +

        mark

        +
        public void mark(int readlimit)
        +
        Mark the current position.
        +
        +
        Overrides:
        +
        mark in class InputStream
        +
        Parameters:
        readlimit - The number of bytes before this marked position + is invalid.
        +
        Throws:
        +
        UnsupportedOperationException - if mark is not supported.
        +
      • +
      + + + +
        +
      • +

        markSupported

        +
        public boolean markSupported()
        +
        Indicates whether mark is supported.
        +
        +
        Overrides:
        +
        markSupported in class InputStream
        +
        Returns:
        Whether mark is supported or not.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Read a byte.
        +
        +
        Specified by:
        +
        read in class InputStream
        +
        Returns:
        Either The byte value returned by processByte() + or -1 if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] bytes)
        +         throws IOException
        +
        Read some bytes into the specified array.
        +
        +
        Overrides:
        +
        read in class InputStream
        +
        Parameters:
        bytes - The byte array to read into
        +
        Returns:
        The number of bytes read or -1 + if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] bytes,
        +       int offset,
        +       int length)
        +         throws IOException
        +
        Read the specified number bytes into an array.
        +
        +
        Overrides:
        +
        read in class InputStream
        +
        Parameters:
        bytes - The byte array to read into.
        offset - The offset to start reading bytes into.
        length - The number of bytes to read.
        +
        Returns:
        The number of bytes read or -1 + if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        reset

        +
        public void reset()
        +           throws IOException
        +
        Reset the stream to the point when mark was last called.
        +
        +
        Overrides:
        +
        reset in class InputStream
        +
        Throws:
        +
        UnsupportedOperationException - if mark is not supported.
        +
        IOException - If no position has been marked + or the read limit has been exceed since the last position was + marked.
        +
      • +
      + + + +
        +
      • +

        skip

        +
        public long skip(long numberOfBytes)
        +          throws IOException
        +
        Skip a specified number of bytes.
        +
        +
        Overrides:
        +
        skip in class InputStream
        +
        Parameters:
        numberOfBytes - The number of bytes to skip.
        +
        Returns:
        The number of bytes skipped or -1 + if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        processByte

        +
        protected int processByte()
        +
        Return a byte value for the read() method. +

        + This implementation returns zero.

        +
        Returns:
        This implementation always returns zero.
        +
      • +
      + + + +
        +
      • +

        processBytes

        +
        protected void processBytes(byte[] bytes,
        +                int offset,
        +                int length)
        +
        Process the bytes for the read(byte[], offset, length) + method. +

        + This implementation leaves the byte array unchanged.

        +
        Parameters:
        bytes - The byte array
        offset - The offset to start at.
        length - The number of bytes.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullReader.html" index c04e9c835f4a5546541584f88695d435b7a5117a..940ecee5e9ab644126a3d7caa911fd032017764a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/NullReader.html" @@ -1,3 +1,633 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c5f7fdc71c3bc590d436de00f1a70d742775d54681a79f0d0dde9adceb6b64f0 -size 33523 + + + + + +NullReader (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class NullReader

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable, Readable
    +
    +
    +
    +
    public class NullReader
    +extends Reader
    +
    A functional, light weight Reader that emulates + a reader of a specified size. +

    + This implementation provides a light weight + object for testing with an Reader + where the contents don't matter. +

    + One use case would be for testing the handling of + large Reader as it can emulate that + scenario without the overhead of actually processing + large numbers of characters - significantly speeding up + test execution times. +

    + This implementation returns a space from the method that + reads a character and leaves the array unchanged in the read + methods that are passed a character array. + If alternative data is required the processChar() and + processChars() methods can be implemented to generate + data, for example: + +

    +  public class TestReader extends NullReader {
    +      public TestReader(int size) {
    +          super(size);
    +      }
    +      protected char processChar() {
    +          return ... // return required value here
    +      }
    +      protected void processChars(char[] chars, int offset, int length) {
    +          for (int i = offset; i < length; i++) {
    +              chars[i] = ... // set array value here
    +          }
    +      }
    +  }
    + 
    +
    Since:
    +
    1.3
    +
    Version:
    +
    $Id: NullReader.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      NullReader(long size) +
      Create a Reader that emulates a specified size + which supports marking and does not throw EOFException.
      +
      NullReader(long size, + boolean markSupported, + boolean throwEofException) +
      Create a Reader that emulates a specified + size with option settings.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidclose() +
      Close this Reader - resets the internal state to + the initial values.
      +
      longgetPosition() +
      Return the current position.
      +
      longgetSize() +
      Return the size this Reader emulates.
      +
      voidmark(int readlimit) +
      Mark the current position.
      +
      booleanmarkSupported() +
      Indicates whether mark is supported.
      +
      protected intprocessChar() +
      Return a character value for the read() method.
      +
      protected voidprocessChars(char[] chars, + int offset, + int length) +
      Process the characters for the read(char[], offset, length) + method.
      +
      intread() +
      Read a character.
      +
      intread(char[] chars) +
      Read some characters into the specified array.
      +
      intread(char[] chars, + int offset, + int length) +
      Read the specified number characters into an array.
      +
      voidreset() +
      Reset the stream to the point when mark was last called.
      +
      longskip(long numberOfChars) +
      Skip a specified number of characters.
      +
      + + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NullReader

        +
        public NullReader(long size)
        +
        Create a Reader that emulates a specified size + which supports marking and does not throw EOFException.
        +
        Parameters:
        size - The size of the reader to emulate.
        +
      • +
      + + + +
        +
      • +

        NullReader

        +
        public NullReader(long size,
        +          boolean markSupported,
        +          boolean throwEofException)
        +
        Create a Reader that emulates a specified + size with option settings.
        +
        Parameters:
        size - The size of the reader to emulate.
        markSupported - Whether this instance will support + the mark() functionality.
        throwEofException - Whether this implementation + will throw an EOFException or return -1 when the + end of file is reached.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getPosition

        +
        public long getPosition()
        +
        Return the current position.
        +
        Returns:
        the current position.
        +
      • +
      + + + +
        +
      • +

        getSize

        +
        public long getSize()
        +
        Return the size this Reader emulates.
        +
        Returns:
        The size of the reader to emulate.
        +
      • +
      + + + + + + + +
        +
      • +

        mark

        +
        public void mark(int readlimit)
        +
        Mark the current position.
        +
        +
        Overrides:
        +
        mark in class Reader
        +
        Parameters:
        readlimit - The number of characters before this marked position + is invalid.
        +
        Throws:
        +
        UnsupportedOperationException - if mark is not supported.
        +
      • +
      + + + +
        +
      • +

        markSupported

        +
        public boolean markSupported()
        +
        Indicates whether mark is supported.
        +
        +
        Overrides:
        +
        markSupported in class Reader
        +
        Returns:
        Whether mark is supported or not.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Read a character.
        +
        +
        Overrides:
        +
        read in class Reader
        +
        Returns:
        Either The character value returned by processChar() + or -1 if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(char[] chars)
        +         throws IOException
        +
        Read some characters into the specified array.
        +
        +
        Overrides:
        +
        read in class Reader
        +
        Parameters:
        chars - The character array to read into
        +
        Returns:
        The number of characters read or -1 + if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(char[] chars,
        +       int offset,
        +       int length)
        +         throws IOException
        +
        Read the specified number characters into an array.
        +
        +
        Specified by:
        +
        read in class Reader
        +
        Parameters:
        chars - The character array to read into.
        offset - The offset to start reading characters into.
        length - The number of characters to read.
        +
        Returns:
        The number of characters read or -1 + if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        reset

        +
        public void reset()
        +           throws IOException
        +
        Reset the stream to the point when mark was last called.
        +
        +
        Overrides:
        +
        reset in class Reader
        +
        Throws:
        +
        UnsupportedOperationException - if mark is not supported.
        +
        IOException - If no position has been marked + or the read limit has been exceed since the last position was + marked.
        +
      • +
      + + + +
        +
      • +

        skip

        +
        public long skip(long numberOfChars)
        +          throws IOException
        +
        Skip a specified number of characters.
        +
        +
        Overrides:
        +
        skip in class Reader
        +
        Parameters:
        numberOfChars - The number of characters to skip.
        +
        Returns:
        The number of characters skipped or -1 + if the end of file has been reached and + throwEofException is set to false.
        +
        Throws:
        +
        EOFException - if the end of file is reached and + throwEofException is set to true.
        +
        IOException - if trying to read past the end of file.
        +
      • +
      + + + +
        +
      • +

        processChar

        +
        protected int processChar()
        +
        Return a character value for the read() method. +

        + This implementation returns zero.

        +
        Returns:
        This implementation always returns zero.
        +
      • +
      + + + +
        +
      • +

        processChars

        +
        protected void processChars(char[] chars,
        +                int offset,
        +                int length)
        +
        Process the characters for the read(char[], offset, length) + method. +

        + This implementation leaves the character array unchanged.

        +
        Parameters:
        chars - The character array
        offset - The offset to start at.
        length - The number of characters.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyInputStream.html" index 039b4f7dab1b8f03b63ffd89e7af46a9ae4a2291..f1bd83b90387e9e2e31e32c0fe74d241b11a8236 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyInputStream.html" @@ -1,3 +1,590 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5751422bbc4c67ea7dbcdc2d99d7a85eb4aff688263b2e7e2e49dc8f13a8607a -size 33334 + + + + + +ProxyInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class ProxyInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    Direct Known Subclasses:
    +
    AutoCloseInputStream, BOMInputStream, CloseShieldInputStream, CountingInputStream, SwappedDataInputStream, TaggedInputStream, TeeInputStream
    +
    +
    +
    +
    public abstract class ProxyInputStream
    +extends FilterInputStream
    +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called. +

    + It is an alternative base class to FilterInputStream + to increase reusability, because FilterInputStream changes the + methods being called, such as read(byte[]) to read(byte[], int, int). +

    + See the protected methods for ways in which a subclass can easily decorate + a stream with custom pre-, post- or error processing functionality.

    +
    Version:
    +
    $Id: ProxyInputStream.java 1603493 2014-06-18 15:46:07Z ggregory $
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ProxyInputStream(InputStream proxy) +
      Constructs a new ProxyInputStream.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      protected voidafterRead(int n) +
      Invoked by the read methods after the proxied call has returned + successfully.
      +
      intavailable() +
      Invokes the delegate's available() method.
      +
      protected voidbeforeRead(int n) +
      Invoked by the read methods before the call is proxied.
      +
      voidclose() +
      Invokes the delegate's close() method.
      +
      protected voidhandleIOException(IOException e) +
      Handle any IOExceptions thrown.
      +
      voidmark(int readlimit) +
      Invokes the delegate's mark(int) method.
      +
      booleanmarkSupported() +
      Invokes the delegate's markSupported() method.
      +
      intread() +
      Invokes the delegate's read() method.
      +
      intread(byte[] bts) +
      Invokes the delegate's read(byte[]) method.
      +
      intread(byte[] bts, + int off, + int len) +
      Invokes the delegate's read(byte[], int, int) method.
      +
      voidreset() +
      Invokes the delegate's reset() method.
      +
      longskip(long ln) +
      Invokes the delegate's skip(long) method.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ProxyInputStream

        +
        public ProxyInputStream(InputStream proxy)
        +
        Constructs a new ProxyInputStream.
        +
        Parameters:
        proxy - the InputStream to delegate to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Invokes the delegate's read() method.
        +
        +
        Overrides:
        +
        read in class FilterInputStream
        +
        Returns:
        the byte read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] bts)
        +         throws IOException
        +
        Invokes the delegate's read(byte[]) method.
        +
        +
        Overrides:
        +
        read in class FilterInputStream
        +
        Parameters:
        bts - the buffer to read the bytes into
        +
        Returns:
        the number of bytes read or EOF if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] bts,
        +       int off,
        +       int len)
        +         throws IOException
        +
        Invokes the delegate's read(byte[], int, int) method.
        +
        +
        Overrides:
        +
        read in class FilterInputStream
        +
        Parameters:
        bts - the buffer to read the bytes into
        off - The start offset
        len - The number of bytes to read
        +
        Returns:
        the number of bytes read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        skip

        +
        public long skip(long ln)
        +          throws IOException
        +
        Invokes the delegate's skip(long) method.
        +
        +
        Overrides:
        +
        skip in class FilterInputStream
        +
        Parameters:
        ln - the number of bytes to skip
        +
        Returns:
        the actual number of bytes skipped
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        available

        +
        public int available()
        +              throws IOException
        +
        Invokes the delegate's available() method.
        +
        +
        Overrides:
        +
        available in class FilterInputStream
        +
        Returns:
        the number of available bytes
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + +
        +
      • +

        mark

        +
        public void mark(int readlimit)
        +
        Invokes the delegate's mark(int) method.
        +
        +
        Overrides:
        +
        mark in class FilterInputStream
        +
        Parameters:
        readlimit - read ahead limit
        +
      • +
      + + + + + + + +
        +
      • +

        markSupported

        +
        public boolean markSupported()
        +
        Invokes the delegate's markSupported() method.
        +
        +
        Overrides:
        +
        markSupported in class FilterInputStream
        +
        Returns:
        true if mark is supported, otherwise false
        +
      • +
      + + + +
        +
      • +

        beforeRead

        +
        protected void beforeRead(int n)
        +                   throws IOException
        +
        Invoked by the read methods before the call is proxied. The number + of bytes that the caller wanted to read (1 for the read() + method, buffer length for read(byte[]), etc.) is given as + an argument. +

        + Subclasses can override this method to add common pre-processing + functionality without having to override all the read methods. + The default implementation does nothing. +

        + Note this method is not called from skip(long) or + reset(). You need to explicitly override those methods if + you want to add pre-processing steps also to them.

        +
        Parameters:
        n - number of bytes that the caller asked to be read
        +
        Throws:
        +
        IOException - if the pre-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        afterRead

        +
        protected void afterRead(int n)
        +                  throws IOException
        +
        Invoked by the read methods after the proxied call has returned + successfully. The number of bytes returned to the caller (or -1 if + the end of stream was reached) is given as an argument. +

        + Subclasses can override this method to add common post-processing + functionality without having to override all the read methods. + The default implementation does nothing. +

        + Note this method is not called from skip(long) or + reset(). You need to explicitly override those methods if + you want to add post-processing steps also to them.

        +
        Parameters:
        n - number of bytes read, or -1 if the end of stream was reached
        +
        Throws:
        +
        IOException - if the post-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        handleIOException

        +
        protected void handleIOException(IOException e)
        +                          throws IOException
        +
        Handle any IOExceptions thrown. +

        + This method provides a point to implement custom exception + handling. The default behaviour is to re-throw the exception.

        +
        Parameters:
        e - The IOException thrown
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyReader.html" index e19271d37ae594b6c1e6519940fb6904b923e4aa..2d7fc0684f0a76f44ef5619f105bcad6a8e2f72d 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ProxyReader.html" @@ -1,3 +1,620 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5cd9c7c9811afadbc1ac57c13728fe63eab2787e7e9b19732a7c3b1979fc0b7e -size 35092 + + + + + +ProxyReader (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class ProxyReader

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable, Readable
    +
    +
    +
    +
    public abstract class ProxyReader
    +extends FilterReader
    +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called. +

    + It is an alternative base class to FilterReader + to increase reusability, because FilterReader changes the + methods being called, such as read(char[]) to read(char[], int, int).

    +
    Version:
    +
    $Id: ProxyReader.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ProxyReader(Reader proxy) +
      Constructs a new ProxyReader.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      protected voidafterRead(int n) +
      Invoked by the read methods after the proxied call has returned + successfully.
      +
      protected voidbeforeRead(int n) +
      Invoked by the read methods before the call is proxied.
      +
      voidclose() +
      Invokes the delegate's close() method.
      +
      protected voidhandleIOException(IOException e) +
      Handle any IOExceptions thrown.
      +
      voidmark(int idx) +
      Invokes the delegate's mark(int) method.
      +
      booleanmarkSupported() +
      Invokes the delegate's markSupported() method.
      +
      intread() +
      Invokes the delegate's read() method.
      +
      intread(char[] chr) +
      Invokes the delegate's read(char[]) method.
      +
      intread(char[] chr, + int st, + int len) +
      Invokes the delegate's read(char[], int, int) method.
      +
      intread(CharBuffer target) +
      Invokes the delegate's read(CharBuffer) method.
      +
      booleanready() +
      Invokes the delegate's ready() method.
      +
      voidreset() +
      Invokes the delegate's reset() method.
      +
      longskip(long ln) +
      Invokes the delegate's skip(long) method.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ProxyReader

        +
        public ProxyReader(Reader proxy)
        +
        Constructs a new ProxyReader.
        +
        Parameters:
        proxy - the Reader to delegate to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Invokes the delegate's read() method.
        +
        +
        Overrides:
        +
        read in class FilterReader
        +
        Returns:
        the character read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(char[] chr)
        +         throws IOException
        +
        Invokes the delegate's read(char[]) method.
        +
        +
        Overrides:
        +
        read in class Reader
        +
        Parameters:
        chr - the buffer to read the characters into
        +
        Returns:
        the number of characters read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(char[] chr,
        +       int st,
        +       int len)
        +         throws IOException
        +
        Invokes the delegate's read(char[], int, int) method.
        +
        +
        Overrides:
        +
        read in class FilterReader
        +
        Parameters:
        chr - the buffer to read the characters into
        st - The start offset
        len - The number of bytes to read
        +
        Returns:
        the number of characters read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(CharBuffer target)
        +         throws IOException
        +
        Invokes the delegate's read(CharBuffer) method.
        +
        +
        Specified by:
        +
        read in interface Readable
        +
        Overrides:
        +
        read in class Reader
        +
        Parameters:
        target - the char buffer to read the characters into
        +
        Returns:
        the number of characters read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        skip

        +
        public long skip(long ln)
        +          throws IOException
        +
        Invokes the delegate's skip(long) method.
        +
        +
        Overrides:
        +
        skip in class FilterReader
        +
        Parameters:
        ln - the number of bytes to skip
        +
        Returns:
        the number of bytes to skipped or EOF if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        ready

        +
        public boolean ready()
        +              throws IOException
        +
        Invokes the delegate's ready() method.
        +
        +
        Overrides:
        +
        ready in class FilterReader
        +
        Returns:
        true if the stream is ready to be read
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + +
        +
      • +

        mark

        +
        public void mark(int idx)
        +          throws IOException
        +
        Invokes the delegate's mark(int) method.
        +
        +
        Overrides:
        +
        mark in class FilterReader
        +
        Parameters:
        idx - read ahead limit
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + +
        +
      • +

        markSupported

        +
        public boolean markSupported()
        +
        Invokes the delegate's markSupported() method.
        +
        +
        Overrides:
        +
        markSupported in class FilterReader
        +
        Returns:
        true if mark is supported, otherwise false
        +
      • +
      + + + +
        +
      • +

        beforeRead

        +
        protected void beforeRead(int n)
        +                   throws IOException
        +
        Invoked by the read methods before the call is proxied. The number + of chars that the caller wanted to read (1 for the read() + method, buffer length for read(char[]), etc.) is given as + an argument. +

        + Subclasses can override this method to add common pre-processing + functionality without having to override all the read methods. + The default implementation does nothing. +

        + Note this method is not called from skip(long) or + reset(). You need to explicitly override those methods if + you want to add pre-processing steps also to them.

        +
        Parameters:
        n - number of chars that the caller asked to be read
        +
        Throws:
        +
        IOException - if the pre-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        afterRead

        +
        protected void afterRead(int n)
        +                  throws IOException
        +
        Invoked by the read methods after the proxied call has returned + successfully. The number of chars returned to the caller (or -1 if + the end of stream was reached) is given as an argument. +

        + Subclasses can override this method to add common post-processing + functionality without having to override all the read methods. + The default implementation does nothing. +

        + Note this method is not called from skip(long) or + reset(). You need to explicitly override those methods if + you want to add post-processing steps also to them.

        +
        Parameters:
        n - number of chars read, or -1 if the end of stream was reached
        +
        Throws:
        +
        IOException - if the post-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        handleIOException

        +
        protected void handleIOException(IOException e)
        +                          throws IOException
        +
        Handle any IOExceptions thrown. +

        + This method provides a point to implement custom exception + handling. The default behaviour is to re-throw the exception.

        +
        Parameters:
        e - The IOException thrown
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReaderInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReaderInputStream.html" index da0207c26d7674c3878aa7c258d1f0503c21132a..871c725a504fce496db93954312bb22fbcc95dd0 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReaderInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReaderInputStream.html" @@ -1,3 +1,538 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:29f43224f0fb09afb2bcd925a757d81db2f7a2e96c2bd5faae21c7a492c8e77d -size 38688 + + + + + +ReaderInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class ReaderInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class ReaderInputStream
    +extends InputStream
    +
    InputStream implementation that reads a character stream from a Reader + and transforms it to a byte stream using a specified charset encoding. The stream + is transformed using a CharsetEncoder object, guaranteeing that all charset + encodings supported by the JRE are handled correctly. In particular for charsets such as + UTF-16, the implementation ensures that one and only one byte order marker + is produced. +

    + Since in general it is not possible to predict the number of characters to be read from the + Reader to satisfy a read request on the ReaderInputStream, all reads from + the Reader are buffered. There is therefore no well defined correlation + between the current position of the Reader and that of the ReaderInputStream. + This also implies that in general there is no need to wrap the underlying Reader + in a BufferedReader. +

    + ReaderInputStream implements the inverse transformation of InputStreamReader; + in the following example, reading from in2 would return the same byte + sequence as reading from in (provided that the initial byte sequence is legal + with respect to the charset encoding): +

    + InputStream in = ...
    + Charset cs = ...
    + InputStreamReader reader = new InputStreamReader(in, cs);
    + ReaderInputStream in2 = new ReaderInputStream(reader, cs);
    + ReaderInputStream implements the same transformation as OutputStreamWriter, + except that the control flow is reversed: both classes transform a character stream + into a byte stream, but OutputStreamWriter pushes data to the underlying stream, + while ReaderInputStream pulls it from the underlying stream. +

    + Note that while there are use cases where there is no alternative to using + this class, very often the need to use this class is an indication of a flaw + in the design of the code. This class is typically used in situations where an existing + API only accepts an InputStream, but where the most natural way to produce the data + is as a character stream, i.e. by providing a Reader instance. An example of a situation + where this problem may appear is when implementing the DataSource + interface from the Java Activation Framework. +

    + Given the fact that the Reader class doesn't provide any way to predict whether the next + read operation will block or not, it is not possible to provide a meaningful + implementation of the InputStream.available() method. A call to this method + will always return 0. Also, this class doesn't support InputStream.mark(int). +

    + Instances of ReaderInputStream are not thread safe.

    +
    Since:
    +
    2.0
    +
    See Also:
    WriterOutputStream
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + + + + + +
        +
      • +

        ReaderInputStream

        +
        public ReaderInputStream(Reader reader,
        +                 CharsetEncoder encoder,
        +                 int bufferSize)
        +
        Construct a new ReaderInputStream.
        +
        Parameters:
        reader - the target Reader
        encoder - the charset encoder
        bufferSize - the size of the input buffer in number of characters
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        ReaderInputStream

        +
        public ReaderInputStream(Reader reader,
        +                 Charset charset,
        +                 int bufferSize)
        +
        Construct a new ReaderInputStream.
        +
        Parameters:
        reader - the target Reader
        charset - the charset encoding
        bufferSize - the size of the input buffer in number of characters
        +
      • +
      + + + +
        +
      • +

        ReaderInputStream

        +
        public ReaderInputStream(Reader reader,
        +                 Charset charset)
        +
        Construct a new ReaderInputStream with a default input buffer size of + 1024 characters.
        +
        Parameters:
        reader - the target Reader
        charset - the charset encoding
        +
      • +
      + + + +
        +
      • +

        ReaderInputStream

        +
        public ReaderInputStream(Reader reader,
        +                 String charsetName,
        +                 int bufferSize)
        +
        Construct a new ReaderInputStream.
        +
        Parameters:
        reader - the target Reader
        charsetName - the name of the charset encoding
        bufferSize - the size of the input buffer in number of characters
        +
      • +
      + + + +
        +
      • +

        ReaderInputStream

        +
        public ReaderInputStream(Reader reader,
        +                 String charsetName)
        +
        Construct a new ReaderInputStream with a default input buffer size of + 1024 characters.
        +
        Parameters:
        reader - the target Reader
        charsetName - the name of the charset encoding
        +
      • +
      + + + + +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        read

        +
        public int read(byte[] b,
        +       int off,
        +       int len)
        +         throws IOException
        +
        Read the specified number of bytes into an array.
        +
        +
        Overrides:
        +
        read in class InputStream
        +
        Parameters:
        b - the byte array to read into
        off - the offset to start reading bytes into
        len - the number of bytes to read
        +
        Returns:
        the number of bytes read or -1 + if the end of the stream has been reached
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] b)
        +         throws IOException
        +
        Read the specified number of bytes into an array.
        +
        +
        Overrides:
        +
        read in class InputStream
        +
        Parameters:
        b - the byte array to read into
        +
        Returns:
        the number of bytes read or -1 + if the end of the stream has been reached
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Read a single byte.
        +
        +
        Specified by:
        +
        read in class InputStream
        +
        Returns:
        either the byte read or -1 if the end of the stream + has been reached
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReversedLinesFileReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReversedLinesFileReader.html" index 7eb84ddadd3fbeb918b447a7ad20ecadaa51da67..10fdaac91b5e55c0387abca5fd2d9a731d8ad378 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReversedLinesFileReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/ReversedLinesFileReader.html" @@ -1,3 +1,383 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6f101a402052f35c3a137bfbcde43533c4778c206c567c691d54a012e56dac3b -size 22749 + + + + + +ReversedLinesFileReader (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class ReversedLinesFileReader

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.input.ReversedLinesFileReader
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class ReversedLinesFileReader
    +extends Object
    +implements Closeable
    +
    Reads lines in a file reversely (similar to a BufferedReader, but starting at + the last line). Useful for e.g. searching in log files.
    +
    Since:
    +
    2.2
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + + + + + +
        +
      • +

        ReversedLinesFileReader

        +
        public ReversedLinesFileReader(File file,
        +                       Charset charset)
        +                        throws IOException
        +
        Creates a ReversedLinesFileReader with default block size of 4KB and the + specified encoding.
        +
        Parameters:
        file - the file to be read
        charset - the encoding to use
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        ReversedLinesFileReader

        +
        public ReversedLinesFileReader(File file,
        +                       int blockSize,
        +                       Charset encoding)
        +                        throws IOException
        +
        Creates a ReversedLinesFileReader with the given block size and encoding.
        +
        Parameters:
        file - the file to be read
        blockSize - size of the internal buffer (for ideal performance this should + match with the block size of the underlying file system).
        encoding - the encoding of the file
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        ReversedLinesFileReader

        +
        public ReversedLinesFileReader(File file,
        +                       int blockSize,
        +                       String encoding)
        +                        throws IOException
        +
        Creates a ReversedLinesFileReader with the given block size and encoding.
        +
        Parameters:
        file - the file to be read
        blockSize - size of the internal buffer (for ideal performance this should + match with the block size of the underlying file system).
        encoding - the encoding of the file
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
        UnsupportedCharsetException - thrown instead of UnsupportedEncodingException in + version 2.2 if the encoding is not supported.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        readLine

        +
        public String readLine()
        +                throws IOException
        +
        Returns the lines of the file from bottom to top.
        +
        Returns:
        the next line or null if the start of the file is reached
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/SwappedDataInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/SwappedDataInputStream.html" index dd2eed03adefb2de3b3e83368faf757f1bc55da0..07e6107ab21a929049a6477cc81e148e2d56ac31 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/SwappedDataInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/SwappedDataInputStream.html" @@ -1,3 +1,676 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c6b93ea0ffbc7ce64e5f8f694aa2afa1d4c2ba8f56657751bb1e707dc95626b4 -size 46367 + + + + + +SwappedDataInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class SwappedDataInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, DataInput, AutoCloseable
    +
    +
    +
    +
    public class SwappedDataInputStream
    +extends ProxyInputStream
    +implements DataInput
    +
    DataInput for systems relying on little endian data formats. + When read, values will be changed from little endian to big + endian formats for internal usage. +

    + Origin of code: Avalon Excalibur (IO)

    +
    Version:
    +
    CVS $Revision: 1302050 $
    +
  • +
+
+
+ +
+
+ +
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TaggedInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TaggedInputStream.html" index 33ec77e5f03d99522b30763c549f9e2e8e4730f5..df43bf18c42a73b98a3e10dce30900e9134dffac 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TaggedInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TaggedInputStream.html" @@ -1,3 +1,390 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4cc072c8c22cf4ebe49e2ecde9b19ecd07af2f58f541b2f5ec613e4a70799e8f -size 20889 + + + + + +TaggedInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class TaggedInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class TaggedInputStream
    +extends ProxyInputStream
    +
    An input stream decorator that tags potential exceptions so that the + stream that caused the exception can easily be identified. This is + done by using the TaggedIOException class to wrap all thrown + IOExceptions. See below for an example of using this class. +
    + TaggedInputStream stream = new TaggedInputStream(...);
    + try {
    +     // Processing that may throw an IOException either from this stream
    +     // or from some other IO activity like temporary files, etc.
    +     processStream(stream);
    + } catch (IOException e) {
    +     if (stream.isCauseOf(e)) {
    +         // The exception was caused by this stream.
    +         // Use e.getCause() to get the original exception.
    +     } else {
    +         // The exception was caused by something else.
    +     }
    + }
    + 
    +

    + Alternatively, the throwIfCauseOf(Throwable) method can be + used to let higher levels of code handle the exception caused by this + stream while other processing errors are being taken care of at this + lower level. +

    + TaggedInputStream stream = new TaggedInputStream(...);
    + try {
    +     processStream(stream);
    + } catch (IOException e) {
    +     stream.throwIfCauseOf(e);
    +     // ... or process the exception that was caused by something else
    + }
    + 
    +
    Since:
    +
    2.0
    +
    See Also:
    TaggedIOException
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TaggedInputStream

        +
        public TaggedInputStream(InputStream proxy)
        +
        Creates a tagging decorator for the given input stream.
        +
        Parameters:
        proxy - input stream to be decorated
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        isCauseOf

        +
        public boolean isCauseOf(Throwable exception)
        +
        Tests if the given exception was caused by this stream.
        +
        Parameters:
        exception - an exception
        +
        Returns:
        true if the exception was thrown by this stream, + false otherwise
        +
      • +
      + + + +
        +
      • +

        throwIfCauseOf

        +
        public void throwIfCauseOf(Throwable throwable)
        +                    throws IOException
        +
        Re-throws the original exception thrown by this stream. This method + first checks whether the given exception is a TaggedIOException + wrapper created by this decorator, and then unwraps and throws the + original wrapped exception. Returns normally if the exception was + not thrown by this stream.
        +
        Parameters:
        throwable - an exception
        +
        Throws:
        +
        IOException - original exception, if any, thrown by this stream
        +
      • +
      + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/Tailer.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/Tailer.html" index d10c5330f9774c676283050051cfae6bb73e6b63..1b4d8de9ed97f3ded8753c7e23fb471aacc1c884 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/Tailer.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/Tailer.html" @@ -1,3 +1,753 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1bc0466e062727857297bb8b76ef874651d21271db1ddde7614a2954c1323794 -size 46784 + + + + + +Tailer (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class Tailer

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Runnable
    +
    +
    +
    +
    public class Tailer
    +extends Object
    +implements Runnable
    +
    Simple implementation of the unix "tail -f" functionality. + +

    1. Create a TailerListener implementation

    +

    + First you need to create a TailerListener implementation + (TailerListenerAdapter is provided for convenience so that you don't have to + implement every method). +

    + +

    For example:

    +
    +  public class MyTailerListener extends TailerListenerAdapter {
    +      public void handle(String line) {
    +          System.out.println(line);
    +      }
    +  }
    + +

    2. Using a Tailer

    + +

    + You can create and use a Tailer in one of three ways: +

    + + +

    + An example of each of these is shown below. +

    + +

    2.1 Using the static helper method

    + +
    +      TailerListener listener = new MyTailerListener();
    +      Tailer tailer = Tailer.create(file, listener, delay);
    + +

    2.2 Using an Executor

    + +
    +      TailerListener listener = new MyTailerListener();
    +      Tailer tailer = new Tailer(file, listener, delay);
    +
    +      // stupid executor impl. for demo purposes
    +      Executor executor = new Executor() {
    +          public void execute(Runnable command) {
    +              command.run();
    +           }
    +      };
    +
    +      executor.execute(tailer);
    + 
    + + +

    2.3 Using a Thread

    +
    +      TailerListener listener = new MyTailerListener();
    +      Tailer tailer = new Tailer(file, listener, delay);
    +      Thread thread = new Thread(tailer);
    +      thread.setDaemon(true); // optional
    +      thread.start();
    + +

    3. Stopping a Tailer

    +

    Remember to stop the tailer when you have done with it:

    +
    +      tailer.stop();
    + 
    + +

    4. Interrupting a Tailer

    +

    You can interrupt the thread a tailer is running on by calling Thread.interrupt().

    +
    +      thread.interrupt();
    + 
    +

    If you interrupt a tailer, the tailer listener is called with the InterruptedException.

    + +

    The file is read using the default charset; this can be overriden if necessary

    +
    Since:
    +
    2.0, 2.5 Updated behavior and documentation for Thread.interrupt()
    +
    Version:
    +
    $Id: Tailer.java 1714076 2015-11-12 16:06:41Z krosenvold $
    +
    See Also:
    TailerListener, +TailerListenerAdapter
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      Tailer(File file, + Charset cset, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates a Tailer for the given file, with a specified buffer size.
      +
      Tailer(File file, + TailerListener listener) +
      Creates a Tailer for the given file, starting from the beginning, with the default delay of 1.0s.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis) +
      Creates a Tailer for the given file, starting from the beginning.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end) +
      Creates a Tailer for the given file, with a delay other than the default 1.0s.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen) +
      Creates a Tailer for the given file, with a delay other than the default 1.0s.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates a Tailer for the given file, with a specified buffer size.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end, + int bufSize) +
      Creates a Tailer for the given file, with a specified buffer size.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      static Tailercreate(File file, + Charset charset, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      static Tailercreate(File file, + TailerListener listener) +
      Creates and starts a Tailer for the given file, starting at the beginning of the file + with the default delay of 1.0s
      +
      static Tailercreate(File file, + TailerListener listener, + long delayMillis) +
      Creates and starts a Tailer for the given file, starting at the beginning of the file
      +
      static Tailercreate(File file, + TailerListener listener, + long delayMillis, + boolean end) +
      Creates and starts a Tailer for the given file with default buffer size.
      +
      static Tailercreate(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen) +
      Creates and starts a Tailer for the given file with default buffer size.
      +
      static Tailercreate(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      static Tailercreate(File file, + TailerListener listener, + long delayMillis, + boolean end, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      longgetDelay() +
      Return the delay in milliseconds.
      +
      FilegetFile() +
      Return the file.
      +
      protected booleangetRun() +
      Gets whether to keep on running.
      +
      voidrun() +
      Follows changes in the file, calling the TailerListener's handle method for each new line.
      +
      voidstop() +
      Allows the tailer to complete its current loop and return.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        Tailer

        +
        public Tailer(File file,
        +      TailerListener listener)
        +
        Creates a Tailer for the given file, starting from the beginning, with the default delay of 1.0s.
        +
        Parameters:
        file - The file to follow.
        listener - the TailerListener to use.
        +
      • +
      + + + +
        +
      • +

        Tailer

        +
        public Tailer(File file,
        +      TailerListener listener,
        +      long delayMillis)
        +
        Creates a Tailer for the given file, starting from the beginning.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        +
      • +
      + + + +
        +
      • +

        Tailer

        +
        public Tailer(File file,
        +      TailerListener listener,
        +      long delayMillis,
        +      boolean end)
        +
        Creates a Tailer for the given file, with a delay other than the default 1.0s.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        +
      • +
      + + + +
        +
      • +

        Tailer

        +
        public Tailer(File file,
        +      TailerListener listener,
        +      long delayMillis,
        +      boolean end,
        +      boolean reOpen)
        +
        Creates a Tailer for the given file, with a delay other than the default 1.0s.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        reOpen - if true, close and reopen the file between reading chunks
        +
      • +
      + + + +
        +
      • +

        Tailer

        +
        public Tailer(File file,
        +      TailerListener listener,
        +      long delayMillis,
        +      boolean end,
        +      int bufSize)
        +
        Creates a Tailer for the given file, with a specified buffer size.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        bufSize - Buffer size
        +
      • +
      + + + +
        +
      • +

        Tailer

        +
        public Tailer(File file,
        +      TailerListener listener,
        +      long delayMillis,
        +      boolean end,
        +      boolean reOpen,
        +      int bufSize)
        +
        Creates a Tailer for the given file, with a specified buffer size.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        reOpen - if true, close and reopen the file between reading chunks
        bufSize - Buffer size
        +
      • +
      + + + +
        +
      • +

        Tailer

        +
        public Tailer(File file,
        +      Charset cset,
        +      TailerListener listener,
        +      long delayMillis,
        +      boolean end,
        +      boolean reOpen,
        +      int bufSize)
        +
        Creates a Tailer for the given file, with a specified buffer size.
        +
        Parameters:
        file - the file to follow.
        cset - the Charset to be used for reading the file
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        reOpen - if true, close and reopen the file between reading chunks
        bufSize - Buffer size
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        create

        +
        public static Tailer create(File file,
        +            TailerListener listener,
        +            long delayMillis,
        +            boolean end,
        +            int bufSize)
        +
        Creates and starts a Tailer for the given file.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        bufSize - buffer size.
        +
        Returns:
        The new tailer
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static Tailer create(File file,
        +            TailerListener listener,
        +            long delayMillis,
        +            boolean end,
        +            boolean reOpen,
        +            int bufSize)
        +
        Creates and starts a Tailer for the given file.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        reOpen - whether to close/reopen the file between chunks
        bufSize - buffer size.
        +
        Returns:
        The new tailer
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static Tailer create(File file,
        +            Charset charset,
        +            TailerListener listener,
        +            long delayMillis,
        +            boolean end,
        +            boolean reOpen,
        +            int bufSize)
        +
        Creates and starts a Tailer for the given file.
        +
        Parameters:
        file - the file to follow.
        charset - the character set to use for reading the file
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        reOpen - whether to close/reopen the file between chunks
        bufSize - buffer size.
        +
        Returns:
        The new tailer
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static Tailer create(File file,
        +            TailerListener listener,
        +            long delayMillis,
        +            boolean end)
        +
        Creates and starts a Tailer for the given file with default buffer size.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        +
        Returns:
        The new tailer
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static Tailer create(File file,
        +            TailerListener listener,
        +            long delayMillis,
        +            boolean end,
        +            boolean reOpen)
        +
        Creates and starts a Tailer for the given file with default buffer size.
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        end - Set to true to tail from the end of the file, false to tail from the beginning of the file.
        reOpen - whether to close/reopen the file between chunks
        +
        Returns:
        The new tailer
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static Tailer create(File file,
        +            TailerListener listener,
        +            long delayMillis)
        +
        Creates and starts a Tailer for the given file, starting at the beginning of the file
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        delayMillis - the delay between checks of the file for new content in milliseconds.
        +
        Returns:
        The new tailer
        +
      • +
      + + + +
        +
      • +

        create

        +
        public static Tailer create(File file,
        +            TailerListener listener)
        +
        Creates and starts a Tailer for the given file, starting at the beginning of the file + with the default delay of 1.0s
        +
        Parameters:
        file - the file to follow.
        listener - the TailerListener to use.
        +
        Returns:
        The new tailer
        +
      • +
      + + + +
        +
      • +

        getFile

        +
        public File getFile()
        +
        Return the file.
        +
        Returns:
        the file
        +
      • +
      + + + +
        +
      • +

        getRun

        +
        protected boolean getRun()
        +
        Gets whether to keep on running.
        +
        Returns:
        whether to keep on running.
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        getDelay

        +
        public long getDelay()
        +
        Return the delay in milliseconds.
        +
        Returns:
        the delay in milliseconds.
        +
      • +
      + + + +
        +
      • +

        run

        +
        public void run()
        +
        Follows changes in the file, calling the TailerListener's handle method for each new line.
        +
        +
        Specified by:
        +
        run in interface Runnable
        +
        +
      • +
      + + + +
        +
      • +

        stop

        +
        public void stop()
        +
        Allows the tailer to complete its current loop and return.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListener.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListener.html" index bb67dd0b294eea42122a52f14e953a1b75de2d08..423cd8603687d36982bf140e0bb747af41dcc5cb 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListener.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListener.html" @@ -1,3 +1,298 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:aeeb301eb077fcb6d1a43f8bedaf18c76d16778513831592e0307eb0d1600fcb -size 11362 + + + + + +TailerListener (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Interface TailerListener

+
+
+
+
    +
  • +
    +
    All Known Implementing Classes:
    +
    TailerListenerAdapter
    +
    +
    +
    +
    public interface TailerListener
    +
    Listener for events from a Tailer.
    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: TailerListener.java 1714076 2015-11-12 16:06:41Z krosenvold $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      voidfileNotFound() +
      This method is called if the tailed file is not found.
      +
      voidfileRotated() +
      Called if a file rotation is detected.
      +
      voidhandle(Exception ex) +
      Handles an Exception .
      +
      voidhandle(String line) +
      Handles a line from a Tailer.
      +
      voidinit(Tailer tailer) +
      The tailer will call this method during construction, + giving the listener a method of stopping the tailer.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        init

        +
        void init(Tailer tailer)
        +
        The tailer will call this method during construction, + giving the listener a method of stopping the tailer.
        +
        Parameters:
        tailer - the tailer.
        +
      • +
      + + + +
        +
      • +

        fileNotFound

        +
        void fileNotFound()
        +
        This method is called if the tailed file is not found. +

        + Note: this is called from the tailer thread.

        +
      • +
      + + + +
        +
      • +

        fileRotated

        +
        void fileRotated()
        +
        Called if a file rotation is detected. + + This method is called before the file is reopened, and fileNotFound may + be called if the new file has not yet been created. +

        + Note: this is called from the tailer thread.

        +
      • +
      + + + +
        +
      • +

        handle

        +
        void handle(String line)
        +
        Handles a line from a Tailer. +

        + Note: this is called from the tailer thread.

        +
        Parameters:
        line - the line.
        +
      • +
      + + + +
        +
      • +

        handle

        +
        void handle(Exception ex)
        +
        Handles an Exception . +

        + Note: this is called from the tailer thread.

        +
        Parameters:
        ex - the exception.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListenerAdapter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListenerAdapter.html" index 17752b8c3426289bf8f92adc27d6d29c25ff430e..f8870b5b73b8f1647355d5bafe6826f451938081 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListenerAdapter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TailerListenerAdapter.html" @@ -1,3 +1,381 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c6be69d20103d786b9bec1911a2167dcb8f040453215bfc31db3957d89515b50 -size 17795 + + + + + +TailerListenerAdapter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class TailerListenerAdapter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    TailerListener
    +
    +
    +
    +
    public class TailerListenerAdapter
    +extends Object
    +implements TailerListener
    + +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: TailerListenerAdapter.java 1714076 2015-11-12 16:06:41Z krosenvold $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TailerListenerAdapter

        +
        public TailerListenerAdapter()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        init

        +
        public void init(Tailer tailer)
        +
        The tailer will call this method during construction, + giving the listener a method of stopping the tailer.
        +
        +
        Specified by:
        +
        init in interface TailerListener
        +
        Parameters:
        tailer - the tailer.
        +
      • +
      + + + +
        +
      • +

        fileNotFound

        +
        public void fileNotFound()
        +
        This method is called if the tailed file is not found.
        +
        +
        Specified by:
        +
        fileNotFound in interface TailerListener
        +
        +
      • +
      + + + +
        +
      • +

        fileRotated

        +
        public void fileRotated()
        +
        Called if a file rotation is detected. + + This method is called before the file is reopened, and fileNotFound may + be called if the new file has not yet been created.
        +
        +
        Specified by:
        +
        fileRotated in interface TailerListener
        +
        +
      • +
      + + + +
        +
      • +

        handle

        +
        public void handle(String line)
        +
        Handles a line from a Tailer.
        +
        +
        Specified by:
        +
        handle in interface TailerListener
        +
        Parameters:
        line - the line.
        +
      • +
      + + + +
        +
      • +

        handle

        +
        public void handle(Exception ex)
        +
        Handles an Exception .
        +
        +
        Specified by:
        +
        handle in interface TailerListener
        +
        Parameters:
        ex - the exception.
        +
      • +
      + + + +
        +
      • +

        endOfFileReached

        +
        public void endOfFileReached()
        +
        Called each time the Tailer reaches the end of the file. + + Note: this is called from the tailer thread. + + Note: a future version of commons-io will pull this method up to the TailerListener interface, + for now clients must subclass this class to use this feature.
        +
        Since:
        +
        2.5
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TeeInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TeeInputStream.html" index d2b80b9dac689566b22b973ad74d550510bacf55..7636451d96b38a81ef80e97775432e4c18d08c2b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TeeInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/TeeInputStream.html" @@ -1,3 +1,441 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:da9f04bcc148ff9e8f52115a9758a7e7d6ed06b10baab9e36bcca5fc6b2af5b2 -size 25898 + + + + + +TeeInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class TeeInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class TeeInputStream
    +extends ProxyInputStream
    +
    InputStream proxy that transparently writes a copy of all bytes read + from the proxied stream to a given OutputStream. Using ProxyInputStream.skip(long) + or ProxyInputStream.mark(int)/ProxyInputStream.reset() on the stream will result on some + bytes from the input stream being skipped or duplicated in the output + stream. +

    + The proxied input stream is closed when the close() method is + called on this proxy. It is configurable whether the associated output + stream will also closed.

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: TeeInputStream.java 1586350 2014-04-10 15:57:20Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TeeInputStream

        +
        public TeeInputStream(InputStream input,
        +              OutputStream branch)
        +
        Creates a TeeInputStream that proxies the given InputStream + and copies all read bytes to the given OutputStream. The given + output stream will not be closed when this stream gets closed.
        +
        Parameters:
        input - input stream to be proxied
        branch - output stream that will receive a copy of all bytes read
        +
      • +
      + + + +
        +
      • +

        TeeInputStream

        +
        public TeeInputStream(InputStream input,
        +              OutputStream branch,
        +              boolean closeBranch)
        +
        Creates a TeeInputStream that proxies the given InputStream + and copies all read bytes to the given OutputStream. The given + output stream will be closed when this stream gets closed if the + closeBranch parameter is true.
        +
        Parameters:
        input - input stream to be proxied
        branch - output stream that will receive a copy of all bytes read
        closeBranch - flag for closing also the output stream when this + stream is closed
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        close

        +
        public void close()
        +           throws IOException
        +
        Closes the proxied input stream and, if so configured, the associated + output stream. An exception thrown from one stream will not prevent + closing of the other stream.
        +
        +
        Specified by:
        +
        close in interface Closeable
        +
        Specified by:
        +
        close in interface AutoCloseable
        +
        Overrides:
        +
        close in class ProxyInputStream
        +
        Throws:
        +
        IOException - if either of the streams could not be closed
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read()
        +         throws IOException
        +
        Reads a single byte from the proxied input stream and writes it to + the associated output stream.
        +
        +
        Overrides:
        +
        read in class ProxyInputStream
        +
        Returns:
        next byte from the stream, or -1 if the stream has ended
        +
        Throws:
        +
        IOException - if the stream could not be read (or written)
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] bts,
        +       int st,
        +       int end)
        +         throws IOException
        +
        Reads bytes from the proxied input stream and writes the read bytes + to the associated output stream.
        +
        +
        Overrides:
        +
        read in class ProxyInputStream
        +
        Parameters:
        bts - byte buffer
        st - start offset within the buffer
        end - maximum number of bytes to read
        +
        Returns:
        number of bytes read, or -1 if the stream has ended
        +
        Throws:
        +
        IOException - if the stream could not be read (or written)
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(byte[] bts)
        +         throws IOException
        +
        Reads bytes from the proxied input stream and writes the read bytes + to the associated output stream.
        +
        +
        Overrides:
        +
        read in class ProxyInputStream
        +
        Parameters:
        bts - byte buffer
        +
        Returns:
        number of bytes read, or -1 if the stream has ended
        +
        Throws:
        +
        IOException - if the stream could not be read (or written)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/UnixLineEndingInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/UnixLineEndingInputStream.html" index a272fbbe3457e7914e20090741ae18dd435a9596..4ee3827b4743a8be97fed91f947c05ca8ff6e23e 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/UnixLineEndingInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/UnixLineEndingInputStream.html" @@ -1,3 +1,330 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c885dc8f44103dab56882a292a523e7e518bd6005cfe4a5f1e8c740bb49b4c72 -size 17289 + + + + + +UnixLineEndingInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class UnixLineEndingInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class UnixLineEndingInputStream
    +extends InputStream
    +
    A filtering input stream that ensures the content will have unix-style line endings, LF.
    +
    Since:
    +
    2.5
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        UnixLineEndingInputStream

        +
        public UnixLineEndingInputStream(InputStream in,
        +                         boolean ensureLineFeedAtEndOfFile)
        +
        Create an input stream that filters another stream
        +
        Parameters:
        in - The input stream to wrap
        ensureLineFeedAtEndOfFile - true to ensure that the file ends with LF
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/WindowsLineEndingInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/WindowsLineEndingInputStream.html" index f43fd4f47f30e221b5f73047fe5577000e08e76b..ddcc0453cb761a5f009302abb5aee2ec76606c70 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/WindowsLineEndingInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/WindowsLineEndingInputStream.html" @@ -1,3 +1,330 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5b3f30f8c186abb1b093a338040fd892c5ee15310fa855977298563d7affec21 -size 17355 + + + + + +WindowsLineEndingInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class WindowsLineEndingInputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable
    +
    +
    +
    +
    public class WindowsLineEndingInputStream
    +extends InputStream
    +
    A filtering input stream that ensures the content will have windows line endings, CRLF.
    +
    Since:
    +
    2.5
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        WindowsLineEndingInputStream

        +
        public WindowsLineEndingInputStream(InputStream in,
        +                            boolean ensureLineFeedAtEndOfFile)
        +
        Create an input stream that filters another stream
        +
        Parameters:
        in - The input stream to wrap
        ensureLineFeedAtEndOfFile - true to ensure that the file ends with CRLF
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/XmlStreamReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/XmlStreamReader.html" index 4072287239d94c7a54f8ead989e7396f33b1090b..91684ffaf5fabcedce3a8a35b32384c25473ad51 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/XmlStreamReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/XmlStreamReader.html" @@ -1,3 +1,737 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:95bfdc921d80e7d2c96b6fdaa48ea100d342e190558aabd4c5a4866b7605184d -size 43662 + + + + + +XmlStreamReader (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class XmlStreamReader

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, AutoCloseable, Readable
    +
    +
    +
    +
    public class XmlStreamReader
    +extends Reader
    +
    Character stream that handles all the necessary Voodo to figure out the + charset encoding of the XML document within the stream. +

    + IMPORTANT: This class is not related in any way to the org.xml.sax.XMLReader. + This one IS a character stream. +

    + All this has to be done without consuming characters from the stream, if not + the XML parser will not recognized the document as a valid XML. This is not + 100% true, but it's close enough (UTF-8 BOM is not handled by all parsers + right now, XmlStreamReader handles it and things work in all parsers). +

    + The XmlStreamReader class handles the charset encoding of XML documents in + Files, raw streams and HTTP streams by offering a wide set of constructors. +

    + By default the charset encoding detection is lenient, the constructor with + the lenient flag can be used for an script (following HTTP MIME and XML + specifications). All this is nicely explained by Mark Pilgrim in his blog, + Determining the character encoding of a feed. +

    + Originally developed for ROME under + Apache License 2.0.

    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: XmlStreamReader.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
    See Also:
    XmlStreamWriter
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        ENCODING_PATTERN

        +
        public static final Pattern ENCODING_PATTERN
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(File file)
        +                throws IOException
        +
        Creates a Reader for a File. +

        + It looks for the UTF-8 BOM first, if none sniffs the XML prolog charset, + if this is also missing defaults to UTF-8. +

        + It does a lenient charset encoding detection, check the constructor with + the lenient parameter for details.

        +
        Parameters:
        file - File to create a Reader from.
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the file.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(InputStream is)
        +                throws IOException
        +
        Creates a Reader for a raw InputStream. +

        + It follows the same logic used for files. +

        + It does a lenient charset encoding detection, check the constructor with + the lenient parameter for details.

        +
        Parameters:
        is - InputStream to create a Reader from.
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the stream.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(InputStream is,
        +               boolean lenient)
        +                throws IOException
        +
        Creates a Reader for a raw InputStream. +

        + It follows the same logic used for files. +

        + If lenient detection is indicated and the detection above fails as per + specifications it then attempts the following: +

        + If the content type was 'text/html' it replaces it with 'text/xml' and + tries the detection again. +

        + Else if the XML prolog had a charset encoding that encoding is used. +

        + Else if the content type had a charset encoding that encoding is used. +

        + Else 'UTF-8' is used. +

        + If lenient detection is indicated an XmlStreamReaderException is never + thrown.

        +
        Parameters:
        is - InputStream to create a Reader from.
        lenient - indicates if the charset encoding detection should be + relaxed.
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the stream.
        +
        XmlStreamReaderException - thrown if the charset encoding could not + be determined according to the specs.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(InputStream is,
        +               boolean lenient,
        +               String defaultEncoding)
        +                throws IOException
        +
        Creates a Reader for a raw InputStream. +

        + It follows the same logic used for files. +

        + If lenient detection is indicated and the detection above fails as per + specifications it then attempts the following: +

        + If the content type was 'text/html' it replaces it with 'text/xml' and + tries the detection again. +

        + Else if the XML prolog had a charset encoding that encoding is used. +

        + Else if the content type had a charset encoding that encoding is used. +

        + Else 'UTF-8' is used. +

        + If lenient detection is indicated an XmlStreamReaderException is never + thrown.

        +
        Parameters:
        is - InputStream to create a Reader from.
        lenient - indicates if the charset encoding detection should be + relaxed.
        defaultEncoding - The default encoding
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the stream.
        +
        XmlStreamReaderException - thrown if the charset encoding could not + be determined according to the specs.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(URL url)
        +                throws IOException
        +
        Creates a Reader using the InputStream of a URL. +

        + If the URL is not of type HTTP and there is not 'content-type' header in + the fetched data it uses the same logic used for Files. +

        + If the URL is a HTTP Url or there is a 'content-type' header in the + fetched data it uses the same logic used for an InputStream with + content-type. +

        + It does a lenient charset encoding detection, check the constructor with + the lenient parameter for details.

        +
        Parameters:
        url - URL to create a Reader from.
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the stream of + the URL.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(URLConnection conn,
        +               String defaultEncoding)
        +                throws IOException
        +
        Creates a Reader using the InputStream of a URLConnection. +

        + If the URLConnection is not of type HttpURLConnection and there is not + 'content-type' header in the fetched data it uses the same logic used for + files. +

        + If the URLConnection is a HTTP Url or there is a 'content-type' header in + the fetched data it uses the same logic used for an InputStream with + content-type. +

        + It does a lenient charset encoding detection, check the constructor with + the lenient parameter for details.

        +
        Parameters:
        conn - URLConnection to create a Reader from.
        defaultEncoding - The default encoding
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the stream of + the URLConnection.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(InputStream is,
        +               String httpContentType)
        +                throws IOException
        +
        Creates a Reader using an InputStream an the associated content-type + header. +

        + First it checks if the stream has BOM. If there is not BOM checks the + content-type encoding. If there is not content-type encoding checks the + XML prolog encoding. If there is not XML prolog encoding uses the default + encoding mandated by the content-type MIME type. +

        + It does a lenient charset encoding detection, check the constructor with + the lenient parameter for details.

        +
        Parameters:
        is - InputStream to create the reader from.
        httpContentType - content-type header to use for the resolution of + the charset encoding.
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the file.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(InputStream is,
        +               String httpContentType,
        +               boolean lenient,
        +               String defaultEncoding)
        +                throws IOException
        +
        Creates a Reader using an InputStream an the associated content-type + header. This constructor is lenient regarding the encoding detection. +

        + First it checks if the stream has BOM. If there is not BOM checks the + content-type encoding. If there is not content-type encoding checks the + XML prolog encoding. If there is not XML prolog encoding uses the default + encoding mandated by the content-type MIME type. +

        + If lenient detection is indicated and the detection above fails as per + specifications it then attempts the following: +

        + If the content type was 'text/html' it replaces it with 'text/xml' and + tries the detection again. +

        + Else if the XML prolog had a charset encoding that encoding is used. +

        + Else if the content type had a charset encoding that encoding is used. +

        + Else 'UTF-8' is used. +

        + If lenient detection is indicated an XmlStreamReaderException is never + thrown.

        +
        Parameters:
        is - InputStream to create the reader from.
        httpContentType - content-type header to use for the resolution of + the charset encoding.
        lenient - indicates if the charset encoding detection should be + relaxed.
        defaultEncoding - The default encoding
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the file.
        +
        XmlStreamReaderException - thrown if the charset encoding could not + be determined according to the specs.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReader

        +
        public XmlStreamReader(InputStream is,
        +               String httpContentType,
        +               boolean lenient)
        +                throws IOException
        +
        Creates a Reader using an InputStream an the associated content-type + header. This constructor is lenient regarding the encoding detection. +

        + First it checks if the stream has BOM. If there is not BOM checks the + content-type encoding. If there is not content-type encoding checks the + XML prolog encoding. If there is not XML prolog encoding uses the default + encoding mandated by the content-type MIME type. +

        + If lenient detection is indicated and the detection above fails as per + specifications it then attempts the following: +

        + If the content type was 'text/html' it replaces it with 'text/xml' and + tries the detection again. +

        + Else if the XML prolog had a charset encoding that encoding is used. +

        + Else if the content type had a charset encoding that encoding is used. +

        + Else 'UTF-8' is used. +

        + If lenient detection is indicated an XmlStreamReaderException is never + thrown.

        +
        Parameters:
        is - InputStream to create the reader from.
        httpContentType - content-type header to use for the resolution of + the charset encoding.
        lenient - indicates if the charset encoding detection should be + relaxed.
        +
        Throws:
        +
        IOException - thrown if there is a problem reading the file.
        +
        XmlStreamReaderException - thrown if the charset encoding could not + be determined according to the specs.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getDefaultEncoding

        +
        public String getDefaultEncoding()
        +
        Returns the default encoding to use if none is set in HTTP content-type, + XML prolog and the rules based on content-type are not adequate. +

        + If it is NULL the content-type based rules are used.

        +
        Returns:
        the default encoding to use.
        +
      • +
      + + + +
        +
      • +

        getEncoding

        +
        public String getEncoding()
        +
        Returns the charset encoding of the XmlStreamReader.
        +
        Returns:
        charset encoding.
        +
      • +
      + + + +
        +
      • +

        read

        +
        public int read(char[] buf,
        +       int offset,
        +       int len)
        +         throws IOException
        +
        Invokes the underlying reader's read(char[], int, int) method.
        +
        +
        Specified by:
        +
        read in class Reader
        +
        Parameters:
        buf - the buffer to read the characters into
        offset - The start offset
        len - The number of bytes to read
        +
        Returns:
        the number of characters read or -1 if the end of stream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/XmlStreamReaderException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/XmlStreamReaderException.html" new file mode 100644 index 0000000000000000000000000000000000000000..8a84bcf3cfa4f987486539ba6d6502f91600b77e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/XmlStreamReaderException.html" @@ -0,0 +1,418 @@ + + + + + +XmlStreamReaderException (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.input
+

Class XmlStreamReaderException

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable
    +
    +
    +
    +
    public class XmlStreamReaderException
    +extends IOException
    +
    The XmlStreamReaderException is thrown by the XmlStreamReader constructors if + the charset encoding can not be determined according to the XML 1.0 + specification and RFC 3023. +

    + The exception returns the unconsumed InputStream to allow the application to + do an alternate processing with the stream. Note that the original + InputStream given to the XmlStreamReader cannot be used as that one has been + already read.

    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: XmlStreamReaderException.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        XmlStreamReaderException

        +
        public XmlStreamReaderException(String msg,
        +                        String bomEnc,
        +                        String xmlGuessEnc,
        +                        String xmlEnc)
        +
        Creates an exception instance if the charset encoding could not be + determined. +

        + Instances of this exception are thrown by the XmlStreamReader.

        +
        Parameters:
        msg - message describing the reason for the exception.
        bomEnc - BOM encoding.
        xmlGuessEnc - XML guess encoding.
        xmlEnc - XML prolog encoding.
        +
      • +
      + + + +
        +
      • +

        XmlStreamReaderException

        +
        public XmlStreamReaderException(String msg,
        +                        String ctMime,
        +                        String ctEnc,
        +                        String bomEnc,
        +                        String xmlGuessEnc,
        +                        String xmlEnc)
        +
        Creates an exception instance if the charset encoding could not be + determined. +

        + Instances of this exception are thrown by the XmlStreamReader.

        +
        Parameters:
        msg - message describing the reason for the exception.
        ctMime - MIME type in the content-type.
        ctEnc - encoding in the content-type.
        bomEnc - BOM encoding.
        xmlGuessEnc - XML guess encoding.
        xmlEnc - XML prolog encoding.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getBomEncoding

        +
        public String getBomEncoding()
        +
        Returns the BOM encoding found in the InputStream.
        +
        Returns:
        the BOM encoding, null if none.
        +
      • +
      + + + +
        +
      • +

        getXmlGuessEncoding

        +
        public String getXmlGuessEncoding()
        +
        Returns the encoding guess based on the first bytes of the InputStream.
        +
        Returns:
        the encoding guess, null if it couldn't be guessed.
        +
      • +
      + + + +
        +
      • +

        getXmlEncoding

        +
        public String getXmlEncoding()
        +
        Returns the encoding found in the XML prolog of the InputStream.
        +
        Returns:
        the encoding of the XML prolog, null if none.
        +
      • +
      + + + +
        +
      • +

        getContentTypeMime

        +
        public String getContentTypeMime()
        +
        Returns the MIME type in the content-type used to attempt determining the + encoding.
        +
        Returns:
        the MIME type in the content-type, null if there was not + content-type or the encoding detection did not involve HTTP.
        +
      • +
      + + + +
        +
      • +

        getContentTypeEncoding

        +
        public String getContentTypeEncoding()
        +
        Returns the encoding in the content-type used to attempt determining the + encoding.
        +
        Returns:
        the encoding in the content-type, null if there was not + content-type, no encoding in it or the encoding detection did not + involve HTTP.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/AutoCloseInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/AutoCloseInputStream.html" index 07eee24c8bc84ce1010fd518636b37f84ee0170f..b016cf3620cdd20c350dcd6796d64b7d11c91c49 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/AutoCloseInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/AutoCloseInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4ae4ee343ccb37a898e8c1d14356c4c20861153e2ee7da9210d58d99d190c0fc -size 4470 + + + + + +Uses of Class org.apache.commons.io.input.AutoCloseInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.AutoCloseInputStream

+
+
No usage of org.apache.commons.io.input.AutoCloseInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BOMInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BOMInputStream.html" index 2bbd64dfeea7dd325d691904845ab0e55609447d..1949674b921a8e142ef4fd11c7a9b387853429c6 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BOMInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BOMInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1529209954ebd7a0c4bc806d5ea32c995c8fc5d7917d5eb3fe9058f4f0371730 -size 4404 + + + + + +Uses of Class org.apache.commons.io.input.BOMInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.BOMInputStream

+
+
No usage of org.apache.commons.io.input.BOMInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedInputStream.html" index 077555e5d42ae8df09ec48124a2cfb763561132e..c4e320bc34ce1ca6f1c13916e978342bf0a4a04a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:714ff9cd165ce81b2db8f37c1282dec80bcbbac86d1037bd58988782c192d514 -size 4448 + + + + + +Uses of Class org.apache.commons.io.input.BoundedInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.BoundedInputStream

+
+
No usage of org.apache.commons.io.input.BoundedInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedReader.html" index 6c6a19b68751fdd08b17a32cda1c2abedf5ebe87..da066bafeb228bcad44b5cf8939c80933d9bd66a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BoundedReader.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0e1e1f1dec7ecc106d284fd515976af7716f54a26008371cc344d3ba5b80f846 -size 4393 + + + + + +Uses of Class org.apache.commons.io.input.BoundedReader (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.BoundedReader

+
+
No usage of org.apache.commons.io.input.BoundedReader
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BrokenInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BrokenInputStream.html" index b9a4143bef865e61bad71a7747c410acb73560d0..f0a604d0c194d956d37b69096b8b1c924aa66553 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BrokenInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/BrokenInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:795ed8ba6d252dfdb16fdf7887d4181d8d84a49d73c46d27ea46c87f73642b3f -size 4437 + + + + + +Uses of Class org.apache.commons.io.input.BrokenInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.BrokenInputStream

+
+
No usage of org.apache.commons.io.input.BrokenInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceInputStream.html" index b093404c0d6a58edd5176e0d69def1be72f4ef10..695da93af396578d1ffcf57d1e00e94c90611249 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:556028ccf880cdb778d64ae5c127f20adb47ae419b0e0c0ef2d694fbd4043e53 -size 4503 + + + + + +Uses of Class org.apache.commons.io.input.CharSequenceInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.CharSequenceInputStream

+
+
No usage of org.apache.commons.io.input.CharSequenceInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceReader.html" index be101aae8df774f764a0f92793f602bdc54f7c74..6ee51e2d7b0d0304d330c1340633fe218a7e412e 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CharSequenceReader.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a25579925d0081c5c9abef3b0c58348e34fcb43462165630c97df76333224086 -size 4448 + + + + + +Uses of Class org.apache.commons.io.input.CharSequenceReader (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.CharSequenceReader

+
+
No usage of org.apache.commons.io.input.CharSequenceReader
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClassLoaderObjectInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClassLoaderObjectInputStream.html" index df0b828c933a9aab61892d731e08284759db67f2..e97bbdca125ca1655affa8440ae0feb4cb51d01d 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClassLoaderObjectInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClassLoaderObjectInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7296b5f506f43e583a75e190a323f5120a3508d19acb74205769107e7720f269 -size 4558 + + + + + +Uses of Class org.apache.commons.io.input.ClassLoaderObjectInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.ClassLoaderObjectInputStream

+
+
No usage of org.apache.commons.io.input.ClassLoaderObjectInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CloseShieldInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CloseShieldInputStream.html" index 4e904fc938b60f0aeeaa060eb03e58430f401fe2..714ed5ef31ca004772ed2a5f5dbb5390f9df708d 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CloseShieldInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CloseShieldInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9dfb999bf7e63d605b019ef6001d566a0ace68e0f6e049ec38bc394f8e012805 -size 4492 + + + + + +Uses of Class org.apache.commons.io.input.CloseShieldInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.CloseShieldInputStream

+
+
No usage of org.apache.commons.io.input.CloseShieldInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClosedInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClosedInputStream.html" index bd59412eb06ab03c5e98d8fd4eb5e1af70ccaf05..e41bb63df3b40957a3b7ee2613fbbfb6c2b4508f 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClosedInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ClosedInputStream.html" @@ -1,3 +1,161 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:37fd27f63a271a256dd657b79d07cee70d7905e70593220849f4185f646599ba -size 6703 + + + + + +Uses of Class org.apache.commons.io.input.ClosedInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.ClosedInputStream

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CountingInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CountingInputStream.html" index 305e61acf05d69bcedec8b02e8ab0bbe6e2a7864..1832ba67f920a57aafd791553fc4fdd7f377315b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CountingInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/CountingInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d956495f22960a89b5644a4d259501cc866fdf733b06c27cc4f6d58dc6ed1153 -size 4459 + + + + + +Uses of Class org.apache.commons.io.input.CountingInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.CountingInputStream

+
+
No usage of org.apache.commons.io.input.CountingInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/DemuxInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/DemuxInputStream.html" index 9382936cb20af5cdb1b1410704491a1d16341623..e2bd27e2b0a11e50186be67a1e2fe457de4c90d8 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/DemuxInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/DemuxInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:414c8a22020607a6fb56c1b4ae99a40a2e54460b16530d66b6d44e36aa8b46a9 -size 4426 + + + + + +Uses of Class org.apache.commons.io.input.DemuxInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.DemuxInputStream

+
+
No usage of org.apache.commons.io.input.DemuxInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullInputStream.html" index 74187bc18eaa798377df22a1901ad9acc23349db..9769b4823347a658112db7da062a83048b300feb 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:39d8e5537fbe45df02ba2a98d5057159b4edc40aa56898243a1801a8414c6e93 -size 4415 + + + + + +Uses of Class org.apache.commons.io.input.NullInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.NullInputStream

+
+
No usage of org.apache.commons.io.input.NullInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullReader.html" index 04cfe3be72adf7489271f28c7078baf51cec7719..eeefa45d84bfb4bd8b6574a98dc75e60869c6515 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/NullReader.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5122be59efa4c35e5b81d2847779df0fedba99c626a313eff56da4a74ba6c08c -size 4360 + + + + + +Uses of Class org.apache.commons.io.input.NullReader (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.NullReader

+
+
No usage of org.apache.commons.io.input.NullReader
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyInputStream.html" index 820c5237493204b73f05fe5e93ad85e5f512c90e..83fc91a3a633efaf78ac77bf577b4eb83589a3f3 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyInputStream.html" @@ -1,3 +1,201 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e2237b528d7a2681dffb35f49e74fcfcf411828a6d3b179a4a0a2becd2c7c66b -size 9216 + + + + + +Uses of Class org.apache.commons.io.input.ProxyInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.ProxyInputStream

+
+
+
    +
  • + + + + + + + + + + + + +
    Packages that use ProxyInputStream 
    PackageDescription
    org.apache.commons.io.input +
    +This package provides implementations of input classes, such as +InputStream and Reader.
    +
    +
  • +
  • +
      +
    • + + +

      Uses of ProxyInputStream in org.apache.commons.io.input

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Subclasses of ProxyInputStream in org.apache.commons.io.input 
      Modifier and TypeClass and Description
      class AutoCloseInputStream +
      Proxy stream that closes and discards the underlying stream as soon as the + end of input has been reached or when the stream is explicitly closed.
      +
      class BOMInputStream +
      This class is used to wrap a stream that includes an encoded ByteOrderMark as its first bytes.
      +
      class CloseShieldInputStream +
      Proxy stream that prevents the underlying input stream from being closed.
      +
      class CountingInputStream +
      A decorating input stream that counts the number of bytes that have passed + through the stream so far.
      +
      class SwappedDataInputStream +
      DataInput for systems relying on little endian data formats.
      +
      class TaggedInputStream +
      An input stream decorator that tags potential exceptions so that the + stream that caused the exception can easily be identified.
      +
      class TeeInputStream +
      InputStream proxy that transparently writes a copy of all bytes read + from the proxied stream to a given OutputStream.
      +
      +
    • +
    +
  • +
+
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyReader.html" index d9519d553d689a682654c83a0bac5ac0fa4dced1..c4ec21dfdb140de6b35af96aafdcda0d05a67e4b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ProxyReader.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:44e07460bf76ec7dec971f027724516f9d62f4ebe7c488d5f2c1afa78c7a5e8b -size 4371 + + + + + +Uses of Class org.apache.commons.io.input.ProxyReader (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.ProxyReader

+
+
No usage of org.apache.commons.io.input.ProxyReader
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReaderInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReaderInputStream.html" index 5fe8b9bd3382b36539bdbd82d875ea491ea6088e..4564bbac80ba74e46a122f08d1d48f2bbfb807b9 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReaderInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReaderInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bcd72be94eb085edcc9562bea6608e08a18460901962c1a739835b02bbd301fe -size 4437 + + + + + +Uses of Class org.apache.commons.io.input.ReaderInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.ReaderInputStream

+
+
No usage of org.apache.commons.io.input.ReaderInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReversedLinesFileReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReversedLinesFileReader.html" index 86790c59c304c9dd9ac6682e6ff200e9cc0db0c3..1f637c22dad86c5e9fef2e824b7e91d42e462432 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReversedLinesFileReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/ReversedLinesFileReader.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d00aa16c3d9f0f58fd840879cddfcf70286a60b2960715553264e4115cbeb94d -size 4503 + + + + + +Uses of Class org.apache.commons.io.input.ReversedLinesFileReader (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.ReversedLinesFileReader

+
+
No usage of org.apache.commons.io.input.ReversedLinesFileReader
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/SwappedDataInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/SwappedDataInputStream.html" index dbb64cb72cbe248ee4f4076617df8d630993a9d7..c2b54b4e08c3cfcead7f061a05b75f9bcea44c0b 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/SwappedDataInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/SwappedDataInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4ee41d35bf8721caeb8a67a492bcb91130d55c5085733059c1250fa33611230b -size 4492 + + + + + +Uses of Class org.apache.commons.io.input.SwappedDataInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.SwappedDataInputStream

+
+
No usage of org.apache.commons.io.input.SwappedDataInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TaggedInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TaggedInputStream.html" index fea4dae4c328f8df69c27d61a9798daa5382cc7a..07a7ee03376072024fb4505f45a045be2439739a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TaggedInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TaggedInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:82e0f2b8892a8947e9f19d9bb4f262a3e21f7bf40fcf5ce6160bcc01395890a3 -size 4437 + + + + + +Uses of Class org.apache.commons.io.input.TaggedInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.TaggedInputStream

+
+
No usage of org.apache.commons.io.input.TaggedInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/Tailer.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/Tailer.html" index 0d2b0005fb2aed52fafdb9797d0048811b20db03..4bcb65dd0f69908dfdaca057bbf5b096785fa82d 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/Tailer.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/Tailer.html" @@ -1,3 +1,246 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:75c03a187fef801fa34d506faec002494c350b018026c62926bebdf15fac5eb6 -size 14476 + + + + + +Uses of Class org.apache.commons.io.input.Tailer (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.Tailer

+
+
+
    +
  • + + + + + + + + + + + + +
    Packages that use Tailer 
    PackageDescription
    org.apache.commons.io.input +
    +This package provides implementations of input classes, such as +InputStream and Reader.
    +
    +
  • +
  • +
      +
    • + + +

      Uses of Tailer in org.apache.commons.io.input

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods in org.apache.commons.io.input that return Tailer 
      Modifier and TypeMethod and Description
      static TailerTailer.create(File file, + Charset charset, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      static TailerTailer.create(File file, + TailerListener listener) +
      Creates and starts a Tailer for the given file, starting at the beginning of the file + with the default delay of 1.0s
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis) +
      Creates and starts a Tailer for the given file, starting at the beginning of the file
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end) +
      Creates and starts a Tailer for the given file with default buffer size.
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen) +
      Creates and starts a Tailer for the given file with default buffer size.
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      + + + + + + + + + + + + + + + + +
      Methods in org.apache.commons.io.input with parameters of type Tailer 
      Modifier and TypeMethod and Description
      voidTailerListenerAdapter.init(Tailer tailer) +
      The tailer will call this method during construction, + giving the listener a method of stopping the tailer.
      +
      voidTailerListener.init(Tailer tailer) +
      The tailer will call this method during construction, + giving the listener a method of stopping the tailer.
      +
      +
    • +
    +
  • +
+
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListener.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListener.html" index d43edbf4af4769a308190438c7b29c818d785804..864e12b57675997540fb2df2d9e88b0bcef1a652 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListener.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListener.html" @@ -1,3 +1,306 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fd55e57229d2815e1b91d2c597cedfb4003383e08233415e4181e4e0e15d3358 -size 19844 + + + + + +Uses of Interface org.apache.commons.io.input.TailerListener (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Interface
org.apache.commons.io.input.TailerListener

+
+
+
    +
  • + + + + + + + + + + + + +
    Packages that use TailerListener 
    PackageDescription
    org.apache.commons.io.input +
    +This package provides implementations of input classes, such as +InputStream and Reader.
    +
    +
  • +
  • +
      +
    • + + +

      Uses of TailerListener in org.apache.commons.io.input

      + + + + + + + + + + + + +
      Classes in org.apache.commons.io.input that implement TailerListener 
      Modifier and TypeClass and Description
      class TailerListenerAdapter + +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods in org.apache.commons.io.input with parameters of type TailerListener 
      Modifier and TypeMethod and Description
      static TailerTailer.create(File file, + Charset charset, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      static TailerTailer.create(File file, + TailerListener listener) +
      Creates and starts a Tailer for the given file, starting at the beginning of the file + with the default delay of 1.0s
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis) +
      Creates and starts a Tailer for the given file, starting at the beginning of the file
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end) +
      Creates and starts a Tailer for the given file with default buffer size.
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen) +
      Creates and starts a Tailer for the given file with default buffer size.
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      static TailerTailer.create(File file, + TailerListener listener, + long delayMillis, + boolean end, + int bufSize) +
      Creates and starts a Tailer for the given file.
      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Constructors in org.apache.commons.io.input with parameters of type TailerListener 
      Constructor and Description
      Tailer(File file, + Charset cset, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates a Tailer for the given file, with a specified buffer size.
      +
      Tailer(File file, + TailerListener listener) +
      Creates a Tailer for the given file, starting from the beginning, with the default delay of 1.0s.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis) +
      Creates a Tailer for the given file, starting from the beginning.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end) +
      Creates a Tailer for the given file, with a delay other than the default 1.0s.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen) +
      Creates a Tailer for the given file, with a delay other than the default 1.0s.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end, + boolean reOpen, + int bufSize) +
      Creates a Tailer for the given file, with a specified buffer size.
      +
      Tailer(File file, + TailerListener listener, + long delayMillis, + boolean end, + int bufSize) +
      Creates a Tailer for the given file, with a specified buffer size.
      +
      +
    • +
    +
  • +
+
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListenerAdapter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListenerAdapter.html" index 0f4d7e7e02f852195af3b51f54f1c38958993f22..587c27c84d12ff233be9f7fb17636b6886b775df 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListenerAdapter.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TailerListenerAdapter.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0637f874c7beabef242b505a863ec745ec72688af53cf0de1c4caf991ce322e8 -size 4481 + + + + + +Uses of Class org.apache.commons.io.input.TailerListenerAdapter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.TailerListenerAdapter

+
+
No usage of org.apache.commons.io.input.TailerListenerAdapter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TeeInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TeeInputStream.html" index fcc51d55614febebafc8757c7f2ef64e293d9a6f..3c7fb81cd9802960a6710abfee6f0fde89cca67a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TeeInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/TeeInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:06ad0a922b7e13f839a065a742162a930f9f4b0c66c30ad6e221dc75bbfd1fc2 -size 4404 + + + + + +Uses of Class org.apache.commons.io.input.TeeInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.TeeInputStream

+
+
No usage of org.apache.commons.io.input.TeeInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/UnixLineEndingInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/UnixLineEndingInputStream.html" index 01a50ef0dab4d8f626d58459eec61e7efc82c06f..5b591bc20369d1fcc69e9a4ab3f42202412d0156 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/UnixLineEndingInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/UnixLineEndingInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:51bed4f389aa3da82354d7689ca89065fa574bd96bf501ddf672ca3cbcb70130 -size 4525 + + + + + +Uses of Class org.apache.commons.io.input.UnixLineEndingInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.UnixLineEndingInputStream

+
+
No usage of org.apache.commons.io.input.UnixLineEndingInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/WindowsLineEndingInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/WindowsLineEndingInputStream.html" index 7309a619126588b5048a38b71dec1b5d61d140b3..8b3def0d546fcc95789121a60d4532d0c88c04a1 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/WindowsLineEndingInputStream.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/WindowsLineEndingInputStream.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d8dc8389438a3ed4a7b4976d782452a1267bef0f089f0fe403456bdca9d3abb0 -size 4558 + + + + + +Uses of Class org.apache.commons.io.input.WindowsLineEndingInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.WindowsLineEndingInputStream

+
+
No usage of org.apache.commons.io.input.WindowsLineEndingInputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReader.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReader.html" index f04bcf6c42e359ca47faa2e5e285d060f6451b44..6ef1ea28a487d52efc6e379e0d067c8d11d8c718 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReader.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReader.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:638342455fd620167d22798be53857f37ac8aab310382b15745b90606872a31c -size 4415 + + + + + +Uses of Class org.apache.commons.io.input.XmlStreamReader (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.XmlStreamReader

+
+
No usage of org.apache.commons.io.input.XmlStreamReader
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReaderException.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReaderException.html" index 15e28bc0ff3648a3b2015fe3c7fd219c7dd08fc3..b9221a908455445e1d6f64bcd6e01a9947da3330 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReaderException.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/class-use/XmlStreamReaderException.html" @@ -1,3 +1,115 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6ddb0e22bb43c85f040c045965397492aeabecadd54f01fa5a5917c100c3d060 -size 4514 + + + + + +Uses of Class org.apache.commons.io.input.XmlStreamReaderException (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.input.XmlStreamReaderException

+
+
No usage of org.apache.commons.io.input.XmlStreamReaderException
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-frame.html" index 2868d739c67d6c493905e0a322afe6a4fde03d20..2f1c20c6a48b4b5493e8a034849ce53c169c0a5a 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-frame.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-frame.html" @@ -1,3 +1,51 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f0a114e583077d7b3339ae54bcc8a59a9493d0f9c895eacc9cd67f124b820884 -size 4468 + + + + + +org.apache.commons.io.input (Apache Commons IO 2.5 API) + + + +

org.apache.commons.io.input

+ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-summary.html" index 875069138050de8b3cb5086e944d68d0818a6efa..fd50c6e59545a950fafbb4ee3d2dabd607f64e55 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-summary.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-summary.html" @@ -1,3 +1,355 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1e83ab9b4388857ae58261d9cf99db23883e9c3792fd7d0b84fdc8fd38b3d1cc -size 17088 + + + + + +org.apache.commons.io.input (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Package org.apache.commons.io.input

+
+
+This package provides implementations of input classes, such as +InputStream and Reader.
+
+

See: Description

+
+
+
    +
  • + + + + + + + + + + + + +
    Interface Summary 
    InterfaceDescription
    TailerListener +
    Listener for events from a Tailer.
    +
    +
  • +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    AutoCloseInputStream +
    Proxy stream that closes and discards the underlying stream as soon as the + end of input has been reached or when the stream is explicitly closed.
    +
    BOMInputStream +
    This class is used to wrap a stream that includes an encoded ByteOrderMark as its first bytes.
    +
    BoundedInputStream +
    This is a stream that will only supply bytes up to a certain length - if its + position goes above that, it will stop.
    +
    BoundedReader +
    A reader that imposes a limit to the number of characters that can be read from + an underlying reader, returning eof when this limit is reached -regardless of state of + underlying reader.
    +
    BrokenInputStream +
    Broken input stream.
    +
    CharSequenceInputStream +
    InputStream implementation that can read from String, StringBuffer, + StringBuilder or CharBuffer.
    +
    CharSequenceReader +
    Reader implementation that can read from String, StringBuffer, + StringBuilder or CharBuffer.
    +
    ClassLoaderObjectInputStream +
    A special ObjectInputStream that loads a class based on a specified + ClassLoader rather than the system default.
    +
    ClosedInputStream +
    Closed input stream.
    +
    CloseShieldInputStream +
    Proxy stream that prevents the underlying input stream from being closed.
    +
    CountingInputStream +
    A decorating input stream that counts the number of bytes that have passed + through the stream so far.
    +
    DemuxInputStream +
    Data written to this stream is forwarded to a stream that has been associated + with this thread.
    +
    NullInputStream +
    A functional, light weight InputStream that emulates + a stream of a specified size.
    +
    NullReader +
    A functional, light weight Reader that emulates + a reader of a specified size.
    +
    ProxyInputStream +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
    +
    ProxyReader +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
    +
    ReaderInputStream +
    InputStream implementation that reads a character stream from a Reader + and transforms it to a byte stream using a specified charset encoding.
    +
    ReversedLinesFileReader +
    Reads lines in a file reversely (similar to a BufferedReader, but starting at + the last line).
    +
    SwappedDataInputStream +
    DataInput for systems relying on little endian data formats.
    +
    TaggedInputStream +
    An input stream decorator that tags potential exceptions so that the + stream that caused the exception can easily be identified.
    +
    Tailer +
    Simple implementation of the unix "tail -f" functionality.
    +
    TailerListenerAdapter + +
    TeeInputStream +
    InputStream proxy that transparently writes a copy of all bytes read + from the proxied stream to a given OutputStream.
    +
    UnixLineEndingInputStream +
    A filtering input stream that ensures the content will have unix-style line endings, LF.
    +
    WindowsLineEndingInputStream +
    A filtering input stream that ensures the content will have windows line endings, CRLF.
    +
    XmlStreamReader +
    Character stream that handles all the necessary Voodo to figure out the + charset encoding of the XML document within the stream.
    +
    +
  • +
  • + + + + + + + + + + + + +
    Exception Summary 
    ExceptionDescription
    XmlStreamReaderException +
    The XmlStreamReaderException is thrown by the XmlStreamReader constructors if + the charset encoding can not be determined according to the XML 1.0 + specification and RFC 3023.
    +
    +
  • +
+ + + +

Package org.apache.commons.io.input Description

+

+This package provides implementations of input classes, such as +InputStream and Reader. +

+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-tree.html" index 5cb6c270153f5d04bf7ab9144d51fdd6a5e8cf3b..f30857f180392c714c82962874830fbdb62eab55 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-tree.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-tree.html" @@ -1,3 +1,193 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:84d7f9ec8dcf24e322ba923c37afce04cbca5e4a29304356e92c17cee17be59c -size 14557 + + + + + +org.apache.commons.io.input Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package org.apache.commons.io.input

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-use.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-use.html" index 7d5db84df128adddacba23bf14ea0043ab03d27a..f182f2a6dcce97c400c194b6eec3770aca75f005 100644 --- "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-use.html" +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/input/package-use.html" @@ -1,3 +1,171 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f7cb2de53397d385696c550450fb0bc24ed39db10915c8744023bb5513fea942 -size 6549 + + + + + +Uses of Package org.apache.commons.io.input (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Package
org.apache.commons.io.input

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationListener.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationListener.html" new file mode 100644 index 0000000000000000000000000000000000000000..bef19788f3fc8058af82a982b939b6c04164fce6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationListener.html" @@ -0,0 +1,341 @@ + + + + + +FileAlterationListener (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.monitor
+

Interface FileAlterationListener

+
+
+
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        onStart

        +
        void onStart(FileAlterationObserver observer)
        +
        File system observer started checking event.
        +
        Parameters:
        observer - The file system observer
        +
      • +
      + + + +
        +
      • +

        onDirectoryCreate

        +
        void onDirectoryCreate(File directory)
        +
        Directory created Event.
        +
        Parameters:
        directory - The directory created
        +
      • +
      + + + +
        +
      • +

        onDirectoryChange

        +
        void onDirectoryChange(File directory)
        +
        Directory changed Event.
        +
        Parameters:
        directory - The directory changed
        +
      • +
      + + + +
        +
      • +

        onDirectoryDelete

        +
        void onDirectoryDelete(File directory)
        +
        Directory deleted Event.
        +
        Parameters:
        directory - The directory deleted
        +
      • +
      + + + +
        +
      • +

        onFileCreate

        +
        void onFileCreate(File file)
        +
        File created Event.
        +
        Parameters:
        file - The file created
        +
      • +
      + + + +
        +
      • +

        onFileChange

        +
        void onFileChange(File file)
        +
        File changed Event.
        +
        Parameters:
        file - The file changed
        +
      • +
      + + + +
        +
      • +

        onFileDelete

        +
        void onFileDelete(File file)
        +
        File deleted Event.
        +
        Parameters:
        file - The file deleted
        +
      • +
      + + + +
        +
      • +

        onStop

        +
        void onStop(FileAlterationObserver observer)
        +
        File system observer finished checking event.
        +
        Parameters:
        observer - The file system observer
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.html" new file mode 100644 index 0000000000000000000000000000000000000000..694406d000cab9db5062c21c85d02ff6d8c6de14 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationListenerAdaptor.html" @@ -0,0 +1,414 @@ + + + + + +FileAlterationListenerAdaptor (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.monitor
+

Class FileAlterationListenerAdaptor

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.monitor.FileAlterationListenerAdaptor
    • +
    +
  • +
+
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileAlterationListenerAdaptor

        +
        public FileAlterationListenerAdaptor()
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationMonitor.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationMonitor.html" new file mode 100644 index 0000000000000000000000000000000000000000..3b5d022bc6731dfbd550f313d9776405560bebd9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationMonitor.html" @@ -0,0 +1,461 @@ + + + + + +FileAlterationMonitor (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.monitor
+

Class FileAlterationMonitor

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.monitor.FileAlterationMonitor
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Runnable
    +
    +
    +
    +
    public final class FileAlterationMonitor
    +extends Object
    +implements Runnable
    +
    A runnable that spawns a monitoring thread triggering any + registered FileAlterationObserver at a specified interval.
    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: FileAlterationMonitor.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
    See Also:
    FileAlterationObserver
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileAlterationMonitor

        +
        public FileAlterationMonitor()
        +
        Construct a monitor with a default interval of 10 seconds.
        +
      • +
      + + + +
        +
      • +

        FileAlterationMonitor

        +
        public FileAlterationMonitor(long interval)
        +
        Construct a monitor with the specified interval.
        +
        Parameters:
        interval - The amount of time in miliseconds to wait between + checks of the file system
        +
      • +
      + + + +
        +
      • +

        FileAlterationMonitor

        +
        public FileAlterationMonitor(long interval,
        +                     FileAlterationObserver... observers)
        +
        Construct a monitor with the specified interval and set of observers.
        +
        Parameters:
        interval - The amount of time in miliseconds to wait between + checks of the file system
        observers - The set of observers to add to the monitor.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getInterval

        +
        public long getInterval()
        +
        Return the interval.
        +
        Returns:
        the interval
        +
      • +
      + + + +
        +
      • +

        setThreadFactory

        +
        public void setThreadFactory(ThreadFactory threadFactory)
        +
        Set the thread factory.
        +
        Parameters:
        threadFactory - the thread factory
        +
      • +
      + + + +
        +
      • +

        addObserver

        +
        public void addObserver(FileAlterationObserver observer)
        +
        Add a file system observer to this monitor.
        +
        Parameters:
        observer - The file system observer to add
        +
      • +
      + + + +
        +
      • +

        removeObserver

        +
        public void removeObserver(FileAlterationObserver observer)
        +
        Remove a file system observer from this monitor.
        +
        Parameters:
        observer - The file system observer to remove
        +
      • +
      + + + + + + + +
        +
      • +

        start

        +
        public void start()
        +           throws Exception
        +
        Start monitoring.
        +
        Throws:
        +
        Exception - if an error occurs initializing the observer
        +
      • +
      + + + +
        +
      • +

        stop

        +
        public void stop()
        +          throws Exception
        +
        Stop monitoring.
        +
        Throws:
        +
        Exception - if an error occurs initializing the observer
        +
      • +
      + + + +
        +
      • +

        stop

        +
        public void stop(long stopInterval)
        +          throws Exception
        +
        Stop monitoring.
        +
        Parameters:
        stopInterval - the amount of time in milliseconds to wait for the thread to finish. + A value of zero will wait until the thread is finished (see Thread.join(long)).
        +
        Throws:
        +
        Exception - if an error occurs initializing the observer
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        run

        +
        public void run()
        +
        Run.
        +
        +
        Specified by:
        +
        run in interface Runnable
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationObserver.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationObserver.html" new file mode 100644 index 0000000000000000000000000000000000000000..322bf15ca5fd5703642222bc6351eda80726ec6e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileAlterationObserver.html" @@ -0,0 +1,629 @@ + + + + + +FileAlterationObserver (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.monitor
+

Class FileAlterationObserver

+
+
+
    +
  • java.lang.Object
  • +
  • +
      +
    • org.apache.commons.io.monitor.FileAlterationObserver
    • +
    +
  • +
+
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Serializable
    +
    +
    +
    +
    public class FileAlterationObserver
    +extends Object
    +implements Serializable
    +
    FileAlterationObserver represents the state of files below a root directory, + checking the filesystem and notifying listeners of create, change or + delete events. +

    + To use this implementation: +

    + +

    Basic Usage

    + Create a FileAlterationObserver for the directory and register the listeners: +
    +      File directory = new File(new File("."), "src");
    +      FileAlterationObserver observer = new FileAlterationObserver(directory);
    +      observer.addListener(...);
    +      observer.addListener(...);
    + 
    + To manually observe a directory, initialize the observer and invoked the + checkAndNotify() method as required: +
    +      // intialize
    +      observer.init();
    +      ...
    +      // invoke as required
    +      observer.checkAndNotify();
    +      ...
    +      observer.checkAndNotify();
    +      ...
    +      // finished
    +      observer.finish();
    + 
    + Alternatively, register the oberver(s) with a FileAlterationMonitor, + which creates a new thread, invoking the observer at the specified interval: +
    +      long interval = ...
    +      FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
    +      monitor.addObserver(observer);
    +      monitor.start();
    +      ...
    +      monitor.stop();
    + 
    + +

    File Filters

    + This implementation can monitor portions of the file system + by using FileFilters to observe only the files and/or directories + that are of interest. This makes it more efficient and reduces the + noise from unwanted file system events. +

    + Commons IO has a good range of + useful, ready made + File Filter + implementations for this purpose. +

    + For example, to only observe 1) visible directories and 2) files with a ".java" suffix + in a root directory called "src" you could set up a FileAlterationObserver in the following + way: +

    +      // Create a FileFilter
    +      IOFileFilter directories = FileFilterUtils.and(
    +                                      FileFilterUtils.directoryFileFilter(),
    +                                      HiddenFileFilter.VISIBLE);
    +      IOFileFilter files       = FileFilterUtils.and(
    +                                      FileFilterUtils.fileFileFilter(),
    +                                      FileFilterUtils.suffixFileFilter(".java"));
    +      IOFileFilter filter = FileFilterUtils.or(directories, files);
    +
    +      // Create the File system observer and register File Listeners
    +      FileAlterationObserver observer = new FileAlterationObserver(new File("src"), filter);
    +      observer.addListener(...);
    +      observer.addListener(...);
    + 
    + +

    FileEntry

    + FileEntry represents the state of a file or directory, capturing + File attributes at a point in time. Custom implementations of + FileEntry can be used to capture additional properties that the + basic implementation does not support. The FileEntry.refresh(File) + method is used to determine if a file or directory has changed since the last + check and stores the current state of the File's properties.
    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: FileAlterationObserver.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
    See Also:
    FileAlterationListener, +FileAlterationMonitor, +Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileAlterationObserver

        +
        public FileAlterationObserver(String directoryName)
        +
        Construct an observer for the specified directory.
        +
        Parameters:
        directoryName - the name of the directory to observe
        +
      • +
      + + + +
        +
      • +

        FileAlterationObserver

        +
        public FileAlterationObserver(String directoryName,
        +                      FileFilter fileFilter)
        +
        Construct an observer for the specified directory and file filter.
        +
        Parameters:
        directoryName - the name of the directory to observe
        fileFilter - The file filter or null if none
        +
      • +
      + + + +
        +
      • +

        FileAlterationObserver

        +
        public FileAlterationObserver(String directoryName,
        +                      FileFilter fileFilter,
        +                      IOCase caseSensitivity)
        +
        Construct an observer for the specified directory, file filter and + file comparator.
        +
        Parameters:
        directoryName - the name of the directory to observe
        fileFilter - The file filter or null if none
        caseSensitivity - what case sensitivity to use comparing file names, null means system sensitive
        +
      • +
      + + + +
        +
      • +

        FileAlterationObserver

        +
        public FileAlterationObserver(File directory)
        +
        Construct an observer for the specified directory.
        +
        Parameters:
        directory - the directory to observe
        +
      • +
      + + + +
        +
      • +

        FileAlterationObserver

        +
        public FileAlterationObserver(File directory,
        +                      FileFilter fileFilter)
        +
        Construct an observer for the specified directory and file filter.
        +
        Parameters:
        directory - the directory to observe
        fileFilter - The file filter or null if none
        +
      • +
      + + + +
        +
      • +

        FileAlterationObserver

        +
        public FileAlterationObserver(File directory,
        +                      FileFilter fileFilter,
        +                      IOCase caseSensitivity)
        +
        Construct an observer for the specified directory, file filter and + file comparator.
        +
        Parameters:
        directory - the directory to observe
        fileFilter - The file filter or null if none
        caseSensitivity - what case sensitivity to use comparing file names, null means system sensitive
        +
      • +
      + + + +
        +
      • +

        FileAlterationObserver

        +
        protected FileAlterationObserver(FileEntry rootEntry,
        +                      FileFilter fileFilter,
        +                      IOCase caseSensitivity)
        +
        Construct an observer for the specified directory, file filter and + file comparator.
        +
        Parameters:
        rootEntry - the root directory to observe
        fileFilter - The file filter or null if none
        caseSensitivity - what case sensitivity to use comparing file names, null means system sensitive
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getDirectory

        +
        public File getDirectory()
        +
        Return the directory being observed.
        +
        Returns:
        the directory being observed
        +
      • +
      + + + +
        +
      • +

        getFileFilter

        +
        public FileFilter getFileFilter()
        +
        Return the fileFilter.
        +
        Returns:
        the fileFilter
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        addListener

        +
        public void addListener(FileAlterationListener listener)
        +
        Add a file system listener.
        +
        Parameters:
        listener - The file system listener
        +
      • +
      + + + +
        +
      • +

        removeListener

        +
        public void removeListener(FileAlterationListener listener)
        +
        Remove a file system listener.
        +
        Parameters:
        listener - The file system listener
        +
      • +
      + + + +
        +
      • +

        getListeners

        +
        public Iterable<FileAlterationListener> getListeners()
        +
        Returns the set of registered file system listeners.
        +
        Returns:
        The file system listeners
        +
      • +
      + + + +
        +
      • +

        initialize

        +
        public void initialize()
        +                throws Exception
        +
        Initialize the observer.
        +
        Throws:
        +
        Exception - if an error occurs
        +
      • +
      + + + +
        +
      • +

        destroy

        +
        public void destroy()
        +             throws Exception
        +
        Final processing.
        +
        Throws:
        +
        Exception - if an error occurs
        +
      • +
      + + + +
        +
      • +

        checkAndNotify

        +
        public void checkAndNotify()
        +
        Check whether the file and its chlidren have been created, modified or deleted.
        +
      • +
      + + + +
        +
      • +

        toString

        +
        public String toString()
        +
        Provide a String representation of this observer.
        +
        +
        Overrides:
        +
        toString in class Object
        +
        Returns:
        a String representation of this observer
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileEntry.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileEntry.html" new file mode 100644 index 0000000000000000000000000000000000000000..d51dbcaa10d208f15c78130d9872975acca7732b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/FileEntry.html" @@ -0,0 +1,604 @@ + + + + + +FileEntry (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.monitor
+

Class FileEntry

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileEntry

        +
        public FileEntry(File file)
        +
        Construct a new monitor for a specified File.
        +
        Parameters:
        file - The file being monitored
        +
      • +
      + + + +
        +
      • +

        FileEntry

        +
        public FileEntry(FileEntry parent,
        +         File file)
        +
        Construct a new monitor for a specified File.
        +
        Parameters:
        parent - The parent
        file - The file being monitored
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        refresh

        +
        public boolean refresh(File file)
        +
        Refresh the attributes from the File, indicating + whether the file has changed. +

        + This implementation refreshes the name, exists, + directory, lastModified and length + properties. +

        + The exists, directory, lastModified + and length properties are compared for changes

        +
        Parameters:
        file - the file instance to compare to
        +
        Returns:
        true if the file has changed, otherwise false
        +
      • +
      + + + +
        +
      • +

        newChildInstance

        +
        public FileEntry newChildInstance(File file)
        +
        Create a new child instance. +

        + Custom implementations should override this method to return + a new instance of the appropriate type.

        +
        Parameters:
        file - The child file
        +
        Returns:
        a new child instance
        +
      • +
      + + + +
        +
      • +

        getParent

        +
        public FileEntry getParent()
        +
        Return the parent entry.
        +
        Returns:
        the parent entry
        +
      • +
      + + + +
        +
      • +

        getLevel

        +
        public int getLevel()
        +
        Return the level
        +
        Returns:
        the level
        +
      • +
      + + + +
        +
      • +

        getChildren

        +
        public FileEntry[] getChildren()
        +
        Return the directory's files.
        +
        Returns:
        This directory's files or an empty + array if the file is not a directory or the + directory is empty
        +
      • +
      + + + +
        +
      • +

        setChildren

        +
        public void setChildren(FileEntry[] children)
        +
        Set the directory's files.
        +
        Parameters:
        children - This directory's files, may be null
        +
      • +
      + + + +
        +
      • +

        getFile

        +
        public File getFile()
        +
        Return the file being monitored.
        +
        Returns:
        the file being monitored
        +
      • +
      + + + +
        +
      • +

        getName

        +
        public String getName()
        +
        Return the file name.
        +
        Returns:
        the file name
        +
      • +
      + + + +
        +
      • +

        setName

        +
        public void setName(String name)
        +
        Set the file name.
        +
        Parameters:
        name - the file name
        +
      • +
      + + + +
        +
      • +

        getLastModified

        +
        public long getLastModified()
        +
        Return the last modified time from the last time it + was checked.
        +
        Returns:
        the last modified time
        +
      • +
      + + + +
        +
      • +

        setLastModified

        +
        public void setLastModified(long lastModified)
        +
        Return the last modified time from the last time it + was checked.
        +
        Parameters:
        lastModified - The last modified time
        +
      • +
      + + + +
        +
      • +

        getLength

        +
        public long getLength()
        +
        Return the length.
        +
        Returns:
        the length
        +
      • +
      + + + +
        +
      • +

        setLength

        +
        public void setLength(long length)
        +
        Set the length.
        +
        Parameters:
        length - the length
        +
      • +
      + + + +
        +
      • +

        isExists

        +
        public boolean isExists()
        +
        Indicate whether the file existed the last time it + was checked.
        +
        Returns:
        whether the file existed
        +
      • +
      + + + +
        +
      • +

        setExists

        +
        public void setExists(boolean exists)
        +
        Set whether the file existed the last time it + was checked.
        +
        Parameters:
        exists - whether the file exists or not
        +
      • +
      + + + +
        +
      • +

        isDirectory

        +
        public boolean isDirectory()
        +
        Indicate whether the file is a directory or not.
        +
        Returns:
        whether the file is a directory or not
        +
      • +
      + + + +
        +
      • +

        setDirectory

        +
        public void setDirectory(boolean directory)
        +
        Set whether the file is a directory or not.
        +
        Parameters:
        directory - whether the file is a directory or not
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationListener.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationListener.html" new file mode 100644 index 0000000000000000000000000000000000000000..eb113dac29bef4c5659d087b6aa659761b0015dc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationListener.html" @@ -0,0 +1,197 @@ + + + + + +Uses of Interface org.apache.commons.io.monitor.FileAlterationListener (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Interface
org.apache.commons.io.monitor.FileAlterationListener

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationListenerAdaptor.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationListenerAdaptor.html" new file mode 100644 index 0000000000000000000000000000000000000000..99b5936c2a17b3c80bae68ff3760cb0e5e290781 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationListenerAdaptor.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.monitor.FileAlterationListenerAdaptor (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.monitor.FileAlterationListenerAdaptor

+
+
No usage of org.apache.commons.io.monitor.FileAlterationListenerAdaptor
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationMonitor.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationMonitor.html" new file mode 100644 index 0000000000000000000000000000000000000000..1f9f648e5688165279618f53d269986d55b4b3a7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationMonitor.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.monitor.FileAlterationMonitor (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.monitor.FileAlterationMonitor

+
+
No usage of org.apache.commons.io.monitor.FileAlterationMonitor
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationObserver.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationObserver.html" new file mode 100644 index 0000000000000000000000000000000000000000..3690a4797a0c1d4ad83da33dd09f1157e35ec0a5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileAlterationObserver.html" @@ -0,0 +1,221 @@ + + + + + +Uses of Class org.apache.commons.io.monitor.FileAlterationObserver (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.monitor.FileAlterationObserver

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileEntry.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileEntry.html" new file mode 100644 index 0000000000000000000000000000000000000000..b2e4c5c72826c3fb23baf8db2055949a9e44eb71 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/class-use/FileEntry.html" @@ -0,0 +1,210 @@ + + + + + +Uses of Class org.apache.commons.io.monitor.FileEntry (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.monitor.FileEntry

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-frame.html" new file mode 100644 index 0000000000000000000000000000000000000000..a08385cfbfb6dc898432fc95228118670d7b50a9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-frame.html" @@ -0,0 +1,25 @@ + + + + + +org.apache.commons.io.monitor (Apache Commons IO 2.5 API) + + + +

org.apache.commons.io.monitor

+ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-summary.html" new file mode 100644 index 0000000000000000000000000000000000000000..ffb2f834c900f697ca28a8adb092f979eb2fffc1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-summary.html" @@ -0,0 +1,187 @@ + + + + + +org.apache.commons.io.monitor (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Package org.apache.commons.io.monitor

+
+
+This package provides a component for monitoring file system events +(directory and file create, update and delete events).
+
+

See: Description

+
+
+
    +
  • + + + + + + + + + + + + +
    Interface Summary 
    InterfaceDescription
    FileAlterationListener +
    A listener that receives events of file system modifications.
    +
    +
  • +
  • + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    FileAlterationListenerAdaptor +
    Convenience FileAlterationListener implementation that does nothing.
    +
    FileAlterationMonitor +
    A runnable that spawns a monitoring thread triggering any + registered FileAlterationObserver at a specified interval.
    +
    FileAlterationObserver +
    FileAlterationObserver represents the state of files below a root directory, + checking the filesystem and notifying listeners of create, change or + delete events.
    +
    FileEntry +
    The state of a file or directory, capturing the following File attributes at a point in time.
    +
    +
  • +
+ + + +

Package org.apache.commons.io.monitor Description

+

+This package provides a component for monitoring file system events +(directory and file create, update and delete events). +

+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-tree.html" new file mode 100644 index 0000000000000000000000000000000000000000..52f5132c19b8082d3f4e211eee2efc524a97dc9f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-tree.html" @@ -0,0 +1,135 @@ + + + + + +org.apache.commons.io.monitor Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package org.apache.commons.io.monitor

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-use.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-use.html" new file mode 100644 index 0000000000000000000000000000000000000000..e4c5f69857d98528c6f7c33e3d0f100cce18c0ee --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/monitor/package-use.html" @@ -0,0 +1,166 @@ + + + + + +Uses of Package org.apache.commons.io.monitor (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Package
org.apache.commons.io.monitor

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/AppendableOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/AppendableOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..125cf4608f1f0c7e4ab8067bd5fb6a2cab0e9eb9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/AppendableOutputStream.html" @@ -0,0 +1,315 @@ + + + + + +AppendableOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class AppendableOutputStream<T extends Appendable>

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + + + +
        +
      • +

        AppendableOutputStream

        +
        public AppendableOutputStream(T appendable)
        +
        Construct a new instance with the specified appendable.
        +
        Parameters:
        appendable - the appendable to write to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(int b)
        +           throws IOException
        +
        Write a character to the underlying appendable.
        +
        +
        Specified by:
        +
        write in class OutputStream
        +
        Parameters:
        b - the character to write
        +
        Throws:
        +
        IOException - upon error
        +
      • +
      + + + +
        +
      • +

        getAppendable

        +
        public T getAppendable()
        +
        Return the target appendable.
        +
        Returns:
        the target appendable
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/BrokenOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/BrokenOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..0478f9c246c6c7585d2dda9c2641dfe92ca54e6b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/BrokenOutputStream.html" @@ -0,0 +1,358 @@ + + + + + +BrokenOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class BrokenOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class BrokenOutputStream
    +extends OutputStream
    +
    Broken output stream. This stream always throws an IOException from + all OutputStream methods. +

    + This class is mostly useful for testing error handling in code that uses an + output stream.

    +
    Since:
    +
    2.0
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        BrokenOutputStream

        +
        public BrokenOutputStream(IOException exception)
        +
        Creates a new stream that always throws the given exception.
        +
        Parameters:
        exception - the exception to be thrown
        +
      • +
      + + + +
        +
      • +

        BrokenOutputStream

        +
        public BrokenOutputStream()
        +
        Creates a new stream that always throws an IOException
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ByteArrayOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ByteArrayOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..b8e2ef65e45ece5e2ae1506a8a38c6fb0bc7c3dd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ByteArrayOutputStream.html" @@ -0,0 +1,640 @@ + + + + + +ByteArrayOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class ByteArrayOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class ByteArrayOutputStream
    +extends OutputStream
    +
    This class implements an output stream in which the data is + written into a byte array. The buffer automatically grows as data + is written to it. +

    + The data can be retrieved using toByteArray() and + toString(). +

    + Closing a ByteArrayOutputStream has no effect. The methods in + this class can be called after the stream has been closed without + generating an IOException. +

    + This is an alternative implementation of the ByteArrayOutputStream + class. The original implementation only allocates 32 bytes at the beginning. + As this class is designed for heavy duty it starts at 1024 bytes. In contrast + to the original it doesn't reallocate the whole memory block but allocates + additional buffers. This way no buffers need to be garbage collected and + the contents don't have to be copied to the new buffer. This class is + designed to behave exactly like the original. The only exception is the + deprecated toString(int) method that has been ignored.

    +
    Version:
    +
    $Id: ByteArrayOutputStream.java 1612034 2014-07-20 06:35:19Z ggregory $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + + + + +
      Constructors 
      Constructor and Description
      ByteArrayOutputStream() +
      Creates a new byte array output stream.
      +
      ByteArrayOutputStream(int size) +
      Creates a new byte array output stream, with a buffer capacity of + the specified size, in bytes.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ByteArrayOutputStream

        +
        public ByteArrayOutputStream()
        +
        Creates a new byte array output stream. The buffer capacity is + initially 1024 bytes, though its size increases if necessary.
        +
      • +
      + + + +
        +
      • +

        ByteArrayOutputStream

        +
        public ByteArrayOutputStream(int size)
        +
        Creates a new byte array output stream, with a buffer capacity of + the specified size, in bytes.
        +
        Parameters:
        size - the initial size
        +
        Throws:
        +
        IllegalArgumentException - if size is negative
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(byte[] b,
        +         int off,
        +         int len)
        +
        Write the bytes to byte array.
        +
        +
        Overrides:
        +
        write in class OutputStream
        +
        Parameters:
        b - the bytes to write
        off - The start offset
        len - The number of bytes to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(int b)
        +
        Write a byte to byte array.
        +
        +
        Specified by:
        +
        write in class OutputStream
        +
        Parameters:
        b - the byte to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public int write(InputStream in)
        +          throws IOException
        +
        Writes the entire contents of the specified input stream to this + byte stream. Bytes from the input stream are read directly into the + internal buffers of this streams.
        +
        Parameters:
        in - the input stream to read from
        +
        Returns:
        total number of bytes read from the input stream + (and written to this stream)
        +
        Throws:
        +
        IOException - if an I/O error occurs while reading the input stream
        Since:
        +
        1.4
        +
      • +
      + + + +
        +
      • +

        size

        +
        public int size()
        +
        Return the current size of the byte array.
        +
        Returns:
        the current size of the byte array
        +
      • +
      + + + +
        +
      • +

        close

        +
        public void close()
        +           throws IOException
        +
        Closing a ByteArrayOutputStream has no effect. The methods in + this class can be called after the stream has been closed without + generating an IOException.
        +
        +
        Specified by:
        +
        close in interface Closeable
        +
        Specified by:
        +
        close in interface AutoCloseable
        +
        Overrides:
        +
        close in class OutputStream
        +
        Throws:
        +
        IOException - never (this method should not declare this exception + but it has to now due to backwards compatibility)
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        toBufferedInputStream

        +
        public static InputStream toBufferedInputStream(InputStream input)
        +                                         throws IOException
        +
        Fetches entire contents of an InputStream and represent + same data as result InputStream. +

        + This method is useful where, +

          +
        • Source InputStream is slow.
        • +
        • It has network resources associated, so we cannot keep it open for + long time.
        • +
        • It has network timeout associated.
        • +
        + It can be used in favor of toByteArray(), since it + avoids unnecessary allocation and copy of byte[].
        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.
        +
        Parameters:
        input - Stream to be fully buffered.
        +
        Returns:
        A fully buffered stream.
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        toBufferedInputStream

        +
        public static InputStream toBufferedInputStream(InputStream input,
        +                                int size)
        +                                         throws IOException
        +
        Fetches entire contents of an InputStream and represent + same data as result InputStream. +

        + This method is useful where, +

          +
        • Source InputStream is slow.
        • +
        • It has network resources associated, so we cannot keep it open for + long time.
        • +
        • It has network timeout associated.
        • +
        + It can be used in favor of toByteArray(), since it + avoids unnecessary allocation and copy of byte[].
        + This method buffers the input internally, so there is no need to use a + BufferedInputStream.
        +
        Parameters:
        input - Stream to be fully buffered.
        size - the initial buffer size
        +
        Returns:
        A fully buffered stream.
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        toInputStream

        +
        public InputStream toInputStream()
        +
        Gets the current contents of this byte stream as a Input Stream. The + returned stream is backed by buffers of this stream, + avoiding memory allocation and copy, thus saving space and time.
        +
        Returns:
        the current contents of this output stream.
        Since:
        +
        2.5
        +
        See Also:
        ByteArrayOutputStream.toByteArray(), +reset()
        +
      • +
      + + + +
        +
      • +

        toByteArray

        +
        public byte[] toByteArray()
        +
        Gets the curent contents of this byte stream as a byte array. + The result is independent of this stream.
        +
        Returns:
        the current contents of this output stream, as a byte array
        See Also:
        ByteArrayOutputStream.toByteArray()
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        toString

        +
        public String toString(Charset charset)
        +
        Gets the curent contents of this byte stream as a string + using the specified encoding.
        +
        Parameters:
        charset - the character encoding
        +
        Returns:
        the string converted from the byte array
        Since:
        +
        2.5
        +
        See Also:
        ByteArrayOutputStream.toString(String)
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ChunkedOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ChunkedOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..fa6f13cc1558f23f066e259c9c0c0af7dc63b940 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ChunkedOutputStream.html" @@ -0,0 +1,335 @@ + + + + + +ChunkedOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class ChunkedOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class ChunkedOutputStream
    +extends FilterOutputStream
    +
    OutputStream which breaks larger output blocks into chunks. + Native code may need to copy the input array; if the write buffer + is very large this can cause OOME.
    +
    Since:
    +
    2.5
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ChunkedOutputStream

        +
        public ChunkedOutputStream(OutputStream stream,
        +                   int chunkSize)
        +
        Creates a new stream that uses the specified chunk size.
        +
        Parameters:
        stream - the stream to wrap
        chunkSize - the chunk size to use; must be a positive number.
        +
        Throws:
        +
        IllegalArgumentException - if the chunk size is <= 0
        +
      • +
      + + + +
        +
      • +

        ChunkedOutputStream

        +
        public ChunkedOutputStream(OutputStream stream)
        +
        Creates a new stream that uses a chunk size of DEFAULT_CHUNK_SIZE.
        +
        Parameters:
        stream - the stream to wrap
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(byte[] data,
        +         int srcOffset,
        +         int length)
        +           throws IOException
        +
        Writes the data buffer in chunks to the underlying stream
        +
        +
        Overrides:
        +
        write in class FilterOutputStream
        +
        Parameters:
        data - the data to write
        srcOffset - the offset
        length - the length of data to write
        +
        Throws:
        +
        IOException - if an I/O error occurs.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ChunkedWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ChunkedWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..c2683fc5c0b6b16bf871d8a86efd69cd185ec89a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ChunkedWriter.html" @@ -0,0 +1,349 @@ + + + + + +ChunkedWriter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class ChunkedWriter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, Appendable, AutoCloseable
    +
    +
    +
    +
    public class ChunkedWriter
    +extends FilterWriter
    +
    Writer which breaks larger output blocks into chunks. + Native code may need to copy the input array; if the write buffer + is very large this can cause OOME.
    +
    Since:
    +
    2.5
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ChunkedWriter

        +
        public ChunkedWriter(Writer writer,
        +             int chunkSize)
        +
        Creates a new writer that uses the specified chunk size.
        +
        Parameters:
        writer - the writer to wrap
        chunkSize - the chunk size to use; must be a positive number.
        +
        Throws:
        +
        IllegalArgumentException - if the chunk size is <= 0
        +
      • +
      + + + +
        +
      • +

        ChunkedWriter

        +
        public ChunkedWriter(Writer writer)
        +
        Creates a new writer that uses a chunk size of DEFAULT_CHUNK_SIZE
        +
        Parameters:
        writer - the writer to wrap
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(char[] data,
        +         int srcOffset,
        +         int length)
        +           throws IOException
        +
        writes the data buffer in chunks to the underlying writer
        +
        +
        Overrides:
        +
        write in class FilterWriter
        +
        Parameters:
        data - The data
        srcOffset - the offset
        length - the number of bytes to write
        +
        Throws:
        +
        IOException - upon error
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/CloseShieldOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/CloseShieldOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..02d6fb2d25883b1223e3e287e1154965100470b6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/CloseShieldOutputStream.html" @@ -0,0 +1,327 @@ + + + + + +CloseShieldOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class CloseShieldOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class CloseShieldOutputStream
    +extends ProxyOutputStream
    +
    Proxy stream that prevents the underlying output stream from being closed. +

    + This class is typically used in cases where an output stream needs to be + passed to a component that wants to explicitly close the stream even if + other components would still use the stream for output. +

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: CloseShieldOutputStream.java 1674710 2015-04-20 00:25:55Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CloseShieldOutputStream

        +
        public CloseShieldOutputStream(OutputStream out)
        +
        Creates a proxy that shields the given output stream from being + closed.
        +
        Parameters:
        out - underlying output stream
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ClosedOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ClosedOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..57966f93b8c8f9ed52a29dadede658635675e5f7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ClosedOutputStream.html" @@ -0,0 +1,331 @@ + + + + + +ClosedOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class ClosedOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class ClosedOutputStream
    +extends OutputStream
    +
    Closed output stream. This stream throws an exception on all attempts to + write something to the stream. +

    + Typically uses of this class include testing for corner cases in methods + that accept an output stream and acting as a sentinel value instead of + a null output stream.

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: ClosedOutputStream.java 1471767 2013-04-24 23:24:19Z sebb $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        CLOSED_OUTPUT_STREAM

        +
        public static final ClosedOutputStream CLOSED_OUTPUT_STREAM
        +
        A singleton.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ClosedOutputStream

        +
        public ClosedOutputStream()
        +
      • +
      +
    • +
    + + +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/CountingOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/CountingOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..0620f56e632a53f892ede5da142da42216deb217 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/CountingOutputStream.html" @@ -0,0 +1,406 @@ + + + + + +CountingOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class CountingOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class CountingOutputStream
    +extends ProxyOutputStream
    +
    A decorating output stream that counts the number of bytes that have passed + through the stream so far. +

    + A typical use case would be during debugging, to ensure that data is being + written as expected.

    +
    Version:
    +
    $Id: CountingOutputStream.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        CountingOutputStream

        +
        public CountingOutputStream(OutputStream out)
        +
        Constructs a new CountingOutputStream.
        +
        Parameters:
        out - the OutputStream to write to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        beforeWrite

        +
        protected void beforeWrite(int n)
        +
        Updates the count with the number of bytes that are being written.
        +
        +
        Overrides:
        +
        beforeWrite in class ProxyOutputStream
        +
        Parameters:
        n - number of bytes to be written to the stream
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        getCount

        +
        public int getCount()
        +
        The number of bytes that have passed through this stream. +

        + NOTE: From v1.3 this method throws an ArithmeticException if the + count is greater than can be expressed by an int. + See getByteCount() for a method using a long.

        +
        Returns:
        the number of bytes accumulated
        +
        Throws:
        +
        ArithmeticException - if the byte count is too large
        +
      • +
      + + + +
        +
      • +

        resetCount

        +
        public int resetCount()
        +
        Set the byte count back to 0. +

        + NOTE: From v1.3 this method throws an ArithmeticException if the + count is greater than can be expressed by an int. + See resetByteCount() for a method using a long.

        +
        Returns:
        the count previous to resetting
        +
        Throws:
        +
        ArithmeticException - if the byte count is too large
        +
      • +
      + + + +
        +
      • +

        getByteCount

        +
        public long getByteCount()
        +
        The number of bytes that have passed through this stream. +

        + NOTE: This method is an alternative for getCount(). + It was added because that method returns an integer which will + result in incorrect count for files over 2GB.

        +
        Returns:
        the number of bytes accumulated
        Since:
        +
        1.3
        +
      • +
      + + + +
        +
      • +

        resetByteCount

        +
        public long resetByteCount()
        +
        Set the byte count back to 0. +

        + NOTE: This method is an alternative for resetCount(). + It was added because that method returns an integer which will + result in incorrect count for files over 2GB.

        +
        Returns:
        the count previous to resetting
        Since:
        +
        1.3
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/DeferredFileOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/DeferredFileOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..af269165509d672354ddf6b572771b8ee12e82b0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/DeferredFileOutputStream.html" @@ -0,0 +1,474 @@ + + + + + +DeferredFileOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class DeferredFileOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class DeferredFileOutputStream
    +extends ThresholdingOutputStream
    +
    An output stream which will retain data in memory until a specified + threshold is reached, and only then commit it to disk. If the stream is + closed before the threshold is reached, the data will not be written to + disk at all. +

    + This class originated in FileUpload processing. In this use case, you do + not know in advance the size of the file being uploaded. If the file is small + you want to store it in memory (for speed), but if the file is large you want + to store it to file (to avoid memory issues).

    +
    Version:
    +
    $Id: DeferredFileOutputStream.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DeferredFileOutputStream

        +
        public DeferredFileOutputStream(int threshold,
        +                        File outputFile)
        +
        Constructs an instance of this class which will trigger an event at the + specified threshold, and save data to a file beyond that point.
        +
        Parameters:
        threshold - The number of bytes at which to trigger an event.
        outputFile - The file to which data is saved beyond the threshold.
        +
      • +
      + + + +
        +
      • +

        DeferredFileOutputStream

        +
        public DeferredFileOutputStream(int threshold,
        +                        String prefix,
        +                        String suffix,
        +                        File directory)
        +
        Constructs an instance of this class which will trigger an event at the + specified threshold, and save data to a temporary file beyond that point.
        +
        Parameters:
        threshold - The number of bytes at which to trigger an event.
        prefix - Prefix to use for the temporary file.
        suffix - Suffix to use for the temporary file.
        directory - Temporary file directory.
        Since:
        +
        1.4
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getStream

        +
        protected OutputStream getStream()
        +                          throws IOException
        +
        Returns the current output stream. This may be memory based or disk + based, depending on the current state with respect to the threshold.
        +
        +
        Specified by:
        +
        getStream in class ThresholdingOutputStream
        +
        Returns:
        The underlying output stream.
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + +
        +
      • +

        thresholdReached

        +
        protected void thresholdReached()
        +                         throws IOException
        +
        Switches the underlying output stream from a memory based stream to one + that is backed by disk. This is the point at which we realise that too + much data is being written to keep in memory, so we elect to switch to + disk-based storage.
        +
        +
        Specified by:
        +
        thresholdReached in class ThresholdingOutputStream
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + +
        +
      • +

        isInMemory

        +
        public boolean isInMemory()
        +
        Determines whether or not the data for this output stream has been + retained in memory.
        +
        Returns:
        true if the data is available in memory; + false otherwise.
        +
      • +
      + + + +
        +
      • +

        getData

        +
        public byte[] getData()
        +
        Returns the data for this output stream as an array of bytes, assuming + that the data has been retained in memory. If the data was written to + disk, this method returns null.
        +
        Returns:
        The data for this output stream, or null if no such + data is available.
        +
      • +
      + + + +
        +
      • +

        getFile

        +
        public File getFile()
        +
        Returns either the output file specified in the constructor or + the temporary file created or null. +

        + If the constructor specifying the file is used then it returns that + same output file, even when threshold has not been reached. +

        + If constructor specifying a temporary file prefix/suffix is used + then the temporary file created once the threshold is reached is returned + If the threshold was not reached then null is returned.

        +
        Returns:
        The file for this output stream, or null if no such + file exists.
        +
      • +
      + + + + + + + +
        +
      • +

        writeTo

        +
        public void writeTo(OutputStream out)
        +             throws IOException
        +
        Writes the data from this output stream to the specified output stream, + after it has been closed.
        +
        Parameters:
        out - output stream to write to.
        +
        Throws:
        +
        IOException - if this stream is not yet closed or an error occurs.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/DemuxOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/DemuxOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..0408e7a931020ed300826d779ad338a46507e47d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/DemuxOutputStream.html" @@ -0,0 +1,353 @@ + + + + + +DemuxOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class DemuxOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class DemuxOutputStream
    +extends OutputStream
    +
    Forwards data to a stream that has been associated with this thread.
    +
    Version:
    +
    $Id: DemuxOutputStream.java 1737901 2016-04-06 00:23:36Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        DemuxOutputStream

        +
        public DemuxOutputStream()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        bindStream

        +
        public OutputStream bindStream(OutputStream output)
        +
        Binds the specified stream to the current thread.
        +
        Parameters:
        output - the stream to bind
        +
        Returns:
        the OutputStream that was previously active
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        write

        +
        public void write(int ch)
        +           throws IOException
        +
        Writes byte to stream associated with current thread.
        +
        +
        Specified by:
        +
        write in class OutputStream
        +
        Parameters:
        ch - the byte to write to stream
        +
        Throws:
        +
        IOException - if an error occurs
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/FileWriterWithEncoding.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/FileWriterWithEncoding.html" new file mode 100644 index 0000000000000000000000000000000000000000..2391262a4d39d6c5b253763fad0e26cc6bc57efa --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/FileWriterWithEncoding.html" @@ -0,0 +1,728 @@ + + + + + +FileWriterWithEncoding (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class FileWriterWithEncoding

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, Appendable, AutoCloseable
    +
    +
    +
    +
    public class FileWriterWithEncoding
    +extends Writer
    +
    Writer of files that allows the encoding to be set. +

    + This class provides a simple alternative to FileWriter + that allows an encoding to be set. Unfortunately, it cannot subclass + FileWriter. +

    + By default, the file will be overwritten, but this may be changed to append. +

    + The encoding must be specified using either the name of the Charset, + the Charset, or a CharsetEncoder. If the default encoding + is required then use the FileWriter directly, rather than + this implementation. +

    +
    Since:
    +
    1.4
    +
    Version:
    +
    $Id: FileWriterWithEncoding.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(String filename,
        +                      String encoding)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        filename - the name of the file to write to, not null
        encoding - the encoding to use, not null
        +
        Throws:
        +
        NullPointerException - if the file name or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(String filename,
        +                      String encoding,
        +                      boolean append)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        filename - the name of the file to write to, not null
        encoding - the encoding to use, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file name or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(String filename,
        +                      Charset encoding)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        filename - the name of the file to write to, not null
        encoding - the encoding to use, not null
        +
        Throws:
        +
        NullPointerException - if the file name or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(String filename,
        +                      Charset encoding,
        +                      boolean append)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        filename - the name of the file to write to, not null
        encoding - the encoding to use, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file name or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(String filename,
        +                      CharsetEncoder encoding)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        filename - the name of the file to write to, not null
        encoding - the encoding to use, not null
        +
        Throws:
        +
        NullPointerException - if the file name or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(String filename,
        +                      CharsetEncoder encoding,
        +                      boolean append)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        filename - the name of the file to write to, not null
        encoding - the encoding to use, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file name or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(File file,
        +                      String encoding)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, not null
        +
        Throws:
        +
        NullPointerException - if the file or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(File file,
        +                      String encoding,
        +                      boolean append)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(File file,
        +                      Charset encoding)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, not null
        +
        Throws:
        +
        NullPointerException - if the file or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(File file,
        +                      Charset encoding,
        +                      boolean append)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(File file,
        +                      CharsetEncoder encoding)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, not null
        +
        Throws:
        +
        NullPointerException - if the file or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        FileWriterWithEncoding

        +
        public FileWriterWithEncoding(File file,
        +                      CharsetEncoder encoding,
        +                      boolean append)
        +                       throws IOException
        +
        Constructs a FileWriterWithEncoding with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file or encoding is null
        +
        IOException - in case of an I/O error
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(int idx)
        +           throws IOException
        +
        Write a character.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        idx - the character to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr)
        +           throws IOException
        +
        Write the characters from an array.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        chr - the characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr,
        +         int st,
        +         int end)
        +           throws IOException
        +
        Write the specified characters from an array.
        +
        +
        Specified by:
        +
        write in class Writer
        +
        Parameters:
        chr - the characters to write
        st - The start offset
        end - The number of characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str)
        +           throws IOException
        +
        Write the characters from a string.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        str - the string to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str,
        +         int st,
        +         int end)
        +           throws IOException
        +
        Write the specified characters from a string.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        str - the string to write
        st - The start offset
        end - The number of characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/LockableFileWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/LockableFileWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..b7feb3c7083d107c61cbe29fe0b0ba90ce3b7997 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/LockableFileWriter.html" @@ -0,0 +1,693 @@ + + + + + +LockableFileWriter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class LockableFileWriter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, Appendable, AutoCloseable
    +
    +
    +
    +
    public class LockableFileWriter
    +extends Writer
    +
    FileWriter that will create and honor lock files to allow simple + cross thread file lock handling. +

    + This class provides a simple alternative to FileWriter + that will use a lock file to prevent duplicate writes. +

    + N.B. the lock file is deleted when close() is called + - or if the main file cannot be opened initially. + In the (unlikely) event that the lockfile cannot be deleted, + this is not reported, and subsequent requests using + the same lockfile will fail. +

    + By default, the file will be overwritten, but this may be changed to append. + The lock directory may be specified, but defaults to the system property + java.io.tmpdir. + The encoding may also be specified, and defaults to the platform default.

    +
    Version:
    +
    $Id: LockableFileWriter.java 1686747 2015-06-21 18:44:49Z krosenvold $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(String fileName)
        +                   throws IOException
        +
        Constructs a LockableFileWriter. + If the file exists, it is overwritten.
        +
        Parameters:
        fileName - the file to write to, not null
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(String fileName,
        +                  boolean append)
        +                   throws IOException
        +
        Constructs a LockableFileWriter.
        +
        Parameters:
        fileName - file to write to, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(String fileName,
        +                  boolean append,
        +                  String lockDir)
        +                   throws IOException
        +
        Constructs a LockableFileWriter.
        +
        Parameters:
        fileName - the file to write to, not null
        append - true if content should be appended, false to overwrite
        lockDir - the directory in which the lock file should be held
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(File file)
        +                   throws IOException
        +
        Constructs a LockableFileWriter. + If the file exists, it is overwritten.
        +
        Parameters:
        file - the file to write to, not null
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(File file,
        +                  boolean append)
        +                   throws IOException
        +
        Constructs a LockableFileWriter.
        +
        Parameters:
        file - the file to write to, not null
        append - true if content should be appended, false to overwrite
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        +
      • +
      + + + + + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(File file,
        +                  Charset encoding)
        +                   throws IOException
        +
        Constructs a LockableFileWriter with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, null means platform default
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        Since:
        +
        2.3
        +
      • +
      + + + + + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(File file,
        +                  Charset encoding,
        +                  boolean append,
        +                  String lockDir)
        +                   throws IOException
        +
        Constructs a LockableFileWriter with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, null means platform default
        append - true if content should be appended, false to overwrite
        lockDir - the directory in which the lock file should be held
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        Since:
        +
        2.3
        +
      • +
      + + + +
        +
      • +

        LockableFileWriter

        +
        public LockableFileWriter(File file,
        +                  String encoding,
        +                  boolean append,
        +                  String lockDir)
        +                   throws IOException
        +
        Constructs a LockableFileWriter with a file encoding.
        +
        Parameters:
        file - the file to write to, not null
        encoding - the encoding to use, null means platform default
        append - true if content should be appended, false to overwrite
        lockDir - the directory in which the lock file should be held
        +
        Throws:
        +
        NullPointerException - if the file is null
        +
        IOException - in case of an I/O error
        +
        UnsupportedCharsetException - thrown instead of UnsupportedEncodingException in version 2.2 if the encoding is not + supported.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + + + + + +
        +
      • +

        write

        +
        public void write(int idx)
        +           throws IOException
        +
        Write a character.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        idx - the character to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr)
        +           throws IOException
        +
        Write the characters from an array.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        chr - the characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr,
        +         int st,
        +         int end)
        +           throws IOException
        +
        Write the specified characters from an array.
        +
        +
        Specified by:
        +
        write in class Writer
        +
        Parameters:
        chr - the characters to write
        st - The start offset
        end - The number of characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str)
        +           throws IOException
        +
        Write the characters from a string.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        str - the string to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str,
        +         int st,
        +         int end)
        +           throws IOException
        +
        Write the specified characters from a string.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        str - the string to write
        st - The start offset
        end - The number of characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/NullOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/NullOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..b934a0ef408ad1b3a8e51cf7578cde042892de72 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/NullOutputStream.html" @@ -0,0 +1,372 @@ + + + + + +NullOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class NullOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class NullOutputStream
    +extends OutputStream
    +
    This OutputStream writes all data to the famous /dev/null. +

    + This output stream has no destination (file/socket etc.) and all + bytes written to it are ignored and lost. +

    +
    Version:
    +
    $Id: NullOutputStream.java 1674708 2015-04-20 00:02:45Z ggregory $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        NULL_OUTPUT_STREAM

        +
        public static final NullOutputStream NULL_OUTPUT_STREAM
        +
        A singleton.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NullOutputStream

        +
        public NullOutputStream()
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(byte[] b,
        +         int off,
        +         int len)
        +
        Does nothing - output to /dev/null.
        +
        +
        Overrides:
        +
        write in class OutputStream
        +
        Parameters:
        b - The bytes to write
        off - The start offset
        len - The number of bytes to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(int b)
        +
        Does nothing - output to /dev/null.
        +
        +
        Specified by:
        +
        write in class OutputStream
        +
        Parameters:
        b - The byte to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(byte[] b)
        +           throws IOException
        +
        Does nothing - output to /dev/null.
        +
        +
        Overrides:
        +
        write in class OutputStream
        +
        Parameters:
        b - The bytes to write
        +
        Throws:
        +
        IOException - never
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/NullWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/NullWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..f71956be1b89b131974e716108514db40a093c7e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/NullWriter.html" @@ -0,0 +1,531 @@ + + + + + +NullWriter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class NullWriter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, Appendable, AutoCloseable
    +
    +
    +
    +
    public class NullWriter
    +extends Writer
    +
    This Writer writes all data to the famous /dev/null. +

    + This Writer has no destination (file/socket etc.) and all + characters written to it are ignored and lost.

    +
    Version:
    +
    $Id: NullWriter.java 1471767 2013-04-24 23:24:19Z sebb $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Summary

      + + + + + + + + + + +
      Fields 
      Modifier and TypeField and Description
      static NullWriterNULL_WRITER +
      A singleton.
      +
      + +
    • +
    + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      NullWriter() +
      Constructs a new NullWriter.
      +
      +
    • +
    + + +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        NULL_WRITER

        +
        public static final NullWriter NULL_WRITER
        +
        A singleton.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        NullWriter

        +
        public NullWriter()
        +
        Constructs a new NullWriter.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        append

        +
        public Writer append(char c)
        +
        Does nothing - output to /dev/null.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        c - The character to write
        +
        Returns:
        this writer
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        append

        +
        public Writer append(CharSequence csq,
        +            int start,
        +            int end)
        +
        Does nothing - output to /dev/null.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        csq - The character sequence to write
        start - The index of the first character to write
        end - The index of the first character to write (exclusive)
        +
        Returns:
        this writer
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        append

        +
        public Writer append(CharSequence csq)
        +
        Does nothing - output to /dev/null.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        csq - The character sequence to write
        +
        Returns:
        this writer
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(int idx)
        +
        Does nothing - output to /dev/null.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        idx - The character to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr)
        +
        Does nothing - output to /dev/null.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        chr - The characters to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr,
        +         int st,
        +         int end)
        +
        Does nothing - output to /dev/null.
        +
        +
        Specified by:
        +
        write in class Writer
        +
        Parameters:
        chr - The characters to write
        st - The start offset
        end - The number of characters to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str)
        +
        Does nothing - output to /dev/null.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        str - The string to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str,
        +         int st,
        +         int end)
        +
        Does nothing - output to /dev/null.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        str - The string to write
        st - The start offset
        end - The number of characters to write
        +
      • +
      + + + + + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ProxyOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ProxyOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..0d99df0bd8027e1d5d2c7ed740b0d84d33843e08 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ProxyOutputStream.html" @@ -0,0 +1,492 @@ + + + + + +ProxyOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class ProxyOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    Direct Known Subclasses:
    +
    CloseShieldOutputStream, CountingOutputStream, TaggedOutputStream, TeeOutputStream
    +
    +
    +
    +
    public class ProxyOutputStream
    +extends FilterOutputStream
    +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called. It is an alternative base class to FilterOutputStream + to increase reusability. +

    + See the protected methods for ways in which a subclass can easily decorate + a stream with custom pre-, post- or error processing functionality.

    +
    Version:
    +
    $Id: ProxyOutputStream.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ProxyOutputStream(OutputStream proxy) +
      Constructs a new ProxyOutputStream.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      protected voidafterWrite(int n) +
      Invoked by the write methods after the proxied call has returned + successfully.
      +
      protected voidbeforeWrite(int n) +
      Invoked by the write methods before the call is proxied.
      +
      voidclose() +
      Invokes the delegate's close() method.
      +
      voidflush() +
      Invokes the delegate's flush() method.
      +
      protected voidhandleIOException(IOException e) +
      Handle any IOExceptions thrown.
      +
      voidwrite(byte[] bts) +
      Invokes the delegate's write(byte[]) method.
      +
      voidwrite(byte[] bts, + int st, + int end) +
      Invokes the delegate's write(byte[]) method.
      +
      voidwrite(int idx) +
      Invokes the delegate's write(int) method.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ProxyOutputStream

        +
        public ProxyOutputStream(OutputStream proxy)
        +
        Constructs a new ProxyOutputStream.
        +
        Parameters:
        proxy - the OutputStream to delegate to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(int idx)
        +           throws IOException
        +
        Invokes the delegate's write(int) method.
        +
        +
        Overrides:
        +
        write in class FilterOutputStream
        +
        Parameters:
        idx - the byte to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(byte[] bts)
        +           throws IOException
        +
        Invokes the delegate's write(byte[]) method.
        +
        +
        Overrides:
        +
        write in class FilterOutputStream
        +
        Parameters:
        bts - the bytes to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(byte[] bts,
        +         int st,
        +         int end)
        +           throws IOException
        +
        Invokes the delegate's write(byte[]) method.
        +
        +
        Overrides:
        +
        write in class FilterOutputStream
        +
        Parameters:
        bts - the bytes to write
        st - The start offset
        end - The number of bytes to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        beforeWrite

        +
        protected void beforeWrite(int n)
        +                    throws IOException
        +
        Invoked by the write methods before the call is proxied. The number + of bytes to be written (1 for the write(int) method, buffer + length for write(byte[]), etc.) is given as an argument. +

        + Subclasses can override this method to add common pre-processing + functionality without having to override all the write methods. + The default implementation does nothing.

        +
        Parameters:
        n - number of bytes to be written
        +
        Throws:
        +
        IOException - if the pre-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        afterWrite

        +
        protected void afterWrite(int n)
        +                   throws IOException
        +
        Invoked by the write methods after the proxied call has returned + successfully. The number of bytes written (1 for the + write(int) method, buffer length for write(byte[]), + etc.) is given as an argument. +

        + Subclasses can override this method to add common post-processing + functionality without having to override all the write methods. + The default implementation does nothing.

        +
        Parameters:
        n - number of bytes written
        +
        Throws:
        +
        IOException - if the post-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        handleIOException

        +
        protected void handleIOException(IOException e)
        +                          throws IOException
        +
        Handle any IOExceptions thrown. +

        + This method provides a point to implement custom exception + handling. The default behaviour is to re-throw the exception.

        +
        Parameters:
        e - The IOException thrown
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ProxyWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ProxyWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..bb12da77dfda38ae1c0a58407895a43aa3648e25 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ProxyWriter.html" @@ -0,0 +1,629 @@ + + + + + +ProxyWriter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class ProxyWriter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, Appendable, AutoCloseable
    +
    +
    +
    +
    public class ProxyWriter
    +extends FilterWriter
    +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called. It is an alternative base class to FilterWriter + to increase reusability, because FilterWriter changes the + methods being called, such as write(char[]) to write(char[], int, int) + and write(String) to write(String, int, int).
    +
    Version:
    +
    $Id: ProxyWriter.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
  • +
+
+
+
    +
  • + + + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ProxyWriter(Writer proxy) +
      Constructs a new ProxyWriter.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      protected voidafterWrite(int n) +
      Invoked by the write methods after the proxied call has returned + successfully.
      +
      Writerappend(char c) +
      Invokes the delegate's append(char) method.
      +
      Writerappend(CharSequence csq) +
      Invokes the delegate's append(CharSequence) method.
      +
      Writerappend(CharSequence csq, + int start, + int end) +
      Invokes the delegate's append(CharSequence, int, int) method.
      +
      protected voidbeforeWrite(int n) +
      Invoked by the write methods before the call is proxied.
      +
      voidclose() +
      Invokes the delegate's close() method.
      +
      voidflush() +
      Invokes the delegate's flush() method.
      +
      protected voidhandleIOException(IOException e) +
      Handle any IOExceptions thrown.
      +
      voidwrite(char[] chr) +
      Invokes the delegate's write(char[]) method.
      +
      voidwrite(char[] chr, + int st, + int len) +
      Invokes the delegate's write(char[], int, int) method.
      +
      voidwrite(int idx) +
      Invokes the delegate's write(int) method.
      +
      voidwrite(String str) +
      Invokes the delegate's write(String) method.
      +
      voidwrite(String str, + int st, + int len) +
      Invokes the delegate's write(String) method.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ProxyWriter

        +
        public ProxyWriter(Writer proxy)
        +
        Constructs a new ProxyWriter.
        +
        Parameters:
        proxy - the Writer to delegate to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        append

        +
        public Writer append(char c)
        +              throws IOException
        +
        Invokes the delegate's append(char) method.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        c - The character to write
        +
        Returns:
        this writer
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        append

        +
        public Writer append(CharSequence csq,
        +            int start,
        +            int end)
        +              throws IOException
        +
        Invokes the delegate's append(CharSequence, int, int) method.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        csq - The character sequence to write
        start - The index of the first character to write
        end - The index of the first character to write (exclusive)
        +
        Returns:
        this writer
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        append

        +
        public Writer append(CharSequence csq)
        +              throws IOException
        +
        Invokes the delegate's append(CharSequence) method.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        csq - The character sequence to write
        +
        Returns:
        this writer
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(int idx)
        +           throws IOException
        +
        Invokes the delegate's write(int) method.
        +
        +
        Overrides:
        +
        write in class FilterWriter
        +
        Parameters:
        idx - the character to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr)
        +           throws IOException
        +
        Invokes the delegate's write(char[]) method.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        chr - the characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] chr,
        +         int st,
        +         int len)
        +           throws IOException
        +
        Invokes the delegate's write(char[], int, int) method.
        +
        +
        Overrides:
        +
        write in class FilterWriter
        +
        Parameters:
        chr - the characters to write
        st - The start offset
        len - The number of characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str)
        +           throws IOException
        +
        Invokes the delegate's write(String) method.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        str - the string to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String str,
        +         int st,
        +         int len)
        +           throws IOException
        +
        Invokes the delegate's write(String) method.
        +
        +
        Overrides:
        +
        write in class FilterWriter
        +
        Parameters:
        str - the string to write
        st - The start offset
        len - The number of characters to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        beforeWrite

        +
        protected void beforeWrite(int n)
        +                    throws IOException
        +
        Invoked by the write methods before the call is proxied. The number + of chars to be written (1 for the write(int) method, buffer + length for write(char[]), etc.) is given as an argument. +

        + Subclasses can override this method to add common pre-processing + functionality without having to override all the write methods. + The default implementation does nothing.

        +
        Parameters:
        n - number of chars to be written
        +
        Throws:
        +
        IOException - if the pre-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        afterWrite

        +
        protected void afterWrite(int n)
        +                   throws IOException
        +
        Invoked by the write methods after the proxied call has returned + successfully. The number of chars written (1 for the + write(int) method, buffer length for write(char[]), + etc.) is given as an argument. +

        + Subclasses can override this method to add common post-processing + functionality without having to override all the write methods. + The default implementation does nothing.

        +
        Parameters:
        n - number of chars written
        +
        Throws:
        +
        IOException - if the post-processing fails
        Since:
        +
        2.0
        +
      • +
      + + + +
        +
      • +

        handleIOException

        +
        protected void handleIOException(IOException e)
        +                          throws IOException
        +
        Handle any IOExceptions thrown. +

        + This method provides a point to implement custom exception + handling. The default behaviour is to re-throw the exception.

        +
        Parameters:
        e - The IOException thrown
        +
        Throws:
        +
        IOException - if an I/O error occurs
        Since:
        +
        2.0
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/StringBuilderWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/StringBuilderWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..a0ebea07d8d5fc09d2e92b096b19cc9e74f3678b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/StringBuilderWriter.html" @@ -0,0 +1,524 @@ + + + + + +StringBuilderWriter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class StringBuilderWriter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, Serializable, Appendable, AutoCloseable
    +
    +
    +
    +
    public class StringBuilderWriter
    +extends Writer
    +implements Serializable
    +
    Writer implementation that outputs to a StringBuilder. +

    + NOTE: This implementation, as an alternative to + java.io.StringWriter, provides an un-synchronized + (i.e. for use in a single thread) implementation for better performance. + For safe usage with multiple Threads then + java.io.StringWriter should be used.

    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: StringBuilderWriter.java 1722253 2015-12-30 00:36:12Z ggregory $
    +
    See Also:
    Serialized Form
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        StringBuilderWriter

        +
        public StringBuilderWriter()
        +
        Constructs a new StringBuilder instance with default capacity.
        +
      • +
      + + + +
        +
      • +

        StringBuilderWriter

        +
        public StringBuilderWriter(int capacity)
        +
        Constructs a new StringBuilder instance with the specified capacity.
        +
        Parameters:
        capacity - The initial capacity of the underlying StringBuilder
        +
      • +
      + + + +
        +
      • +

        StringBuilderWriter

        +
        public StringBuilderWriter(StringBuilder builder)
        +
        Constructs a new instance with the specified StringBuilder. + +

        If builder is null a new instance with default capacity will be created.

        +
        Parameters:
        builder - The String builder. May be null.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        append

        +
        public Writer append(char value)
        +
        Appends a single character to this Writer.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        value - The character to append
        +
        Returns:
        This writer instance
        +
      • +
      + + + +
        +
      • +

        append

        +
        public Writer append(CharSequence value)
        +
        Appends a character sequence to this Writer.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        value - The character to append
        +
        Returns:
        This writer instance
        +
      • +
      + + + +
        +
      • +

        append

        +
        public Writer append(CharSequence value,
        +            int start,
        +            int end)
        +
        Appends a portion of a character sequence to the StringBuilder.
        +
        +
        Specified by:
        +
        append in interface Appendable
        +
        Overrides:
        +
        append in class Writer
        +
        Parameters:
        value - The character to append
        start - The index of the first character
        end - The index of the last character + 1
        +
        Returns:
        This writer instance
        +
      • +
      + + + + + + + +
        +
      • +

        flush

        +
        public void flush()
        +
        Flushing this writer has no effect.
        +
        +
        Specified by:
        +
        flush in interface Flushable
        +
        Specified by:
        +
        flush in class Writer
        +
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(String value)
        +
        Writes a String to the StringBuilder.
        +
        +
        Overrides:
        +
        write in class Writer
        +
        Parameters:
        value - The value to write
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] value,
        +         int offset,
        +         int length)
        +
        Writes a portion of a character array to the StringBuilder.
        +
        +
        Specified by:
        +
        write in class Writer
        +
        Parameters:
        value - The value to write
        offset - The index of the first character
        length - The number of characters to write
        +
      • +
      + + + +
        +
      • +

        getBuilder

        +
        public StringBuilder getBuilder()
        +
        Returns the underlying builder.
        +
        Returns:
        The underlying builder
        +
      • +
      + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/TaggedOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/TaggedOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..0d3b0b2dd35a9b9728452e12cacbb8b3918953ad --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/TaggedOutputStream.html" @@ -0,0 +1,390 @@ + + + + + +TaggedOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class TaggedOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class TaggedOutputStream
    +extends ProxyOutputStream
    +
    An output stream decorator that tags potential exceptions so that the + stream that caused the exception can easily be identified. This is + done by using the TaggedIOException class to wrap all thrown + IOExceptions. See below for an example of using this class. +
    + TaggedOutputStream stream = new TaggedOutputStream(...);
    + try {
    +     // Processing that may throw an IOException either from this stream
    +     // or from some other IO activity like temporary files, etc.
    +     writeToStream(stream);
    + } catch (IOException e) {
    +     if (stream.isCauseOf(e)) {
    +         // The exception was caused by this stream.
    +         // Use e.getCause() to get the original exception.
    +     } else {
    +         // The exception was caused by something else.
    +     }
    + }
    + 
    +

    + Alternatively, the throwIfCauseOf(Exception) method can be + used to let higher levels of code handle the exception caused by this + stream while other processing errors are being taken care of at this + lower level. +

    + TaggedOutputStream stream = new TaggedOutputStream(...);
    + try {
    +     writeToStream(stream);
    + } catch (IOException e) {
    +     stream.throwIfCauseOf(e);
    +     // ... or process the exception that was caused by something else
    + }
    + 
    +
    Since:
    +
    2.0
    +
    See Also:
    TaggedIOException
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TaggedOutputStream

        +
        public TaggedOutputStream(OutputStream proxy)
        +
        Creates a tagging decorator for the given output stream.
        +
        Parameters:
        proxy - output stream to be decorated
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        isCauseOf

        +
        public boolean isCauseOf(Exception exception)
        +
        Tests if the given exception was caused by this stream.
        +
        Parameters:
        exception - an exception
        +
        Returns:
        true if the exception was thrown by this stream, + false otherwise
        +
      • +
      + + + +
        +
      • +

        throwIfCauseOf

        +
        public void throwIfCauseOf(Exception exception)
        +                    throws IOException
        +
        Re-throws the original exception thrown by this stream. This method + first checks whether the given exception is a TaggedIOException + wrapper created by this decorator, and then unwraps and throws the + original wrapped exception. Returns normally if the exception was + not thrown by this stream.
        +
        Parameters:
        exception - an exception
        +
        Throws:
        +
        IOException - original exception, if any, thrown by this stream
        +
      • +
      + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/TeeOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/TeeOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..f4a70a4145b3991843f671ecf8ba2bb9e93928d3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/TeeOutputStream.html" @@ -0,0 +1,454 @@ + + + + + +TeeOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class TeeOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class TeeOutputStream
    +extends ProxyOutputStream
    +
    Classic splitter of OutputStream. Named after the unix 'tee' + command. It allows a stream to be branched off so there + are now two streams.
    +
    Version:
    +
    $Id: TeeOutputStream.java 1686503 2015-06-19 21:32:13Z sebb $
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Field Detail

      + + + +
        +
      • +

        branch

        +
        protected OutputStream branch
        +
        the second OutputStream to write to
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        TeeOutputStream

        +
        public TeeOutputStream(OutputStream out,
        +               OutputStream branch)
        +
        Constructs a TeeOutputStream.
        +
        Parameters:
        out - the main OutputStream
        branch - the second OutputStream
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(byte[] b)
        +           throws IOException
        +
        Write the bytes to both streams.
        +
        +
        Overrides:
        +
        write in class ProxyOutputStream
        +
        Parameters:
        b - the bytes to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(byte[] b,
        +         int off,
        +         int len)
        +           throws IOException
        +
        Write the specified bytes to both streams.
        +
        +
        Overrides:
        +
        write in class ProxyOutputStream
        +
        Parameters:
        b - the bytes to write
        off - The start offset
        len - The number of bytes to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(int b)
        +           throws IOException
        +
        Write a byte to both streams.
        +
        +
        Overrides:
        +
        write in class ProxyOutputStream
        +
        Parameters:
        b - the byte to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + +
        +
      • +

        close

        +
        public void close()
        +           throws IOException
        +
        Closes both output streams. + + If closing the main output stream throws an exception, attempt to close the branch output stream. + + If closing the main and branch output streams both throw exceptions, which exceptions is thrown by this method is + currently unspecified and subject to change.
        +
        +
        Specified by:
        +
        close in interface Closeable
        +
        Specified by:
        +
        close in interface AutoCloseable
        +
        Overrides:
        +
        close in class ProxyOutputStream
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ThresholdingOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ThresholdingOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..dd315786eaaeae6fa1dd99add4b79f1f0827f2ee --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/ThresholdingOutputStream.html" @@ -0,0 +1,566 @@ + + + + + +ThresholdingOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class ThresholdingOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    Direct Known Subclasses:
    +
    DeferredFileOutputStream
    +
    +
    +
    +
    public abstract class ThresholdingOutputStream
    +extends OutputStream
    +
    An output stream which triggers an event when a specified number of bytes of + data have been written to it. The event can be used, for example, to throw + an exception if a maximum has been reached, or to switch the underlying + stream type when the threshold is exceeded. +

    + This class overrides all OutputStream methods. However, these + overrides ultimately call the corresponding methods in the underlying output + stream implementation. +

    + NOTE: This implementation may trigger the event before the threshold + is actually reached, since it triggers when a pending write operation would + cause the threshold to be exceeded.

    +
    Version:
    +
    $Id: ThresholdingOutputStream.java 1687815 2015-06-26 17:18:56Z krosenvold $
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Summary

      + + + + + + + + +
      Constructors 
      Constructor and Description
      ThresholdingOutputStream(int threshold) +
      Constructs an instance of this class which will trigger an event at the + specified threshold.
      +
      +
    • +
    + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      protected voidcheckThreshold(int count) +
      Checks to see if writing the specified number of bytes would cause the + configured threshold to be exceeded.
      +
      voidclose() +
      Closes this output stream and releases any system resources associated + with this stream.
      +
      voidflush() +
      Flushes this output stream and forces any buffered output bytes to be + written out.
      +
      longgetByteCount() +
      Returns the number of bytes that have been written to this output stream.
      +
      protected abstract OutputStreamgetStream() +
      Returns the underlying output stream, to which the corresponding + OutputStream methods in this class will ultimately delegate.
      +
      intgetThreshold() +
      Returns the threshold, in bytes, at which an event will be triggered.
      +
      booleanisThresholdExceeded() +
      Determines whether or not the configured threshold has been exceeded for + this output stream.
      +
      protected voidresetByteCount() +
      Resets the byteCount to zero.
      +
      protected voidsetByteCount(long count) +
      Sets the byteCount to count.
      +
      protected abstract voidthresholdReached() +
      Indicates that the configured threshold has been reached, and that a + subclass should take whatever action necessary on this event.
      +
      voidwrite(byte[] b) +
      Writes b.length bytes from the specified byte array to this + output stream.
      +
      voidwrite(byte[] b, + int off, + int len) +
      Writes len bytes from the specified byte array starting at + offset off to this output stream.
      +
      voidwrite(int b) +
      Writes the specified byte to this output stream.
      +
      + +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ThresholdingOutputStream

        +
        public ThresholdingOutputStream(int threshold)
        +
        Constructs an instance of this class which will trigger an event at the + specified threshold.
        +
        Parameters:
        threshold - The number of bytes at which to trigger an event.
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(int b)
        +           throws IOException
        +
        Writes the specified byte to this output stream.
        +
        +
        Specified by:
        +
        write in class OutputStream
        +
        Parameters:
        b - The byte to be written.
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(byte[] b)
        +           throws IOException
        +
        Writes b.length bytes from the specified byte array to this + output stream.
        +
        +
        Overrides:
        +
        write in class OutputStream
        +
        Parameters:
        b - The array of bytes to be written.
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(byte[] b,
        +         int off,
        +         int len)
        +           throws IOException
        +
        Writes len bytes from the specified byte array starting at + offset off to this output stream.
        +
        +
        Overrides:
        +
        write in class OutputStream
        +
        Parameters:
        b - The byte array from which the data will be written.
        off - The start offset in the byte array.
        len - The number of bytes to write.
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + +
        +
      • +

        flush

        +
        public void flush()
        +           throws IOException
        +
        Flushes this output stream and forces any buffered output bytes to be + written out.
        +
        +
        Specified by:
        +
        flush in interface Flushable
        +
        Overrides:
        +
        flush in class OutputStream
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + + + + + +
        +
      • +

        getThreshold

        +
        public int getThreshold()
        +
        Returns the threshold, in bytes, at which an event will be triggered.
        +
        Returns:
        The threshold point, in bytes.
        +
      • +
      + + + +
        +
      • +

        getByteCount

        +
        public long getByteCount()
        +
        Returns the number of bytes that have been written to this output stream.
        +
        Returns:
        The number of bytes written.
        +
      • +
      + + + +
        +
      • +

        isThresholdExceeded

        +
        public boolean isThresholdExceeded()
        +
        Determines whether or not the configured threshold has been exceeded for + this output stream.
        +
        Returns:
        true if the threshold has been reached; + false otherwise.
        +
      • +
      + + + +
        +
      • +

        checkThreshold

        +
        protected void checkThreshold(int count)
        +                       throws IOException
        +
        Checks to see if writing the specified number of bytes would cause the + configured threshold to be exceeded. If so, triggers an event to allow + a concrete implementation to take action on this.
        +
        Parameters:
        count - The number of bytes about to be written to the underlying + output stream.
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + +
        +
      • +

        resetByteCount

        +
        protected void resetByteCount()
        +
        Resets the byteCount to zero. You can call this from + thresholdReached() if you want the event to be triggered again.
        +
      • +
      + + + +
        +
      • +

        setByteCount

        +
        protected void setByteCount(long count)
        +
        Sets the byteCount to count. Usefull for re-opening an output stream + that been previously written to.
        +
        Parameters:
        count - The number of bytes that have already been written to the + output stream
        Since:
        +
        2.5
        +
      • +
      + + + +
        +
      • +

        getStream

        +
        protected abstract OutputStream getStream()
        +                                   throws IOException
        +
        Returns the underlying output stream, to which the corresponding + OutputStream methods in this class will ultimately delegate.
        +
        Returns:
        The underlying output stream.
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      + + + +
        +
      • +

        thresholdReached

        +
        protected abstract void thresholdReached()
        +                                  throws IOException
        +
        Indicates that the configured threshold has been reached, and that a + subclass should take whatever action necessary on this event. This may + include changing the underlying output stream.
        +
        Throws:
        +
        IOException - if an error occurs.
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/WriterOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/WriterOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..37f0713456a5c8c42ef6df37c960fe4276e9c50c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/WriterOutputStream.html" @@ -0,0 +1,573 @@ + + + + + +WriterOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class WriterOutputStream

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, AutoCloseable
    +
    +
    +
    +
    public class WriterOutputStream
    +extends OutputStream
    +
    OutputStream implementation that transforms a byte stream to a + character stream using a specified charset encoding and writes the resulting + stream to a Writer. The stream is transformed using a + CharsetDecoder object, guaranteeing that all charset + encodings supported by the JRE are handled correctly. +

    + The output of the CharsetDecoder is buffered using a fixed size buffer. + This implies that the data is written to the underlying Writer in chunks + that are no larger than the size of this buffer. By default, the buffer is + flushed only when it overflows or when flush() or close() + is called. In general there is therefore no need to wrap the underlying Writer + in a BufferedWriter. WriterOutputStream can also + be instructed to flush the buffer after each write operation. In this case, all + available data is written immediately to the underlying Writer, implying that + the current position of the Writer is correlated to the current position + of the WriterOutputStream. +

    + WriterOutputStream implements the inverse transformation of OutputStreamWriter; + in the following example, writing to out2 would have the same result as writing to + out directly (provided that the byte sequence is legal with respect to the + charset encoding): +

    + OutputStream out = ...
    + Charset cs = ...
    + OutputStreamWriter writer = new OutputStreamWriter(out, cs);
    + WriterOutputStream out2 = new WriterOutputStream(writer, cs);
    + WriterOutputStream implements the same transformation as InputStreamReader, + except that the control flow is reversed: both classes transform a byte stream + into a character stream, but InputStreamReader pulls data from the underlying stream, + while WriterOutputStream pushes it to the underlying stream. +

    + Note that while there are use cases where there is no alternative to using + this class, very often the need to use this class is an indication of a flaw + in the design of the code. This class is typically used in situations where an existing + API only accepts an OutputStream object, but where the stream is known to represent + character data that must be decoded for further use. +

    + Instances of WriterOutputStream are not thread safe.

    +
    Since:
    +
    2.0
    +
    See Also:
    ReaderInputStream
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        WriterOutputStream

        +
        public WriterOutputStream(Writer writer,
        +                  CharsetDecoder decoder)
        +
        Constructs a new WriterOutputStream with a default output buffer size of + 1024 characters. The output buffer will only be flushed when it overflows or when + flush() or close() is called.
        +
        Parameters:
        writer - the target Writer
        decoder - the charset decoder
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        WriterOutputStream

        +
        public WriterOutputStream(Writer writer,
        +                  CharsetDecoder decoder,
        +                  int bufferSize,
        +                  boolean writeImmediately)
        +
        Constructs a new WriterOutputStream.
        +
        Parameters:
        writer - the target Writer
        decoder - the charset decoder
        bufferSize - the size of the output buffer in number of characters
        writeImmediately - If true the output buffer will be flushed after each + write operation, i.e. all available data will be written to the + underlying Writer immediately. If false, the + output buffer will only be flushed when it overflows or when + flush() or close() is called.
        Since:
        +
        2.1
        +
      • +
      + + + +
        +
      • +

        WriterOutputStream

        +
        public WriterOutputStream(Writer writer,
        +                  Charset charset,
        +                  int bufferSize,
        +                  boolean writeImmediately)
        +
        Constructs a new WriterOutputStream.
        +
        Parameters:
        writer - the target Writer
        charset - the charset encoding
        bufferSize - the size of the output buffer in number of characters
        writeImmediately - If true the output buffer will be flushed after each + write operation, i.e. all available data will be written to the + underlying Writer immediately. If false, the + output buffer will only be flushed when it overflows or when + flush() or close() is called.
        +
      • +
      + + + +
        +
      • +

        WriterOutputStream

        +
        public WriterOutputStream(Writer writer,
        +                  Charset charset)
        +
        Constructs a new WriterOutputStream with a default output buffer size of + 1024 characters. The output buffer will only be flushed when it overflows or when + flush() or close() is called.
        +
        Parameters:
        writer - the target Writer
        charset - the charset encoding
        +
      • +
      + + + +
        +
      • +

        WriterOutputStream

        +
        public WriterOutputStream(Writer writer,
        +                  String charsetName,
        +                  int bufferSize,
        +                  boolean writeImmediately)
        +
        Constructs a new WriterOutputStream.
        +
        Parameters:
        writer - the target Writer
        charsetName - the name of the charset encoding
        bufferSize - the size of the output buffer in number of characters
        writeImmediately - If true the output buffer will be flushed after each + write operation, i.e. all available data will be written to the + underlying Writer immediately. If false, the + output buffer will only be flushed when it overflows or when + flush() or close() is called.
        +
      • +
      + + + +
        +
      • +

        WriterOutputStream

        +
        public WriterOutputStream(Writer writer,
        +                  String charsetName)
        +
        Constructs a new WriterOutputStream with a default output buffer size of + 1024 characters. The output buffer will only be flushed when it overflows or when + flush() or close() is called.
        +
        Parameters:
        writer - the target Writer
        charsetName - the name of the charset encoding
        +
      • +
      + + + + +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        write

        +
        public void write(byte[] b,
        +         int off,
        +         int len)
        +           throws IOException
        +
        Write bytes from the specified byte array to the stream.
        +
        +
        Overrides:
        +
        write in class OutputStream
        +
        Parameters:
        b - the byte array containing the bytes to write
        off - the start offset in the byte array
        len - the number of bytes to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(byte[] b)
        +           throws IOException
        +
        Write bytes from the specified byte array to the stream.
        +
        +
        Overrides:
        +
        write in class OutputStream
        +
        Parameters:
        b - the byte array containing the bytes to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(int b)
        +           throws IOException
        +
        Write a single byte to the stream.
        +
        +
        Specified by:
        +
        write in class OutputStream
        +
        Parameters:
        b - the byte to write
        +
        Throws:
        +
        IOException - if an I/O error occurs
        +
      • +
      + + + + + + + + +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/XmlStreamWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/XmlStreamWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..ae2faac075bc3865f446dd45dc6c277f9a51cc8d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/XmlStreamWriter.html" @@ -0,0 +1,464 @@ + + + + + +XmlStreamWriter (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.output
+

Class XmlStreamWriter

+
+
+ +
+
    +
  • +
    +
    All Implemented Interfaces:
    +
    Closeable, Flushable, Appendable, AutoCloseable
    +
    +
    +
    +
    public class XmlStreamWriter
    +extends Writer
    +
    Character stream that handles all the necessary Voodo to figure out the + charset encoding of the XML document written to the stream.
    +
    Since:
    +
    2.0
    +
    Version:
    +
    $Id: XmlStreamWriter.java 1415850 2012-11-30 20:51:39Z ggregory $
    +
    See Also:
    XmlStreamReader
    +
  • +
+
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        XmlStreamWriter

        +
        public XmlStreamWriter(OutputStream out)
        +
        Construct an new XML stream writer for the specified output stream + with a default encoding of UTF-8.
        +
        Parameters:
        out - The output stream
        +
      • +
      + + + +
        +
      • +

        XmlStreamWriter

        +
        public XmlStreamWriter(OutputStream out,
        +               String defaultEncoding)
        +
        Construct an new XML stream writer for the specified output stream + with the specified default encoding.
        +
        Parameters:
        out - The output stream
        defaultEncoding - The default encoding if not encoding could be detected
        +
      • +
      + + + +
        +
      • +

        XmlStreamWriter

        +
        public XmlStreamWriter(File file)
        +                throws FileNotFoundException
        +
        Construct an new XML stream writer for the specified file + with a default encoding of UTF-8.
        +
        Parameters:
        file - The file to write to
        +
        Throws:
        +
        FileNotFoundException - if there is an error creating or + opening the file
        +
      • +
      + + + +
        +
      • +

        XmlStreamWriter

        +
        public XmlStreamWriter(File file,
        +               String defaultEncoding)
        +                throws FileNotFoundException
        +
        Construct an new XML stream writer for the specified file + with the specified default encoding.
        +
        Parameters:
        file - The file to write to
        defaultEncoding - The default encoding if not encoding could be detected
        +
        Throws:
        +
        FileNotFoundException - if there is an error creating or + opening the file
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        getEncoding

        +
        public String getEncoding()
        +
        Return the detected encoding.
        +
        Returns:
        the detected encoding
        +
      • +
      + + + +
        +
      • +

        getDefaultEncoding

        +
        public String getDefaultEncoding()
        +
        Return the default encoding.
        +
        Returns:
        the default encoding
        +
      • +
      + + + + + + + +
        +
      • +

        flush

        +
        public void flush()
        +           throws IOException
        +
        Flush the underlying writer.
        +
        +
        Specified by:
        +
        flush in interface Flushable
        +
        Specified by:
        +
        flush in class Writer
        +
        Throws:
        +
        IOException - if an error occurs flushing the underlying writer
        +
      • +
      + + + +
        +
      • +

        write

        +
        public void write(char[] cbuf,
        +         int off,
        +         int len)
        +           throws IOException
        +
        Write the characters to the underlying writer, detecing encoding.
        +
        +
        Specified by:
        +
        write in class Writer
        +
        Parameters:
        cbuf - the buffer to write the characters from
        off - The start offset
        len - The number of characters to write
        +
        Throws:
        +
        IOException - if an error occurs detecting the encoding
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/AppendableOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/AppendableOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..9f09f73724fbde5b489e9512cb7f8e6da7f6c175 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/AppendableOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.AppendableOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.AppendableOutputStream

+
+
No usage of org.apache.commons.io.output.AppendableOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/BrokenOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/BrokenOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..97d04af37e81978302255c65cecad9077037b1db --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/BrokenOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.BrokenOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.BrokenOutputStream

+
+
No usage of org.apache.commons.io.output.BrokenOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ByteArrayOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ByteArrayOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..7a028b5462071807bfa7cfe7041c8e56f10e6843 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ByteArrayOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.ByteArrayOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.ByteArrayOutputStream

+
+
No usage of org.apache.commons.io.output.ByteArrayOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ChunkedOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ChunkedOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..90956545aff6fb188df39eef4001e40ff60a42c0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ChunkedOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.ChunkedOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.ChunkedOutputStream

+
+
No usage of org.apache.commons.io.output.ChunkedOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ChunkedWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ChunkedWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..21d33116b188d74301680e398b5f4061e199ae44 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ChunkedWriter.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.ChunkedWriter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.ChunkedWriter

+
+
No usage of org.apache.commons.io.output.ChunkedWriter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/CloseShieldOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/CloseShieldOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..00afc5af83930a1b7ac2253d152122e06b3798b0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/CloseShieldOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.CloseShieldOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.CloseShieldOutputStream

+
+
No usage of org.apache.commons.io.output.CloseShieldOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ClosedOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ClosedOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..b4733595b4dcedabeaa97c3c532ceb99051f15f2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ClosedOutputStream.html" @@ -0,0 +1,161 @@ + + + + + +Uses of Class org.apache.commons.io.output.ClosedOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.ClosedOutputStream

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/CountingOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/CountingOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..50edf43d2faf6dd649e592bd56d59a3be7a60f72 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/CountingOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.CountingOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.CountingOutputStream

+
+
No usage of org.apache.commons.io.output.CountingOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/DeferredFileOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/DeferredFileOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..a1d2fd9e256a95dbd3cae2c89f668dbc35382152 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/DeferredFileOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.DeferredFileOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.DeferredFileOutputStream

+
+
No usage of org.apache.commons.io.output.DeferredFileOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/DemuxOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/DemuxOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..ff9ba7d03248207b6030ef1b0a41afec1289b938 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/DemuxOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.DemuxOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.DemuxOutputStream

+
+
No usage of org.apache.commons.io.output.DemuxOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/FileWriterWithEncoding.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/FileWriterWithEncoding.html" new file mode 100644 index 0000000000000000000000000000000000000000..83c3cb4d251ff6b1440c44db7befde37f3fe5d35 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/FileWriterWithEncoding.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.FileWriterWithEncoding (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.FileWriterWithEncoding

+
+
No usage of org.apache.commons.io.output.FileWriterWithEncoding
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/LockableFileWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/LockableFileWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..70a2fbabd79f72fd3fbc126806a19c74fbdd70f1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/LockableFileWriter.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.LockableFileWriter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.LockableFileWriter

+
+
No usage of org.apache.commons.io.output.LockableFileWriter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/NullOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/NullOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..f7d494b46833b73cd15090565a42e957865729b1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/NullOutputStream.html" @@ -0,0 +1,161 @@ + + + + + +Uses of Class org.apache.commons.io.output.NullOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.NullOutputStream

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/NullWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/NullWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..b2c8c0527b5094cef02f0680e323391374a806d3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/NullWriter.html" @@ -0,0 +1,161 @@ + + + + + +Uses of Class org.apache.commons.io.output.NullWriter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.NullWriter

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ProxyOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ProxyOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..d45de06147bed6acac45d602aab028f89cfd2e1e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ProxyOutputStream.html" @@ -0,0 +1,181 @@ + + + + + +Uses of Class org.apache.commons.io.output.ProxyOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.ProxyOutputStream

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ProxyWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ProxyWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..20707c7d9643bcd583a273a6bf7d239ca4440c31 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ProxyWriter.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.ProxyWriter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.ProxyWriter

+
+
No usage of org.apache.commons.io.output.ProxyWriter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/StringBuilderWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/StringBuilderWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..df2bb7489a410f95363901acec30b850ebace069 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/StringBuilderWriter.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.StringBuilderWriter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.StringBuilderWriter

+
+
No usage of org.apache.commons.io.output.StringBuilderWriter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/TaggedOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/TaggedOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..a55c5d9e3594590fae68190c70c3de644227cda6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/TaggedOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.TaggedOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.TaggedOutputStream

+
+
No usage of org.apache.commons.io.output.TaggedOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/TeeOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/TeeOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..850cbfd503dcb345067b794cc831eae2c8514b31 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/TeeOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.TeeOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.TeeOutputStream

+
+
No usage of org.apache.commons.io.output.TeeOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ThresholdingOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ThresholdingOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..8a06407928fa8d62b7b3618821afba7c51d15b34 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/ThresholdingOutputStream.html" @@ -0,0 +1,162 @@ + + + + + +Uses of Class org.apache.commons.io.output.ThresholdingOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.ThresholdingOutputStream

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/WriterOutputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/WriterOutputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..be25656ac9bea3ec545f7beba0dba550ba997351 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/WriterOutputStream.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.WriterOutputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.WriterOutputStream

+
+
No usage of org.apache.commons.io.output.WriterOutputStream
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/XmlStreamWriter.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/XmlStreamWriter.html" new file mode 100644 index 0000000000000000000000000000000000000000..f1f260e96c8cd50ad8b367d5fc478b32fa8c1bd2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/class-use/XmlStreamWriter.html" @@ -0,0 +1,115 @@ + + + + + +Uses of Class org.apache.commons.io.output.XmlStreamWriter (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.output.XmlStreamWriter

+
+
No usage of org.apache.commons.io.output.XmlStreamWriter
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-frame.html" new file mode 100644 index 0000000000000000000000000000000000000000..6c5a4c2164222a7fe9929ca6390cd101da8ba0b1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-frame.html" @@ -0,0 +1,39 @@ + + + + + +org.apache.commons.io.output (Apache Commons IO 2.5 API) + + + +

org.apache.commons.io.output

+ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-summary.html" new file mode 100644 index 0000000000000000000000000000000000000000..4201e5abe2b22ce7eb3d3be8e8effd80d548c5de --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-summary.html" @@ -0,0 +1,289 @@ + + + + + +org.apache.commons.io.output (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Package org.apache.commons.io.output

+
+
+This package provides implementations of output classes, such as +OutputStream and Writer.
+
+

See: Description

+
+
+
    +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    AppendableOutputStream<T extends Appendable> +
    OutputStream implementation that writes the data to an Appendable + Object.
    +
    BrokenOutputStream +
    Broken output stream.
    +
    ByteArrayOutputStream +
    This class implements an output stream in which the data is + written into a byte array.
    +
    ChunkedOutputStream +
    OutputStream which breaks larger output blocks into chunks.
    +
    ChunkedWriter +
    Writer which breaks larger output blocks into chunks.
    +
    ClosedOutputStream +
    Closed output stream.
    +
    CloseShieldOutputStream +
    Proxy stream that prevents the underlying output stream from being closed.
    +
    CountingOutputStream +
    A decorating output stream that counts the number of bytes that have passed + through the stream so far.
    +
    DeferredFileOutputStream +
    An output stream which will retain data in memory until a specified + threshold is reached, and only then commit it to disk.
    +
    DemuxOutputStream +
    Forwards data to a stream that has been associated with this thread.
    +
    FileWriterWithEncoding +
    Writer of files that allows the encoding to be set.
    +
    LockableFileWriter +
    FileWriter that will create and honor lock files to allow simple + cross thread file lock handling.
    +
    NullOutputStream +
    This OutputStream writes all data to the famous /dev/null.
    +
    NullWriter +
    This Writer writes all data to the famous /dev/null.
    +
    ProxyOutputStream +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
    +
    ProxyWriter +
    A Proxy stream which acts as expected, that is it passes the method + calls on to the proxied stream and doesn't change which methods are + being called.
    +
    StringBuilderWriter +
    Writer implementation that outputs to a StringBuilder.
    +
    TaggedOutputStream +
    An output stream decorator that tags potential exceptions so that the + stream that caused the exception can easily be identified.
    +
    TeeOutputStream +
    Classic splitter of OutputStream.
    +
    ThresholdingOutputStream +
    An output stream which triggers an event when a specified number of bytes of + data have been written to it.
    +
    WriterOutputStream +
    OutputStream implementation that transforms a byte stream to a + character stream using a specified charset encoding and writes the resulting + stream to a Writer.
    +
    XmlStreamWriter +
    Character stream that handles all the necessary Voodo to figure out the + charset encoding of the XML document written to the stream.
    +
    +
  • +
+ + + +

Package org.apache.commons.io.output Description

+

+This package provides implementations of output classes, such as +OutputStream and Writer. +

+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-tree.html" new file mode 100644 index 0000000000000000000000000000000000000000..91f523068dcda25bb8a17a65c02c75c62ded9e36 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-tree.html" @@ -0,0 +1,171 @@ + + + + + +org.apache.commons.io.output Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package org.apache.commons.io.output

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-use.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-use.html" new file mode 100644 index 0000000000000000000000000000000000000000..86907aae7323192bf7100dddd6b5613e95d3d5c6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/output/package-use.html" @@ -0,0 +1,177 @@ + + + + + +Uses of Package org.apache.commons.io.output (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Package
org.apache.commons.io.output

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-frame.html" new file mode 100644 index 0000000000000000000000000000000000000000..6ea3e186ca1ea5c646588842164f4e7a917299d1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-frame.html" @@ -0,0 +1,42 @@ + + + + + +org.apache.commons.io (Apache Commons IO 2.5 API) + + + +

org.apache.commons.io

+ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-summary.html" new file mode 100644 index 0000000000000000000000000000000000000000..16b611ed9e4ad320f84b4da4e090263376465252 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-summary.html" @@ -0,0 +1,305 @@ + + + + + +org.apache.commons.io (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Package org.apache.commons.io

+
+
+This package defines utility classes for working with streams, readers, +writers and files.
+
+

See: Description

+
+
+
    +
  • + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    ByteOrderMark +
    Byte Order Mark (BOM) representation - see BOMInputStream.
    +
    Charsets +
    Charsets required of every implementation of the Java platform.
    +
    CopyUtilsDeprecated +
    Use IOUtils.
    +
    DirectoryWalker<T> +
    Abstract class that walks through a directory hierarchy and provides + subclasses with convenient hooks to add specific behaviour.
    +
    EndianUtils +
    Utility code for dealing with different endian systems.
    +
    FileCleanerDeprecated + +
    FileCleaningTracker +
    Keeps track of files awaiting deletion, and deletes them when an associated + marker object is reclaimed by the garbage collector.
    +
    FileDeleteStrategy +
    Strategy for deleting files.
    +
    FilenameUtils +
    General filename and filepath manipulation utilities.
    +
    FileSystemUtils +
    General File System utilities.
    +
    FileUtils +
    General file manipulation utilities.
    +
    HexDump +
    Dumps data in hexadecimal format.
    +
    IOUtils +
    General IO stream manipulation utilities.
    +
    LineIterator +
    An Iterator over the lines in a Reader.
    +
    +
  • +
  • + + + + + + + + + + + + +
    Enum Summary 
    EnumDescription
    IOCase +
    Enumeration of IO case sensitivity.
    +
    +
  • +
  • + + + + + + + + + + + + + + + + + + + + + + + + +
    Exception Summary 
    ExceptionDescription
    DirectoryWalker.CancelException +
    CancelException is thrown in DirectoryWalker to cancel the current + processing.
    +
    FileExistsException +
    Indicates that a file already exists.
    +
    IOExceptionWithCauseDeprecated +
    (since 2.5) use IOException instead
    +
    TaggedIOException +
    An IOException decorator that adds a serializable tag to the + wrapped exception.
    +
    +
  • +
+ + + +

Package org.apache.commons.io Description

+

+This package defines utility classes for working with streams, readers, +writers and files. The most commonly used classes are described here: +

+

+IOUtils is the most frequently used class. +It provides operations to read, write, copy and close streams. +

+

+FileUtils provides operations based around the JDK File class. +These include reading, writing, copying, comparing and deleting. +

+

+FilenameUtils provides utilities based on filenames. +This utility class manipulates filenames without using File objects. +It aims to simplify the transition between Windows and Unix. +Before using this class however, you should consider whether you should +be using File objects. +

+

+FileSystemUtils allows access to the filing system in ways the JDK +does not support. At present this allows you to get the free space on a drive. +

+

+EndianUtils swaps data between Big-Endian and Little-Endian formats. +

+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-tree.html" new file mode 100644 index 0000000000000000000000000000000000000000..6215d5211af84429bfb48d672ce4a4143ed611d6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-tree.html" @@ -0,0 +1,172 @@ + + + + + +org.apache.commons.io Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package org.apache.commons.io

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Enum Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-use.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-use.html" new file mode 100644 index 0000000000000000000000000000000000000000..8f29ded37b5ef140deb57e341fe12fc93f4b18e6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/package-use.html" @@ -0,0 +1,286 @@ + + + + + +Uses of Package org.apache.commons.io (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Package
org.apache.commons.io

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/ClassNameMatcher.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/ClassNameMatcher.html" new file mode 100644 index 0000000000000000000000000000000000000000..adb4f6cfd3778c34c267b4b241b66dd641f40a84 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/ClassNameMatcher.html" @@ -0,0 +1,212 @@ + + + + + +ClassNameMatcher (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.serialization
+

Interface ClassNameMatcher

+
+
+
+
    +
  • +
    +
    +
    public interface ClassNameMatcher
    +
    An object that matches a Class name to a condition.
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Summary

      + + + + + + + + + + +
      Methods 
      Modifier and TypeMethod and Description
      booleanmatches(String className) +
      Returns true if the supplied class name matches this object's condition.
      +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        matches

        +
        boolean matches(String className)
        +
        Returns true if the supplied class name matches this object's condition.
        +
        Parameters:
        className - fully qualified class name
        +
        Returns:
        true if the class name matches this object's condition
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/ValidatingObjectInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/ValidatingObjectInputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..22801f434d3e1123ae71dad1596857004acba0f9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/ValidatingObjectInputStream.html" @@ -0,0 +1,537 @@ + + + + + +ValidatingObjectInputStream (Apache Commons IO 2.5 API) + + + + + + + + + + +
+
org.apache.commons.io.serialization
+

Class ValidatingObjectInputStream

+
+
+ +
+ +
+
+ +
+
+
    +
  • + +
      +
    • + + +

      Constructor Detail

      + + + +
        +
      • +

        ValidatingObjectInputStream

        +
        public ValidatingObjectInputStream(InputStream input)
        +                            throws IOException
        +
        Constructs an object to deserialize the specified input stream. + At least one accept method needs to be called to specify which + classes can be deserialized, as by default no classes are + accepted.
        +
        Parameters:
        input - an input stream
        +
        Throws:
        +
        IOException - if an I/O error occurs while reading stream header
        +
      • +
      +
    • +
    + +
      +
    • + + +

      Method Detail

      + + + +
        +
      • +

        invalidClassNameFound

        +
        protected void invalidClassNameFound(String className)
        +                              throws InvalidClassException
        +
        Called to throw InvalidClassException if an invalid + class name is found during deserialization. Can be overridden, for example + to log those class names.
        +
        Parameters:
        className - name of the invalid class
        +
        Throws:
        +
        InvalidClassException - if the specified class is not allowed
        +
      • +
      + + + + + + + +
        +
      • +

        accept

        +
        public ValidatingObjectInputStream accept(Class<?>... classes)
        +
        Accept the specified classes for deserialization, unless they + are otherwise rejected.
        +
        Parameters:
        classes - Classes to accept
        +
        Returns:
        this object
        +
      • +
      + + + +
        +
      • +

        reject

        +
        public ValidatingObjectInputStream reject(Class<?>... classes)
        +
        Reject the specified classes for deserialization, even if they + are otherwise accepted.
        +
        Parameters:
        classes - Classes to reject
        +
        Returns:
        this object
        +
      • +
      + + + + + + + + + + + +
        +
      • +

        accept

        +
        public ValidatingObjectInputStream accept(Pattern pattern)
        +
        Accept class names that match the supplied pattern for + deserialization, unless they are otherwise rejected.
        +
        Parameters:
        pattern - standard Java regexp
        +
        Returns:
        this object
        +
      • +
      + + + +
        +
      • +

        reject

        +
        public ValidatingObjectInputStream reject(Pattern pattern)
        +
        Reject class names that match the supplied pattern for + deserialization, even if they are otherwise accepted.
        +
        Parameters:
        pattern - standard Java regexp
        +
        Returns:
        this object
        +
      • +
      + + + +
        +
      • +

        accept

        +
        public ValidatingObjectInputStream accept(ClassNameMatcher m)
        +
        Accept class names where the supplied ClassNameMatcher matches for + deserialization, unless they are otherwise rejected.
        +
        Parameters:
        m - the matcher to use
        +
        Returns:
        this object
        +
      • +
      + + + +
        +
      • +

        reject

        +
        public ValidatingObjectInputStream reject(ClassNameMatcher m)
        +
        Reject class names where the supplied ClassNameMatcher matches for + deserialization, even if they are otherwise accepted.
        +
        Parameters:
        m - the matcher to use
        +
        Returns:
        this object
        +
      • +
      +
    • +
    +
  • +
+
+
+ + + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/class-use/ClassNameMatcher.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/class-use/ClassNameMatcher.html" new file mode 100644 index 0000000000000000000000000000000000000000..6389f2268189bcd27a7771c246d097106e8f99b7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/class-use/ClassNameMatcher.html" @@ -0,0 +1,168 @@ + + + + + +Uses of Interface org.apache.commons.io.serialization.ClassNameMatcher (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Interface
org.apache.commons.io.serialization.ClassNameMatcher

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/class-use/ValidatingObjectInputStream.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/class-use/ValidatingObjectInputStream.html" new file mode 100644 index 0000000000000000000000000000000000000000..5ba9d909dd8e9b97262d6ab52bcc1ffa57fa2a2f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/class-use/ValidatingObjectInputStream.html" @@ -0,0 +1,210 @@ + + + + + +Uses of Class org.apache.commons.io.serialization.ValidatingObjectInputStream (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Class
org.apache.commons.io.serialization.ValidatingObjectInputStream

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-frame.html" new file mode 100644 index 0000000000000000000000000000000000000000..153475a1252924860e9274cf214157b8ed85f7f6 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-frame.html" @@ -0,0 +1,22 @@ + + + + + +org.apache.commons.io.serialization (Apache Commons IO 2.5 API) + + + +

org.apache.commons.io.serialization

+
+

Interfaces

+ +

Classes

+ +
+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-summary.html" new file mode 100644 index 0000000000000000000000000000000000000000..b99832677f9a979f56c2aba44cf316109e3d4bdc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-summary.html" @@ -0,0 +1,165 @@ + + + + + +org.apache.commons.io.serialization (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Package org.apache.commons.io.serialization

+
+
+This package provides a framework for controlling the deserialization of classes.
+
+

See: Description

+
+
+
    +
  • + + + + + + + + + + + + +
    Interface Summary 
    InterfaceDescription
    ClassNameMatcher +
    An object that matches a Class name to a condition.
    +
    +
  • +
  • + + + + + + + + + + + + +
    Class Summary 
    ClassDescription
    ValidatingObjectInputStream +
    An ObjectInputStream that's restricted to deserialize + a limited set of classes.
    +
    +
  • +
+ + + +

Package org.apache.commons.io.serialization Description

+

+This package provides a framework for controlling the deserialization of classes. +

+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-tree.html" new file mode 100644 index 0000000000000000000000000000000000000000..3ec42398ad519d3bc205f11e3f6ed6a50a80b643 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-tree.html" @@ -0,0 +1,140 @@ + + + + + +org.apache.commons.io.serialization Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Hierarchy For Package org.apache.commons.io.serialization

+Package Hierarchies: + +
+
+

Class Hierarchy

+ +

Interface Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-use.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-use.html" new file mode 100644 index 0000000000000000000000000000000000000000..24a801b625c6fc250ce0743cbdf9a23a071effb3 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/org/apache/commons/io/serialization/package-use.html" @@ -0,0 +1,159 @@ + + + + + +Uses of Package org.apache.commons.io.serialization (Apache Commons IO 2.5 API) + + + + + + + + + +
+

Uses of Package
org.apache.commons.io.serialization

+
+
+ +
+ + + + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-frame.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-frame.html" new file mode 100644 index 0000000000000000000000000000000000000000..a83a177326a38d435e734803a98651e799853d5a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-frame.html" @@ -0,0 +1,25 @@ + + + + + +Overview List (Apache Commons IO 2.5 API) + + + + + +

 

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-summary.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-summary.html" new file mode 100644 index 0000000000000000000000000000000000000000..8b5903dfdb7a3fd5e8d18449fbae2be2ffe1e8a1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-summary.html" @@ -0,0 +1,178 @@ + + + + + +Overview (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Apache Commons IO 2.5 API

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Packages 
PackageDescription
org.apache.commons.io +
+This package defines utility classes for working with streams, readers, +writers and files.
+
org.apache.commons.io.comparator +
This package provides various Comparator implementations +for Files.
+
org.apache.commons.io.filefilter +
This package defines an interface (IOFileFilter) that combines both +FileFilter and FilenameFilter.
+
org.apache.commons.io.input +
+This package provides implementations of input classes, such as +InputStream and Reader.
+
org.apache.commons.io.monitor +
+This package provides a component for monitoring file system events +(directory and file create, update and delete events).
+
org.apache.commons.io.output +
+This package provides implementations of output classes, such as +OutputStream and Writer.
+
org.apache.commons.io.serialization +
+This package provides a framework for controlling the deserialization of classes.
+
+
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-tree.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-tree.html" new file mode 100644 index 0000000000000000000000000000000000000000..fa85417d941985a99abc3f3ffc9dcff4a56b4617 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/overview-tree.html" @@ -0,0 +1,328 @@ + + + + + +Class Hierarchy (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + + +
+

Class Hierarchy

+ +

Interface Hierarchy

+ +

Enum Hierarchy

+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/package-list" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/package-list" new file mode 100644 index 0000000000000000000000000000000000000000..48871b7632db4846056e699e87d665dadfb5059c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/package-list" @@ -0,0 +1,7 @@ +org.apache.commons.io +org.apache.commons.io.comparator +org.apache.commons.io.filefilter +org.apache.commons.io.input +org.apache.commons.io.monitor +org.apache.commons.io.output +org.apache.commons.io.serialization diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/background.gif" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/background.gif" new file mode 100644 index 0000000000000000000000000000000000000000..f471940fde2f39ef8943a6af9569bcf986b1579b Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/background.gif" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/tab.gif" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/tab.gif" new file mode 100644 index 0000000000000000000000000000000000000000..1a73a83be11dde2d0003b716ca778fafc6f34ad7 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/tab.gif" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/titlebar.gif" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/titlebar.gif" new file mode 100644 index 0000000000000000000000000000000000000000..17443b3e16942feb776754978f8a8485ffbcaf84 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/titlebar.gif" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/titlebar_end.gif" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/titlebar_end.gif" new file mode 100644 index 0000000000000000000000000000000000000000..3ad78d461b2b332860475cd35c9459fbbf4eab0a Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/resources/titlebar_end.gif" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/serialized-form.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/serialized-form.html" new file mode 100644 index 0000000000000000000000000000000000000000..de34cc4be22db9afac202cc0d4a1e42d0ea5c603 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/serialized-form.html" @@ -0,0 +1,972 @@ + + + + + +Serialized Form (Apache Commons IO 2.5 API) + + + + + + +
+ + + + + +
+ + +
+

Serialized Form

+
+
+ +
+ +
+ + + + + +
+ + +

Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.

+ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/stylesheet.css" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/stylesheet.css" new file mode 100644 index 0000000000000000000000000000000000000000..0aeaa97fe05f89f7f1290a2d66d812f7f05bcf7e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-io-2.5/docs/stylesheet.css" @@ -0,0 +1,474 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ +body { + background-color:#ffffff; + color:#353833; + font-family:Arial, Helvetica, sans-serif; + font-size:76%; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4c6b87; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4c6b87; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-size:1.3em; +} +h1 { + font-size:1.8em; +} +h2 { + font-size:1.5em; +} +h3 { + font-size:1.4em; +} +h4 { + font-size:1.3em; +} +h5 { + font-size:1.2em; +} +h6 { + font-size:1.1em; +} +ul { + list-style-type:disc; +} +code, tt { + font-size:1.2em; +} +dt code { + font-size:1.2em; +} +table tr td dt code { + font-size:1.2em; + vertical-align:top; +} +sup { + font-size:.6em; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:.8em; + z-index:200; + margin-top:-7px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + background-image:url(resources/titlebar.gif); + background-position:left top; + background-repeat:no-repeat; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:1em; + margin:0; +} +.topNav { + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.bottomNav { + margin-top:10px; + background-image:url(resources/background.gif); + background-repeat:repeat-x; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; +} +.subNav { + background-color:#dee3e9; + border-bottom:1px solid #9eadc0; + float:left; + width:100%; + overflow:hidden; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding:3px 6px; +} +ul.subNavList li{ + list-style:none; + float:left; + font-size:90%; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; +} +.navBarCell1Rev { + background-image:url(resources/tab.gif); + background-color:#a88834; + color:#FFFFFF; + margin: auto 5px; + border:1px solid #c9aa44; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader h1 { + font-size:1.3em; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 25px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:1.2em; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + margin:0 0 6px -8px; + padding:2px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:1.0em; +} +.indexContainer h2 { + font-size:1.1em; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:1.1em; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:10px 0 10px 20px; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:25px; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #9eadc0; + background-color:#f9f9f9; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:1px solid #9eadc0; + border-top:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; + border-bottom:1px solid #9eadc0; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.contentContainer table, .classUseContainer table, .constantValuesContainer table { + border-bottom:1px solid #9eadc0; + width:100%; +} +.contentContainer ul li table, .classUseContainer ul li table, .constantValuesContainer ul li table { + width:100%; +} +.contentContainer .description table, .contentContainer .details table { + border-bottom:none; +} +.contentContainer ul li table th.colOne, .contentContainer ul li table th.colFirst, .contentContainer ul li table th.colLast, .classUseContainer ul li table th, .constantValuesContainer ul li table th, .contentContainer ul li table td.colOne, .contentContainer ul li table td.colFirst, .contentContainer ul li table td.colLast, .classUseContainer ul li table td, .constantValuesContainer ul li table td{ + vertical-align:top; + padding-right:20px; +} +.contentContainer ul li table th.colLast, .classUseContainer ul li table th.colLast,.constantValuesContainer ul li table th.colLast, +.contentContainer ul li table td.colLast, .classUseContainer ul li table td.colLast,.constantValuesContainer ul li table td.colLast, +.contentContainer ul li table th.colOne, .classUseContainer ul li table th.colOne, +.contentContainer ul li table td.colOne, .classUseContainer ul li table td.colOne { + padding-right:3px; +} +.overviewSummary caption, .packageSummary caption, .contentContainer ul.blockList li.blockList caption, .summary caption, .classUseContainer caption, .constantValuesContainer caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#FFFFFF; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + margin:0px; +} +caption a:link, caption a:hover, caption a:active, caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .packageSummary caption span, .contentContainer ul.blockList li.blockList caption span, .summary caption span, .classUseContainer caption span, .constantValuesContainer caption span { + white-space:nowrap; + padding-top:8px; + padding-left:8px; + display:block; + float:left; + background-image:url(resources/titlebar.gif); + height:18px; +} +.overviewSummary .tabEnd, .packageSummary .tabEnd, .contentContainer ul.blockList li.blockList .tabEnd, .summary .tabEnd, .classUseContainer .tabEnd, .constantValuesContainer .tabEnd { + width:10px; + background-image:url(resources/titlebar_end.gif); + background-repeat:no-repeat; + background-position:top right; + position:relative; + float:left; +} +ul.blockList ul.blockList li.blockList table { + margin:0 0 12px 0px; + width:100%; +} +.tableSubHeadingColor { + background-color: #EEEEFF; +} +.altColor { + background-color:#eeeeef; +} +.rowColor { + background-color:#ffffff; +} +.overviewSummary td, .packageSummary td, .contentContainer ul.blockList li.blockList td, .summary td, .classUseContainer td, .constantValuesContainer td { + text-align:left; + padding:3px 3px 3px 7px; +} +th.colFirst, th.colLast, th.colOne, .constantValuesContainer th { + background:#dee3e9; + border-top:1px solid #9eadc0; + border-bottom:1px solid #9eadc0; + text-align:left; + padding:3px 3px 3px 7px; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +td.colFirst, th.colFirst { + border-left:1px solid #9eadc0; + white-space:nowrap; +} +td.colLast, th.colLast { + border-right:1px solid #9eadc0; +} +td.colOne, th.colOne { + border-right:1px solid #9eadc0; + border-left:1px solid #9eadc0; +} +table.overviewSummary { + padding:0px; + margin-left:0px; +} +table.overviewSummary td.colFirst, table.overviewSummary th.colFirst, +table.overviewSummary td.colOne, table.overviewSummary th.colOne { + width:25%; + vertical-align:middle; +} +table.packageSummary td.colFirst, table.overviewSummary th.colFirst { + width:25%; + vertical-align:middle; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:.9em; +} +.block { + display:block; + margin:3px 0 0 0; +} +.strong { + font-weight:bold; +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang-2.6-bin.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang-2.6-bin.zip" new file mode 100644 index 0000000000000000000000000000000000000000..53c7a1636551deb3f04ce05abc53df3f024f4f9c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang-2.6-bin.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aa9a9aff4c0b61461c0d8a0735bc95b9a610edaead9644023ace66009d9ebec9 +size 3830423 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang-2.6-src.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang-2.6-src.zip" new file mode 100644 index 0000000000000000000000000000000000000000..67356f78a3b406bda9f472a2cbe7379cdfe293c2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang-2.6-src.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0d018ac0f8d870e4c7702644a471d0a999d5ea611c414cc4112b5ac681b1f84 +size 819648 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang3-3.6-bin.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang3-3.6-bin.zip" new file mode 100644 index 0000000000000000000000000000000000000000..3861bb49ac40bfaa2cea9b81833dd3328c79a9f0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang3-3.6-bin.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19dd16da4561d2a0c0af759197b20ad507fc9ecd0bcda0f372f9a90c7e9f3f95 +size 4790675 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang3-3.6-src.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang3-3.6-src.zip" new file mode 100644 index 0000000000000000000000000000000000000000..1a44638984ad6a57c83496699d222df3f1065fd7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/commons-lang3-3.6-src.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a288f657567e67ea11f88311a97370989422a79e58fe081857a6177103327aaf +size 1217716 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/common\345\214\205.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/common\345\214\205.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..4c76f29440cf1069e9fac67605e2c85020709e40 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/03-apache-common\345\214\205/common\345\214\205.jpg" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a1aaab6f1bba3c6b1a82cbb430618911e4d948df146e1497620bfd13fd5d384b +size 824473 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1563809289418.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1563809289418.png" new file mode 100644 index 0000000000000000000000000000000000000000..51317ee61f527b96a4719bd253af816541c6b0ff --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1563809289418.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f3a616b53df94018f5530a3ba57d759f57bd270dcd6618c32a0277b5f2e25454 +size 242169 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1_charset.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1_charset.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..6d215595f1baeb2191a5df3bdf2c9f9f61407cc8 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1_charset.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1_io.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1_io.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..6ac67b93e904f60645f3c635808ece3daee3cbe4 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/1_io.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/2_copy.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/2_copy.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..a2b6c94593794f50da48722160c82bdcf81f82a8 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/2_copy.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/2_zhuanhuan.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/2_zhuanhuan.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..883398e9e7af20338b7f3717d29f5551972e1b77 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/2_zhuanhuan.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/3_xuliehua.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/3_xuliehua.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..65882b700a628ed88374980f92b0d88c5815a60a Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/3_xuliehua.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220131021502089.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220131021502089.png" new file mode 100644 index 0000000000000000000000000000000000000000..4b991c366024ae2e8cf96962055a184d9ea38e7d Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220131021502089.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220131021528397.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220131021528397.png" new file mode 100644 index 0000000000000000000000000000000000000000..78621b6d6e1a395a4a3d4d01a54b06c4334e51e1 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220131021528397.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412215446368.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412215446368.png" new file mode 100644 index 0000000000000000000000000000000000000000..acc57783537dff20b8dccedbfffaa116255f9970 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412215446368.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:021207ad6bee9df63aa5a4ce0ee4f76e44f80a586fa7b6538694bc60e511b4d6 +size 111353 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412224132724.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412224132724.png" new file mode 100644 index 0000000000000000000000000000000000000000..8fb8f648d54fc4346454da089e57080109997066 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412224132724.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412224700133.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412224700133.png" new file mode 100644 index 0000000000000000000000000000000000000000..2ad627f87e074c79df4fb43d478b4a74f42106d7 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412224700133.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412225253349.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412225253349.png" new file mode 100644 index 0000000000000000000000000000000000000000..b7b8fbdd6f20788090e75f37a374d6ce09bb7ca0 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412225253349.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230501953.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230501953.png" new file mode 100644 index 0000000000000000000000000000000000000000..b1766dcaf6b608ac961eb264f929888ccccad9fe --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230501953.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4051966529dcd4acdc07a4bfdd36636a81afbba47b0370993869a8080f5dedc +size 190536 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230745170.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230745170.png" new file mode 100644 index 0000000000000000000000000000000000000000..3f292ef964ed2f99f5d1c1dc62829f82c829141c Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230745170.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230751461.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230751461.png" new file mode 100644 index 0000000000000000000000000000000000000000..a9275c159dfc351f08fe0acd830ccae610d0b5ab Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412230751461.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412231533768.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412231533768.png" new file mode 100644 index 0000000000000000000000000000000000000000..5ac26bbe6ed61a5ef2b120b879928016c82d288f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412231533768.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412232254819.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412232254819.png" new file mode 100644 index 0000000000000000000000000000000000000000..fb5d61f0261263e32bb17cf214f334c640dcb85f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412232254819.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412232303297.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412232303297.png" new file mode 100644 index 0000000000000000000000000000000000000000..fb5d61f0261263e32bb17cf214f334c640dcb85f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220412232303297.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002314063.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002314063.png" new file mode 100644 index 0000000000000000000000000000000000000000..5ba223a18f9bdd76b468464aa7b5ffeae5e1690e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002314063.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002626240.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002626240.png" new file mode 100644 index 0000000000000000000000000000000000000000..7f6e09538074cabc8c1e10f108d3b66b98727be0 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002626240.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002630473.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002630473.png" new file mode 100644 index 0000000000000000000000000000000000000000..56e8d3dc32540888767294aa0385075bd649d0ec Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002630473.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002723838.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002723838.png" new file mode 100644 index 0000000000000000000000000000000000000000..8f219cdaaa142c8a6d67964bb01de5f5b287fb61 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220413002723838.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220416004246436.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220416004246436.png" new file mode 100644 index 0000000000000000000000000000000000000000..bccf6f584137634bc0ca86c4191279613ca1ea66 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220416004246436.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123117300.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123117300.png" new file mode 100644 index 0000000000000000000000000000000000000000..177e42d82c047c9736b18eafe69a1c4ec377cf29 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123117300.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123328452.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123328452.png" new file mode 100644 index 0000000000000000000000000000000000000000..a7c26389b898a087bed11801e6aad1475a1bda90 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123328452.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123603551.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123603551.png" new file mode 100644 index 0000000000000000000000000000000000000000..ccafe0b28ef252d2b1e6d13a8baa752434459be7 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220503123603551.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220514183413011.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220514183413011.png" new file mode 100644 index 0000000000000000000000000000000000000000..476b748ee054f06ae1782c5bb2b3171fb7ca9f77 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220514183413011.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220518095907714.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220518095907714.png" new file mode 100644 index 0000000000000000000000000000000000000000..a7629231be401858f35e0bcade28658dda8e20a2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220518095907714.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:83e04e7c3b06d50a122bfa8fb180c764134010822331d700d33e89dbb7228a32 +size 198734 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220525164636164.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220525164636164.png" new file mode 100644 index 0000000000000000000000000000000000000000..736bcd9419b8ac1bb2d94983a96f7155ae5de1e8 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220525164636164.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220525165627814.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220525165627814.png" new file mode 100644 index 0000000000000000000000000000000000000000..f9e0b345312f57d0d395cb64601cc8aacfd63683 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/image-20220525165627814.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/\345\255\227\347\254\246\351\233\206.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/\345\255\227\347\254\246\351\233\206.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..efe25e7866346c51dd0535aed03065ec9e488f38 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/\345\255\227\347\254\246\351\233\206.jpg" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c0b1329b4bce79be494ff33f9ce32009bad66d1f549c95e6b3c4ebdd7eb1e186 +size 111451 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25415\347\253\240.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25415\347\253\240.png" new file mode 100644 index 0000000000000000000000000000000000000000..2e0fb10705922075bc59e572c208f1041c8a9ed8 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25415\347\253\240.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:adf859db259c2f647b50c73a4a73fee50f1791467041d8c002cfb396aa2c9e19 +size 656006 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_IO\346\265\201.pptx" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_IO\346\265\201.pptx" new file mode 100644 index 0000000000000000000000000000000000000000..813170c1e76c30d52d3faa17326ae36649482579 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_IO\346\265\201.pptx" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d65eaefbd0dc3a8f1643b405c263de5aaee754b1b9ac9a48b5226455fcc10041 +size 1945264 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201.md" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201.md" new file mode 100644 index 0000000000000000000000000000000000000000..7df802cccb2aaa690000291e67b55640454c87f2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25415\347\253\240_File\347\261\273\344\270\216IO\346\265\201.md" @@ -0,0 +1,2556 @@ +# 第15章_File类与IO流 + +讲师:尚硅谷-宋红康(江湖人称:康师傅) + +官网:[http://www.atguigu.com](http://www.atguigu.com/) + +*** + +## 本章专题与脉络 + +第3阶段:Java高级应用-第15章 + +*** + +## 1. java.io.File类的使用 + +### 1.1 概述 + +- File类及本章下的各种流,都定义在java.io包下。 +- 一个File对象代表硬盘或网络中可能存在的一个文件或者文件目录(俗称文件夹),与平台无关。(体会万事万物皆对象) +- File 能新建、删除、重命名文件和目录,但 File 不能访问文件内容本身。如果需要访问文件内容本身,则需要使用输入/输出流。 + - File对象可以作为参数传递给流的构造器。 +- 想要在Java程序中表示一个真实存在的文件或目录,那么必须有一个File对象,但是Java程序中的一个File对象,可能没有一个真实存在的文件或目录。 + + +### 1.2 构造器 + +* `public File(String pathname) ` :以pathname为路径创建File对象,可以是绝对路径或者相对路径,如果pathname是相对路径,则默认的当前路径在系统属性user.dir中存储。 +* `public File(String parent, String child) ` :以parent为父路径,child为子路径创建File对象。 +* `public File(File parent, String child)` :根据一个父File对象和子文件路径创建File对象 + +关于路径: + +* **绝对路径:**从盘符开始的路径,这是一个完整的路径。 +* **相对路径:**相对于`项目目录`的路径,这是一个便捷的路径,开发中经常使用。 + * IDEA中,main中的文件的相对路径,是相对于"`当前工程`" + * IDEA中,单元测试方法中的文件的相对路径,是相对于"`当前module`" + +举例: + +```java +package com.atguigu.file; + +import java.io.File; + +public class FileObjectTest { + public static void main(String[] args) { + // 文件路径名 + String pathname = "D:\\aaa.txt"; + File file1 = new File(pathname); + + // 文件路径名 + String pathname2 = "D:\\aaa\\bbb.txt"; + File file2 = new File(pathname2); + + // 通过父路径和子路径字符串 + String parent = "d:\\aaa"; + String child = "bbb.txt"; + File file3 = new File(parent, child); + + // 通过父级File对象和子路径字符串 + File parentDir = new File("d:\\aaa"); + String childFile = "bbb.txt"; + File file4 = new File(parentDir, childFile); + } + + @Test + public void test01() throws IOException{ + File f1 = new File("d:\\atguigu\\javase\\HelloIO.java"); //绝对路径 + System.out.println("文件/目录的名称:" + f1.getName()); + System.out.println("文件/目录的构造路径名:" + f1.getPath()); + System.out.println("文件/目录的绝对路径名:" + f1.getAbsolutePath()); + System.out.println("文件/目录的父目录名:" + f1.getParent()); + } + @Test + public void test02()throws IOException{ + File f2 = new File("/HelloIO.java");//绝对路径,从根路径开始 + System.out.println("文件/目录的名称:" + f2.getName()); + System.out.println("文件/目录的构造路径名:" + f2.getPath()); + System.out.println("文件/目录的绝对路径名:" + f2.getAbsolutePath()); + System.out.println("文件/目录的父目录名:" + f2.getParent()); + } + + @Test + public void test03() throws IOException { + File f3 = new File("HelloIO.java");//相对路径 + System.out.println("user.dir =" + System.getProperty("user.dir")); + System.out.println("文件/目录的名称:" + f3.getName()); + System.out.println("文件/目录的构造路径名:" + f3.getPath()); + System.out.println("文件/目录的绝对路径名:" + f3.getAbsolutePath()); + System.out.println("文件/目录的父目录名:" + f3.getParent()); + } + @Test + public void test04() throws IOException{ + File f5 = new File("HelloIO.java");//相对路径 + System.out.println("user.dir =" + System.getProperty("user.dir")); + System.out.println("文件/目录的名称:" + f5.getName()); + System.out.println("文件/目录的构造路径名:" + f5.getPath()); + System.out.println("文件/目录的绝对路径名:" + f5.getAbsolutePath()); + System.out.println("文件/目录的父目录名:" + f5.getParent()); + } +} +``` + +> 注意: +> +> 1. 无论该路径下是否存在文件或者目录,都不影响File对象的创建。 +> +> 2. window的路径分隔符使用“\”,而Java程序中的“\”表示转义字符,所以在Windows中表示路径,需要用“\\”。或者直接使用“/”也可以,Java程序支持将“/”当成平台无关的`路径分隔符`。或者直接使用File.separator常量值表示。比如: +> +> File file2 = new File("d:" + File.separator + "atguigu" + File.separator + "info.txt"); +> +> 3. 当构造路径是绝对路径时,那么getPath和getAbsolutePath结果一样 +> +> 当构造路径是相对路径时,那么getAbsolutePath的路径 = user.dir的路径 + 构造路径 + +### 1.3 常用方法 + +#### 1、获取文件和目录基本信息 + +* public String getName() :获取名称 +* public String getPath() :获取路径 +* `public String getAbsolutePath()`:获取绝对路径 +* public File getAbsoluteFile():获取绝对路径表示的文件 +* `public String getParent()`:获取上层文件目录路径。若无,返回null +* public long length() :获取文件长度(即:字节数)。不能获取目录的长度。 +* public long lastModified() :获取最后一次的修改时间,毫秒值 + +> 如果File对象代表的文件或目录存在,则File对象实例初始化时,就会用硬盘中对应文件或目录的属性信息(例如,时间、类型等)为File对象的属性赋值,否则除了路径和名称,File对象的其他属性将会保留默认值。 + +image-20220412215446368 + +举例: + +```java +package com.atguigu.file; + +import java.io.File; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; + +public class FileInfoMethod { + public static void main(String[] args) { + File f = new File("d:/aaa/bbb.txt"); + System.out.println("文件构造路径:"+f.getPath()); + System.out.println("文件名称:"+f.getName()); + System.out.println("文件长度:"+f.length()+"字节"); + System.out.println("文件最后修改时间:" + LocalDateTime.ofInstant(Instant.ofEpochMilli(f.lastModified()),ZoneId.of("Asia/Shanghai"))); + + File f2 = new File("d:/aaa"); + System.out.println("目录构造路径:"+f2.getPath()); + System.out.println("目录名称:"+f2.getName()); + System.out.println("目录长度:"+f2.length()+"字节"); + System.out.println("文件最后修改时间:" + LocalDateTime.ofInstant(Instant.ofEpochMilli(f.lastModified()),ZoneId.of("Asia/Shanghai"))); + } +} +``` + +```java +输出结果: +文件构造路径:d:\aaa\bbb.java +文件名称:bbb.java +文件长度:636字节 +文件最后修改时间:2022-07-23T22:01:32.065 + +目录构造路径:d:\aaa +目录名称:aaa +目录长度:4096字节 +文件最后修改时间:2022-07-23T22:01:32.065 +``` + +#### 2、列出目录的下一级 + +* public String[] list() :返回一个String数组,表示该File目录中的所有子文件或目录。 +* public File[] listFiles() :返回一个File数组,表示该File目录中的所有的子文件或目录。 + +```java +package com.atguigu.file; + +import org.junit.Test; + +import java.io.File; +import java.io.FileFilter; +import java.io.FilenameFilter; + +public class DirListFiles { + @Test + public void test01() { + File dir = new File("d:/atguigu"); + String[] subs = dir.list(); + for (String sub : subs) { + System.out.println(sub); + } + } + +} +``` + +#### 3、File类的重命名功能 + +- public boolean renameTo(File dest):把文件重命名为指定的文件路径。 + +#### 4、判断功能的方法 + +- `public boolean exists()` :此File表示的文件或目录是否实际存在。 +- `public boolean isDirectory()` :此File表示的是否为目录。 +- `public boolean isFile()` :此File表示的是否为文件。 +- public boolean canRead() :判断是否可读 +- public boolean canWrite() :判断是否可写 +- public boolean isHidden() :判断是否隐藏 + + +举例: + +```java +package com.atguigu.file; + +import java.io.File; + +public class FileIs { + public static void main(String[] args) { + File f = new File("d:\\aaa\\bbb.java"); + File f2 = new File("d:\\aaa"); + // 判断是否存在 + System.out.println("d:\\aaa\\bbb.java 是否存在:"+f.exists()); + System.out.println("d:\\aaa 是否存在:"+f2.exists()); + // 判断是文件还是目录 + System.out.println("d:\\aaa 文件?:"+f2.isFile()); + System.out.println("d:\\aaa 目录?:"+f2.isDirectory()); + } +} +``` + +``` +输出结果: +d:\aaa\bbb.java 是否存在:true +d:\aaa 是否存在:true +d:\aaa 文件?:false +d:\aaa 目录?:true +``` + +> 如果文件或目录不存在,那么exists()、isFile()和isDirectory()都是返回true + +#### 5、创建、删除功能 + +- `public boolean createNewFile()` :创建文件。若文件存在,则不创建,返回false。 +- `public boolean mkdir()` :创建文件目录。如果此文件目录存在,就不创建了。如果此文件目录的上层目录不存在,也不创建。 +- `public boolean mkdirs()` :创建文件目录。如果上层文件目录不存在,一并创建。 +- `public boolean delete()` :删除文件或者文件夹 + 删除注意事项:① Java中的删除不走回收站。② 要删除一个文件目录,请注意该文件目录内不能包含文件或者文件目录。 + +举例: + +```java +package com.atguigu.file; + +import java.io.File; +import java.io.IOException; + +public class FileCreateDelete { + public static void main(String[] args) throws IOException { + // 文件的创建 + File f = new File("aaa.txt"); + System.out.println("aaa.txt是否存在:"+f.exists()); + System.out.println("aaa.txt是否创建:"+f.createNewFile()); + System.out.println("aaa.txt是否存在:"+f.exists()); + + // 目录的创建 + File f2= new File("newDir"); + System.out.println("newDir是否存在:"+f2.exists()); + System.out.println("newDir是否创建:"+f2.mkdir()); + System.out.println("newDir是否存在:"+f2.exists()); + + // 创建一级目录 + File f3= new File("newDira\\newDirb"); + System.out.println("newDira\\newDirb创建:" + f3.mkdir()); + File f4= new File("newDir\\newDirb"); + System.out.println("newDir\\newDirb创建:" + f4.mkdir()); + // 创建多级目录 + File f5= new File("newDira\\newDirb"); + System.out.println("newDira\\newDirb创建:" + f5.mkdirs()); + + // 文件的删除 + System.out.println("aaa.txt删除:" + f.delete()); + + // 目录的删除 + System.out.println("newDir删除:" + f2.delete()); + System.out.println("newDir\\newDirb删除:" + f4.delete()); + } +} +``` + +```java +运行结果: +aaa.txt是否存在:false +aaa.txt是否创建:true +aaa.txt是否存在:true +newDir是否存在:false +newDir是否创建:true +newDir是否存在:true +newDira\newDirb创建:false +newDir\newDirb创建:true +newDira\newDirb创建:true +aaa.txt删除:true +newDir删除:false +newDir\newDirb删除:true +``` + +> API中说明:delete方法,如果此File表示目录,则目录必须为空才能删除。 + +### 1.4 练习 + +练习1:利用File构造器,new 一个文件目录file + +​ 1) 在其中创建多个文件和目录 + +​ 2) 编写方法,实现删除file中指定文件的操作 + +练习2:判断指定目录下是否有后缀名为.jpg的文件。如果有,就输出该文件名称 + +```java +public class FindJPGFileTest { + //方法1: + @Test + public void test1(){ + File srcFile = new File("d:\\code"); + + String[] fileNames = srcFile.list(); + for(String fileName : fileNames){ + if(fileName.endsWith(".jpg")){ + System.out.println(fileName); + } + } + } + //方法2: + @Test + public void test2(){ + File srcFile = new File("d:\\code"); + + File[] listFiles = srcFile.listFiles(); + for(File file : listFiles){ + if(file.getName().endsWith(".jpg")){ + System.out.println(file.getAbsolutePath()); + } + } + } + //方法3: + /* + * File类提供了两个文件过滤器方法 + * public String[] list(FilenameFilter filter) + * public File[] listFiles(FileFilter filter) + + */ + @Test + public void test3(){ + File srcFile = new File("d:\\code"); + + File[] subFiles = srcFile.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".jpg"); + } + }); + + for(File file : subFiles){ + System.out.println(file.getAbsolutePath()); + } + } + +} + +``` + +练习3:遍历指定目录所有文件名称,包括子文件目录中的文件。 + + 拓展1:并计算指定目录占用空间的大小 + + 拓展2:删除指定文件目录及其下的所有文件 + +```java +public class ListFilesTest { + //练习3:(方式1) + public static void printSubFile(File dir) { + // 打印目录的子文件 + File[] subfiles = dir.listFiles(); + + for (File f : subfiles) { + if (f.isDirectory()) {// 文件目录 + printSubFile(f); + } else {// 文件 + System.out.println(f.getAbsolutePath()); + } + + } + } + + // //练习3:(方式2) + public void listAllSubFiles(File file) { + if (file.isFile()) { + System.out.println(file); + } else { + File[] all = file.listFiles(); + // 如果all[i]是文件,直接打印 + // 如果all[i]是目录,接着再获取它的下一级 + for (File f : all) { + listAllSubFiles(f);// 递归调用:自己调用自己就叫递归 + } + } + } + @Test + public void testListAllFiles(){ + // 1.创建目录对象 + File dir = new File("E:\\teach\\01_javaSE\\_尚硅谷Java编程语言\\3_软件"); + + // 2.打印目录的子文件 + printSubFile(dir); + } + + // 拓展1:求指定目录所在空间的大小 + public long getDirectorySize(File file) { + // file是文件,那么直接返回file.length() + // file是目录,把它的下一级的所有file大小加起来就是它的总大小 + long size = 0; + if (file.isFile()) { + size = file.length(); + } else { + File[] all = file.listFiles();// 获取file的下一级 + // 累加all[i]的大小 + for (File f : all) { + size += getDirectorySize(f);// f的大小; + } + } + return size; + } + + // 拓展2:删除指定的目录 + public void deleteDirectory(File file) { + // 如果file是文件,直接delete + // 如果file是目录,先把它的下一级干掉,然后删除自己 + if (file.isDirectory()) { + File[] all = file.listFiles(); + // 循环删除的是file的下一级 + for (File f : all) {// f代表file的每一个下级 + deleteDirectory(f); + } + } + // 删除自己 + file.delete(); + } + +} +``` + +## 2. IO流原理及流的分类 + +![image-20220412224132724](images/image-20220412224132724.png) + +### 2.1 Java IO原理 + +- Java程序中,对于数据的输入/输出操作以“`流(stream)`” 的方式进行,可以看做是一种数据的流动。 + + image-20220503123117300 + +- I/O流中的I/O是`Input/Output`的缩写, I/O技术是非常实用的技术,用于处理设备之间的数据传输。如读/写文件,网络通讯等。 + - `输入input`:读取外部数据(磁盘、光盘等存储设备的数据)到程序(内存)中。 + - `输出output`:将程序(内存)数据输出到磁盘、光盘等存储设备中。 + + +![image-20220412224700133](images/image-20220412224700133.png) + +### 2.2 流的分类 + +`java.io`包下提供了各种“流”类和接口,用以获取不同种类的数据,并通过`标准的方法`输入或输出数据。 + +- 按数据的流向不同分为:**输入流**和**输出流**。 + - **输入流** :把数据从`其他设备`上读取到`内存`中的流。 + - 以InputStream、Reader结尾 + - **输出流** :把数据从`内存` 中写出到`其他设备`上的流。 + - 以OutputStream、Writer结尾 + +- 按操作数据单位的不同分为:**字节流(8bit)**和**字符流(16bit)**。 + - **字节流** :以字节为单位,读写数据的流。 + - 以InputStream、OutputStream结尾 + - **字符流** :以字符为单位,读写数据的流。 + - 以Reader、Writer结尾 + +- 根据IO流的角色不同分为:**节点流**和**处理流**。 + - **节点流**:直接从数据源或目的地读写数据 + + ![image-20220412230745170](images/image-20220412230745170.png) + + - **处理流**:不直接连接到数据源或目的地,而是“连接”在已存在的流(节点流或处理流)之上,通过对数据的处理为程序提供更为强大的读写功能。 + + ![image-20220412230751461](images/image-20220412230751461.png) + +小结:图解 + +image-20220412225253349 + +### 2.3 流的API + +- Java的IO流共涉及40多个类,实际上非常规则,都是从如下4个抽象基类派生的。 + +| (抽象基类) | 输入流 | 输出流 | +| :----------: | :---------: | :----------: | +| 字节流 | InputStream | OutputStream | +| 字符流 | Reader | Writer | + +- 由这四个类派生出来的子类名称都是以其父类名作为子类名后缀。 + +![image-20220412230501953](images/image-20220412230501953.png) + +**常用的节点流:**   + +* 文件流: FileInputStream、FileOutputStrean、FileReader、FileWriter +* 字节/字符数组流: ByteArrayInputStream、ByteArrayOutputStream、CharArrayReader、CharArrayWriter + * 对数组进行处理的节点流(对应的不再是文件,而是内存中的一个数组)。 + +**常用处理流:** + +* 缓冲流:BufferedInputStream、BufferedOutputStream、BufferedReader、BufferedWriter + * 作用:增加缓冲功能,避免频繁读写硬盘,进而提升读写效率。 +* 转换流:InputStreamReader、OutputStreamReader + * 作用:实现字节流和字符流之间的转换。 +* 对象流:ObjectInputStream、ObjectOutputStream + * 作用:提供直接读写Java对象功能 + +## 3. 节点流之一:FileReader\FileWriter + +### 3.1 Reader与Writer + +Java提供一些字符流类,以字符为单位读写数据,专门用于处理文本文件。不能操作图片,视频等非文本文件。 + +> 常见的文本文件有如下的格式:.txt、.java、.c、.cpp、.py等 +> +> 注意:.doc、.xls、.ppt这些都不是文本文件。 + +#### 3.1.1 字符输入流:Reader + +`java.io.Reader`抽象类是表示用于读取字符流的所有类的父类,可以读取字符信息到内存中。它定义了字符输入流的基本共性功能方法。 + +- `public int read()`: 从输入流读取一个字符。 虽然读取了一个字符,但是会自动提升为int类型。返回该字符的Unicode编码值。如果已经到达流末尾了,则返回-1。 +- `public int read(char[] cbuf)`: 从输入流中读取一些字符,并将它们存储到字符数组 cbuf中 。每次最多读取cbuf.length个字符。返回实际读取的字符个数。如果已经到达流末尾,没有数据可读,则返回-1。 +- `public int read(char[] cbuf,int off,int len)`:从输入流中读取一些字符,并将它们存储到字符数组 cbuf中,从cbuf[off]开始的位置存储。每次最多读取len个字符。返回实际读取的字符个数。如果已经到达流末尾,没有数据可读,则返回-1。 +- `public void close()` :关闭此流并释放与此流相关联的任何系统资源。 + +> 注意:当完成流的操作时,必须调用close()方法,释放系统资源,否则会造成内存泄漏。 + +#### 3.1.2 字符输出流:Writer + +`java.io.Writer `抽象类是表示用于写出字符流的所有类的超类,将指定的字符信息写出到目的地。它定义了字节输出流的基本共性功能方法。 + +- `public void write(int c)` :写出单个字符。 +- `public void write(char[] cbuf) `:写出字符数组。 +- `public void write(char[] cbuf, int off, int len) `:写出字符数组的某一部分。off:数组的开始索引;len:写出的字符个数。 +- `public void write(String str) `:写出字符串。 +- `public void write(String str, int off, int len)` :写出字符串的某一部分。off:字符串的开始索引;len:写出的字符个数。 +- `public void flush() `:刷新该流的缓冲。 +- `public void close()` :关闭此流。 + +> 注意:当完成流的操作时,必须调用close()方法,释放系统资源,否则会造成内存泄漏。 + +### 3.2 FileReader 与 FileWriter + +#### 3.2.1 FileReader + +`java.io.FileReader `类用于读取字符文件,构造时使用系统默认的字符编码和默认字节缓冲区。 + +- `FileReader(File file)`: 创建一个新的 FileReader ,给定要读取的File对象。 +- `FileReader(String fileName)`: 创建一个新的 FileReader ,给定要读取的文件的名称。 + +**举例:**读取hello.txt文件中的字符数据,并显示在控制台上 + +```java +/** + * @author 尚硅谷-宋红康 + * @create 14:09 + */ +public class FileReaderWriterTest { + + //实现方式1 + @Test + public void test1() throws IOException { + //1. 创建File类的对象,对应着物理磁盘上的某个文件 + File file = new File("hello.txt"); + //2. 创建FileReader流对象,将File类的对象作为参数传递到FileReader的构造器中 + FileReader fr = new FileReader(file); + //3. 通过相关流的方法,读取文件中的数据 +// int data = fr.read(); //每调用一次读取一个字符 +// while (data != -1) { +// System.out.print((char) data); +// data = fr.read(); +// } + int data; + while ((data = fr.read()) != -1) { + System.out.print((char) data); + } + + //4. 关闭相关的流资源,避免出现内存泄漏 + fr.close(); + + } + + //实现方式2:在方式1的基础上改进,使用try-catch-finally处理异常。保证流是可以关闭的 + @Test + public void test2() { + FileReader fr = null; + try { + //1. 创建File类的对象,对应着物理磁盘上的某个文件 + File file = new File("hello.txt"); + //2. 创建FileReader流对象,将File类的对象作为参数传递到FileReader的构造器中 + fr = new FileReader(file); + //3. 通过相关流的方法,读取文件中的数据 + /* + * read():每次从对接的文件中读取一个字符。并将此字符返回。 + * 如果返回值为-1,则表示文件到了末尾,可以不再读取。 + * */ +// int data = fr.read(); +// while(data != -1){ +// System.out.print((char)data); +// data = fr.read(); +// } + + int data; + while ((data = fr.read()) != -1) { + System.out.println((char) data); + } + + } catch (IOException e) { + e.printStackTrace(); + } finally { + //4. 关闭相关的流资源,避免出现内存泄漏 + try { + if (fr != null) + fr.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + //实现方式3:调用read(char[] cbuf),每次从文件中读取多个字符 + @Test + public void test3() { + FileReader fr = null; + try { + //1. 创建File类的对象,对应着物理磁盘上的某个文件 + File file = new File("hello.txt"); + //2. 创建FileReader流对象,将File类的对象作为参数传递到FileReader的构造器中 + fr = new FileReader(file); + //3. 通过相关流的方法,读取文件中的数据 + char[] cbuf = new char[5]; + /* + * read(char[] cbuf) : 每次将文件中的数据读入到cbuf数组中,并返回读入到数组中的 + * 字符的个数。 + * */ + int len; //记录每次读入的字符的个数 + while ((len = fr.read(cbuf)) != -1) { + //处理char[]数组即可 + //错误: +// for(int i = 0;i < cbuf.length;i++){ +// System.out.print(cbuf[i]); +// } + //错误: +// String str = new String(cbuf); +// System.out.print(str); + //正确: +// for(int i = 0;i < len;i++){ +// System.out.print(cbuf[i]); +// } + //正确: + String str = new String(cbuf, 0, len); + System.out.print(str); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + //4. 关闭相关的流资源,避免出现内存泄漏 + try { + if (fr != null) + fr.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} +``` + +不同实现方式的类比: + +![image-20220518095907714](images/image-20220518095907714.png) + +#### 3.2.2 FileWriter + +`java.io.FileWriter `类用于写出字符到文件,构造时使用系统默认的字符编码和默认字节缓冲区。 + +- `FileWriter(File file)`: 创建一个新的 FileWriter,给定要读取的File对象。 +- `FileWriter(String fileName)`: 创建一个新的 FileWriter,给定要读取的文件的名称。 +- `FileWriter(File file,boolean append)`: 创建一个新的 FileWriter,指明是否在现有文件末尾追加内容。 + +举例: + +```java +public class FWWrite { + //注意:应该使用try-catch-finally处理异常。这里出于方便阅读代码,使用了throws的方式 + @Test + public void test01()throws IOException { + // 使用文件名称创建流对象 + FileWriter fw = new FileWriter(new File("fw.txt")); + // 写出数据 + fw.write(97); // 写出第1个字符 + fw.write('b'); // 写出第2个字符 + fw.write('C'); // 写出第3个字符 + fw.write(30000); // 写出第4个字符,中文编码表中30000对应一个汉字。 + + //关闭资源 + fw.close(); + } + //注意:应该使用try-catch-finally处理异常。这里出于方便阅读代码,使用了throws的方式 + @Test + public void test02()throws IOException { + // 使用文件名称创建流对象 + FileWriter fw = new FileWriter(new File("fw.txt")); + // 字符串转换为字节数组 + char[] chars = "尚硅谷".toCharArray(); + + // 写出字符数组 + fw.write(chars); // 尚硅谷 + + // 写出从索引1开始,2个字符。 + fw.write(chars,1,2); // 硅谷 + + // 关闭资源 + fw.close(); + } + //注意:应该使用try-catch-finally处理异常。这里出于方便阅读代码,使用了throws的方式 + @Test + public void test03()throws IOException { + // 使用文件名称创建流对象 + FileWriter fw = new FileWriter("fw.txt"); + // 字符串 + String msg = "尚硅谷"; + + // 写出字符数组 + fw.write(msg); //尚硅谷 + + // 写出从索引1开始,2个字符。 + fw.write(msg,1,2); // 硅谷 + + // 关闭资源 + fw.close(); + } + + @Test + public void test04(){ + FileWriter fw = null; + try { + //1. 创建File的对象 + File file = new File("personinfo.txt"); + //2. 创建FileWriter的对象,将File对象作为参数传递到FileWriter的构造器中 + //如果输出的文件已存在,则会对现有的文件进行覆盖 + fw = new FileWriter(file); +// fw = new FileWriter(file,false); + //如果输出的文件已存在,则会在现有的文件末尾写入数据 +// fw = new FileWriter(file,true); + + //3. 调用相关的方法,实现数据的写出操作 + //write(String str) / write(char[] cbuf) + fw.write("I love you,"); + fw.write("you love him."); + fw.write("so sad".toCharArray()); + } catch (IOException e) { + e.printStackTrace(); + } finally { + //4. 关闭资源,避免内存泄漏 + try { + if (fw != null) + fw.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } +} +``` + +#### 3.2.3 小结 + +``` +① +因为出现流资源的调用,为了避免内存泄漏,需要使用try-catch-finally处理异常 + +② +对于输入流来说,File类的对象必须在物理磁盘上存在,否则执行就会报FileNotFoundException。如果传入的是一个目录,则会报IOException异常。 + +对于输出流来说,File类的对象是可以不存在的。 + > 如果File类的对象不存在,则可以在输出的过程中,自动创建File类的对象 + > 如果File类的对象存在, + > 如果调用FileWriter(File file)或FileWriter(File file,false),输出时会新建File文件覆盖已有的文件 + > 如果调用FileWriter(File file,true)构造器,则在现有的文件末尾追加写出内容。 +``` + +### 3.3 关于flush(刷新) + +因为内置缓冲区的原因,如果FileWriter不关闭输出流,无法写出字符到文件中。但是关闭的流对象,是无法继续写出数据的。如果我们既想写出数据,又想继续使用流,就需要`flush()` 方法了。 + +- `flush()` :刷新缓冲区,流对象可以继续使用。 +- `close() `:先刷新缓冲区,然后通知系统释放资源。流对象不可以再被使用了。 + +注意:即便是flush()方法写出了数据,操作的最后还是要调用close方法,释放系统资源。 + +举例: + +```java +public class FWWriteFlush { + //注意:应该使用try-catch-finally处理异常。这里出于方便阅读代码,使用了throws的方式 + @Test + public void test() throws IOException { + // 使用文件名称创建流对象 + FileWriter fw = new FileWriter("fw.txt"); + // 写出数据,通过flush + fw.write('刷'); // 写出第1个字符 + fw.flush(); + fw.write('新'); // 继续写出第2个字符,写出成功 + fw.flush(); + + // 写出数据,通过close + fw.write('关'); // 写出第1个字符 + fw.close(); + fw.write('闭'); // 继续写出第2个字符,【报错】java.io.IOException: Stream closed + fw.close(); + } +} +``` + +## 4. 节点流之二:FileInputStream\FileOutputStream + +如果我们读取或写出的数据是非文本文件,则Reader、Writer就无能为力了,必须使用字节流。 + +### 4.1 InputStream和OutputStream + +#### 4.1.1 字节输入流:InputStream + +`java.io.InputStream `抽象类是表示字节输入流的所有类的超类,可以读取字节信息到内存中。它定义了字节输入流的基本共性功能方法。 + +- `public int read()`: 从输入流读取一个字节。返回读取的字节值。虽然读取了一个字节,但是会自动提升为int类型。如果已经到达流末尾,没有数据可读,则返回-1。 +- `public int read(byte[] b)`: 从输入流中读取一些字节数,并将它们存储到字节数组 b中 。每次最多读取b.length个字节。返回实际读取的字节个数。如果已经到达流末尾,没有数据可读,则返回-1。 +- `public int read(byte[] b,int off,int len)`:从输入流中读取一些字节数,并将它们存储到字节数组 b中,从b[off]开始存储,每次最多读取len个字节 。返回实际读取的字节个数。如果已经到达流末尾,没有数据可读,则返回-1。 +- `public void close()` :关闭此输入流并释放与此流相关联的任何系统资源。 + +> 说明:close()方法,当完成流的操作时,必须调用此方法,释放系统资源。 + +#### 4.1.2 字节输出流:OutputStream + +`java.io.OutputStream `抽象类是表示字节输出流的所有类的超类,将指定的字节信息写出到目的地。它定义了字节输出流的基本共性功能方法。 + +- `public void write(int b)` :将指定的字节输出流。虽然参数为int类型四个字节,但是只会保留一个字节的信息写出。 +- `public void write(byte[] b)`:将 b.length字节从指定的字节数组写入此输出流。 +- `public void write(byte[] b, int off, int len)` :从指定的字节数组写入 len字节,从偏移量 off开始输出到此输出流。 +- `public void flush() ` :刷新此输出流并强制任何缓冲的输出字节被写出。 +- `public void close()` :关闭此输出流并释放与此流相关联的任何系统资源。 + +> 说明:close()方法,当完成流的操作时,必须调用此方法,释放系统资源。 +> + +### 4.2 FileInputStream 与 FileOutputStream + +#### 4.2.1 FileInputStream + +`java.io.FileInputStream `类是文件输入流,从文件中读取字节。 + +- `FileInputStream(File file)`: 通过打开与实际文件的连接来创建一个 FileInputStream ,该文件由文件系统中的 File对象 file命名。 +- `FileInputStream(String name)`: 通过打开与实际文件的连接来创建一个 FileInputStream ,该文件由文件系统中的路径名 name命名。 + +举例: + +```java +//read.txt文件中的内容如下: +abcde +``` + +读取操作 + +```java +public class FISRead { + //注意:应该使用try-catch-finally处理异常。这里出于方便阅读代码,使用了throws的方式 + @Test + public void test() throws IOException { + // 使用文件名称创建流对象 + FileInputStream fis = new FileInputStream("read.txt"); + // 读取数据,返回一个字节 + int read = fis.read(); + System.out.println((char) read); + read = fis.read(); + System.out.println((char) read); + read = fis.read(); + System.out.println((char) read); + read = fis.read(); + System.out.println((char) read); + read = fis.read(); + System.out.println((char) read); + // 读取到末尾,返回-1 + read = fis.read(); + System.out.println(read); + // 关闭资源 + fis.close(); + /* + 文件内容:abcde + 输出结果: + a + b + c + d + e + -1 + */ + } + + @Test + public void test02()throws IOException{ + // 使用文件名称创建流对象 + FileInputStream fis = new FileInputStream("read.txt"); + // 定义变量,保存数据 + int b; + // 循环读取 + while ((b = fis.read())!=-1) { + System.out.println((char)b); + } + // 关闭资源 + fis.close(); + } + + @Test + public void test03()throws IOException{ + // 使用文件名称创建流对象. + FileInputStream fis = new FileInputStream("read.txt"); // 文件中为abcde + // 定义变量,作为有效个数 + int len; + // 定义字节数组,作为装字节数据的容器 + byte[] b = new byte[2]; + // 循环读取 + while (( len= fis.read(b))!=-1) { + // 每次读取后,把数组变成字符串打印 + System.out.println(new String(b)); + } + // 关闭资源 + fis.close(); + /* + 输出结果: + ab + cd + ed + 最后错误数据`d`,是由于最后一次读取时,只读取一个字节`e`,数组中, + 上次读取的数据没有被完全替换,所以要通过`len` ,获取有效的字节 + */ + } + + @Test + public void test04()throws IOException{ + // 使用文件名称创建流对象. + FileInputStream fis = new FileInputStream("read.txt"); // 文件中为abcde + // 定义变量,作为有效个数 + int len; + // 定义字节数组,作为装字节数据的容器 + byte[] b = new byte[2]; + // 循环读取 + while (( len= fis.read(b))!=-1) { + // 每次读取后,把数组的有效字节部分,变成字符串打印 + System.out.println(new String(b,0,len));// len 每次读取的有效字节个数 + } + // 关闭资源 + fis.close(); + /* + 输出结果: + ab + cd + e + */ + } +} +``` + +#### 4.2.2 FileOutputStream + +`java.io.FileOutputStream `类是文件输出流,用于将数据写出到文件。 + +- `public FileOutputStream(File file)`:创建文件输出流,写出由指定的 File对象表示的文件。 +- `public FileOutputStream(String name)`: 创建文件输出流,指定的名称为写出文件。 +- `public FileOutputStream(File file, boolean append)`: 创建文件输出流,指明是否在现有文件末尾追加内容。 + +举例: + +```java +package com.atguigu.fileio; + +import org.junit.Test; + +import java.io.FileOutputStream; +import java.io.IOException; + +public class FOSWrite { + //注意:应该使用try-catch-finally处理异常。这里出于方便阅读代码,使用了throws的方式 + @Test + public void test01() throws IOException { + // 使用文件名称创建流对象 + FileOutputStream fos = new FileOutputStream("fos.txt"); + // 写出数据 + fos.write(97); // 写出第1个字节 + fos.write(98); // 写出第2个字节 + fos.write(99); // 写出第3个字节 + // 关闭资源 + fos.close(); + /* 输出结果:abc*/ + } + + @Test + public void test02()throws IOException { + // 使用文件名称创建流对象 + FileOutputStream fos = new FileOutputStream("fos.txt"); + // 字符串转换为字节数组 + byte[] b = "abcde".getBytes(); + // 写出从索引2开始,2个字节。索引2是c,两个字节,也就是cd。 + fos.write(b,2,2); + // 关闭资源 + fos.close(); + } + //这段程序如果多运行几次,每次都会在原来文件末尾追加abcde + @Test + public void test03()throws IOException { + // 使用文件名称创建流对象 + FileOutputStream fos = new FileOutputStream("fos.txt",true); + // 字符串转换为字节数组 + byte[] b = "abcde".getBytes(); + fos.write(b); + // 关闭资源 + fos.close(); + } + + //使用FileInputStream\FileOutputStream,实现对文件的复制 + @Test + public void test05() { + FileInputStream fis = null; + FileOutputStream fos = null; + try { + //1. 造文件-造流 + //复制图片:成功 +// fis = new FileInputStream(new File("pony.jpg")); +// fos = new FileOutputStream(new File("pony_copy1.jpg")); + + //复制文本文件:成功 + fis = new FileInputStream(new File("hello.txt")); + fos = new FileOutputStream(new File("hello1.txt")); + + //2. 复制操作(读、写) + byte[] buffer = new byte[1024]; + int len;//每次读入到buffer中字节的个数 + while ((len = fis.read(buffer)) != -1) { + fos.write(buffer, 0, len); +// String str = new String(buffer,0,len); +// System.out.print(str); + } + System.out.println("复制成功"); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + //3. 关闭资源 + try { + if (fos != null) + fos.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + if (fis != null) + fis.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + } +} +``` + +### 4.3 练习 + +**练习:**实现图片加密操作。 + +提示: + + ![image-20220413002723838](images/image-20220413002723838.png) + +```java +/** + * @author 尚硅谷-宋红康 + * @create 8:59 + */ +public class FileSecretTest { + /* + * 图片的加密 + * */ + @Test + public void test1(){ + FileInputStream fis = null; + FileOutputStream fos = null; + try { + File file1 = new File("pony.jpg"); + File file2 = new File("pony_secret.jpg"); + fis = new FileInputStream(file1); + fos = new FileOutputStream(file2); + + //方式1:每次读入一个字节,效率低 +// int data; +// while((data = fis.read()) != -1){ +// fos.write(data ^ 5); +// } + //方式2:每次读入一个字节数组,效率高 + int len; + byte[] buffer = new byte[1024]; + while((len = fis.read(buffer)) != -1){ + + for(int i = 0;i < len;i++){ + buffer[i] = (byte) (buffer[i] ^ 5); + } + + fos.write(buffer,0,len); + + } + + + System.out.println("加密成功"); + } catch (IOException e) { + e.printStackTrace(); + } finally { + + try { + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /* + * 图片的解密 + * */ + @Test + public void test2(){ + FileInputStream fis = null; + FileOutputStream fos = null; + try { + File file1 = new File("pony_secret.jpg"); + File file2 = new File("pony_unsecret.jpg"); + fis = new FileInputStream(file1); + fos = new FileOutputStream(file2); + + //方式1:每次读入一个字节,效率低 +// int data; +// while((data = fis.read()) != -1){ +// fos.write(data ^ 5); +// } + //方式2:每次读入一个字节数组,效率高 + int len; + byte[] buffer = new byte[1024]; + while((len = fis.read(buffer)) != -1){ + + for(int i = 0;i < len;i++){ + buffer[i] = (byte) (buffer[i] ^ 5); + } + + fos.write(buffer,0,len); + + } + + System.out.println("解密成功"); + } catch (IOException e) { + e.printStackTrace(); + } finally { + + try { + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} +``` + +## 5. 处理流之一:缓冲流 + +- `为了提高数据读写的速度`,Java API提供了带缓冲功能的流类:缓冲流。 + +- 缓冲流要“套接”在相应的节点流之上,根据数据操作单位可以把缓冲流分为: + - **字节缓冲流**:`BufferedInputStream`,`BufferedOutputStream` + - **字符缓冲流**:`BufferedReader`,`BufferedWriter` + +- 缓冲流的基本原理:在创建流对象时,内部会创建一个缓冲区数组(缺省使用`8192个字节(8Kb)`的缓冲区),通过缓冲区读写,减少系统IO次数,从而提高读写的效率。 + + +![image-20220413002314063](images/image-20220413002314063.png) + + + +image-20220514183413011 + +### 5.1 构造器 + +* `public BufferedInputStream(InputStream in)` :创建一个 新的字节型的缓冲输入流。 +* `public BufferedOutputStream(OutputStream out)`: 创建一个新的字节型的缓冲输出流。 + +代码举例: + +```java +// 创建字节缓冲输入流 +BufferedInputStream bis = new BufferedInputStream(new FileInputStream("abc.jpg")); +// 创建字节缓冲输出流 +BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("abc_copy.jpg")); +``` + +* `public BufferedReader(Reader in)` :创建一个 新的字符型的缓冲输入流。 +* `public BufferedWriter(Writer out)`: 创建一个新的字符型的缓冲输出流。 + +代码举例: + +```java +// 创建字符缓冲输入流 +BufferedReader br = new BufferedReader(new FileReader("br.txt")); +// 创建字符缓冲输出流 +BufferedWriter bw = new BufferedWriter(new FileWriter("bw.txt")); +``` + +### 5.2 效率测试 + +查询API,缓冲流读写方法与基本的流是一致的,我们通过复制大文件(375MB),测试它的效率。 + +```java +//方法1:使用FileInputStream\FileOutputStream实现非文本文件的复制 +public void copyFileWithFileStream(String srcPath,String destPath){ + FileInputStream fis = null; + FileOutputStream fos = null; + try { + //1. 造文件-造流 + fis = new FileInputStream(new File(srcPath)); + fos = new FileOutputStream(new File(destPath)); + + //2. 复制操作(读、写) + byte[] buffer = new byte[100]; + int len;//每次读入到buffer中字节的个数 + while ((len = fis.read(buffer)) != -1) { + fos.write(buffer, 0, len); + } + System.out.println("复制成功"); + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + //3. 关闭资源 + try { + if (fos != null) + fos.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + if (fis != null) + fis.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} + +@Test +public void test1(){ + String srcPath = "C:\\Users\\shkstart\\Desktop\\01-复习.mp4"; + String destPath = "C:\\Users\\shkstart\\Desktop\\01-复习2.mp4"; + + long start = System.currentTimeMillis(); + + copyFileWithFileStream(srcPath,destPath); + + long end = System.currentTimeMillis(); + + System.out.println("花费的时间为:" + (end - start));//7677毫秒 + +} + +//方法2:使用BufferedInputStream\BufferedOuputStream实现非文本文件的复制 +public void copyFileWithBufferedStream(String srcPath,String destPath){ + FileInputStream fis = null; + FileOutputStream fos = null; + BufferedInputStream bis = null; + BufferedOutputStream bos = null; + try { + //1. 造文件 + File srcFile = new File(srcPath); + File destFile = new File(destPath); + //2. 造流 + fis = new FileInputStream(srcFile); + fos = new FileOutputStream(destFile); + + bis = new BufferedInputStream(fis); + bos = new BufferedOutputStream(fos); + + //3. 读写操作 + int len; + byte[] buffer = new byte[100]; + while ((len = bis.read(buffer)) != -1) { + bos.write(buffer, 0, len); + } + System.out.println("复制成功"); + } catch (IOException e) { + e.printStackTrace(); + } finally { + //4. 关闭资源(如果有多个流,我们需要先关闭外面的流,再关闭内部的流) + try { + if (bos != null) + bos.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + if (bis != null) + bis.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } +} +@Test +public void test2(){ + String srcPath = "C:\\Users\\shkstart\\Desktop\\01-复习.mp4"; + String destPath = "C:\\Users\\shkstart\\Desktop\\01-复习2.mp4"; + + long start = System.currentTimeMillis(); + + copyFileWithBufferedStream(srcPath,destPath); + + long end = System.currentTimeMillis(); + + System.out.println("花费的时间为:" + (end - start));//415毫秒 + +} +``` + +### 5.3 字符缓冲流特有方法 + +字符缓冲流的基本方法与普通字符流调用方式一致,不再阐述,我们来看它们具备的特有方法。 + +* BufferedReader:`public String readLine()`: 读一行文字。 +* BufferedWriter:`public void newLine()`: 写一行行分隔符,由系统属性定义符号。 + +```java +public class BufferedIOLine { + @Test + public void testReadLine()throws IOException { + // 创建流对象 + BufferedReader br = new BufferedReader(new FileReader("in.txt")); + // 定义字符串,保存读取的一行文字 + String line; + // 循环读取,读取到最后返回null + while ((line = br.readLine())!=null) { + System.out.println(line); + } + // 释放资源 + br.close(); + } + + @Test + public void testNewLine()throws IOException{ + // 创建流对象 + BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); + // 写出数据 + bw.write("尚"); + // 写出换行 + bw.newLine(); + bw.write("硅"); + bw.newLine(); + bw.write("谷"); + bw.newLine(); + // 释放资源 + bw.close(); + } +} + +``` + +> 说明: +> +> 1. 涉及到嵌套的多个流时,如果都显式关闭的话,需要先关闭外层的流,再关闭内层的流 +> +> 2. 其实在开发中,只需要关闭最外层的流即可,因为在关闭外层流时,内层的流也会被关闭。 + +### 5.4 练习 + +**练习1:**分别使用节点流:FileInputStream、FileOutputStream和缓冲流:BufferedInputStream、BufferedOutputStream实现文本文件/图片/视频文件的复制。并比较二者在数据复制方面的效率。 + +**练习2:** + +姓氏统计:一个文本文件中存储着北京所有高校在校生的姓名,格式如下: + +``` +每行一个名字,姓与名以空格分隔: +张 三 +李 四 +王 小五 +``` + +现在想统计所有的姓氏在文件中出现的次数,请描述一下你的解决方案。 + +```java + public static void main(String[] args) { + HashMap map = new HashMap<>(); + BufferedReader br = null; + try { + br = new BufferedReader(new FileReader(new File("e:/name.txt"))); + String value = null; // 临时接收文件中的字符串变量 + StringBuffer buffer = new StringBuffer(); + flag: + while ((value = br.readLine()) != null) { // 开始读取文件中的字符 + char[] c = value.toCharArray(); + for (int i = 0; i < c.length; i++) { + if (c[i] != ' ') { + buffer.append(String.valueOf(c[i])); + } else { + if (map.containsKey(buffer.toString())) { + int count = map.get(buffer.toString()); + map.put(buffer.toString(), count + 1); + } else { + map.put(buffer.toString(), 1); + } + buffer.delete(0, buffer.length()); + continue flag; + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + Set> set = map.entrySet(); + Iterator> it = set.iterator(); + while (it.hasNext()) { + Map.Entry end = (Map.Entry) it.next(); + System.out.println(end); + } + + } +``` + +## 6. 处理流之二:转换流 + +### 6.1 问题引入 + +**引入情况1:** + +使用`FileReader` 读取项目中的文本文件。由于IDEA设置中针对项目设置了UTF-8编码,当读取Windows系统中创建的文本文件时,如果Windows系统默认的是GBK编码,则读入内存中会出现乱码。 + +```java +package com.atguigu.transfer; + +import java.io.FileReader; +import java.io.IOException; + +public class Problem { + public static void main(String[] args) throws IOException { + FileReader fileReader = new FileReader("E:\\File_GBK.txt"); + int data; + while ((data = fileReader.read()) != -1) { + System.out.print((char)data); + } + fileReader.close(); + } +} + +输出结果: +��� +``` + +那么如何读取GBK编码的文件呢? + +**引入情况2:** + +针对文本文件,现在使用一个字节流进行数据的读入,希望将数据显示在控制台上。此时针对包含中文的文本数据,可能会出现乱码。 + +### 6.2 转换流的理解 + +**作用:转换流是字节与字符间的桥梁!** + + + +具体来说: + +image-20220412231533768 + +### 6.3 InputStreamReader 与 OutputStreamWriter + +- **InputStreamReader** + - 转换流`java.io.InputStreamReader`,是Reader的子类,是从字节流到字符流的桥梁。它读取字节,并使用指定的字符集将其解码为字符。它的字符集可以由名称指定,也可以接受平台的默认字符集。 + + - 构造器 + + - `InputStreamReader(InputStream in)`: 创建一个使用默认字符集的字符流。 + - `InputStreamReader(InputStream in, String charsetName)`: 创建一个指定字符集的字符流。 + + - 举例 + + ```java + //使用默认字符集 + InputStreamReader isr1 = new InputStreamReader(new FileInputStream("in.txt")); + //使用指定字符集 + InputStreamReader isr2 = new InputStreamReader(new FileInputStream("in.txt") , "GBK"); + ``` + + - 示例代码: + + ```java + package com.atguigu.transfer; + + import java.io.FileInputStream; + import java.io.IOException; + import java.io.InputStreamReader; + + public class InputStreamReaderDemo { + public static void main(String[] args) throws IOException { + // 定义文件路径,文件为gbk编码 + String fileName = "E:\\file_gbk.txt"; + //方式1: + // 创建流对象,默认UTF8编码 + InputStreamReader isr1 = new InputStreamReader(new FileInputStream(fileName)); + // 定义变量,保存字符 + int charData; + // 使用默认编码字符流读取,乱码 + while ((charData = isr1.read()) != -1) { + System.out.print((char)charData); // ��Һ� + } + isr1.close(); + + //方式2: + // 创建流对象,指定GBK编码 + InputStreamReader isr2 = new InputStreamReader(new FileInputStream(fileName) , "GBK"); + // 使用指定编码字符流读取,正常解析 + while ((charData = isr2.read()) != -1) { + System.out.print((char)charData);// 大家好 + } + isr2.close(); + } + } + ``` + +- **OutputStreamWriter** + - 转换流`java.io.OutputStreamWriter` ,是Writer的子类,是从字符流到字节流的桥梁。使用指定的字符集将字符编码为字节。它的字符集可以由名称指定,也可以接受平台的默认字符集。 + + - 构造器 + + - `OutputStreamWriter(OutputStream in)`: 创建一个使用默认字符集的字符流。 + - `OutputStreamWriter(OutputStream in,String charsetName)`: 创建一个指定字符集的字符流。 + + - 举例: + + ```java + //使用默认字符集 + OutputStreamWriter isr = new OutputStreamWriter(new FileOutputStream("out.txt")); + //使用指定的字符集 + OutputStreamWriter isr2 = new OutputStreamWriter(new FileOutputStream("out.txt") , "GBK"); + ``` + + - 示例代码: + + ```java + package com.atguigu.transfer; + + import java.io.FileOutputStream; + import java.io.IOException; + import java.io.OutputStreamWriter; + + public class OutputStreamWriterDemo { + public static void main(String[] args) throws IOException { + // 定义文件路径 + String FileName = "E:\\out_utf8.txt"; + // 创建流对象,默认UTF8编码 + OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(FileName)); + // 写出数据 + osw.write("你好"); // 保存为6个字节 + osw.close(); + + // 定义文件路径 + String FileName2 = "E:\\out_gbk.txt"; + // 创建流对象,指定GBK编码 + OutputStreamWriter osw2 = new OutputStreamWriter(new + FileOutputStream(FileName2),"GBK"); + // 写出数据 + osw2.write("你好");// 保存为4个字节 + osw2.close(); + } + } + ``` + +### 6.4 字符编码和字符集 + +#### 6.4.1 编码与解码 + +计算机中储存的信息都是用`二进制数`表示的,而我们在屏幕上看到的数字、英文、标点符号、汉字等字符是二进制数转换之后的结果。按照某种规则,将字符存储到计算机中,称为**编码** 。反之,将存储在计算机中的二进制数按照某种规则解析显示出来,称为**解码** 。 + +**字符编码(Character Encoding)** : 就是一套自然语言的字符与二进制数之间的对应规则。 + +**编码表**:生活中文字和计算机中二进制的对应规则 + +**乱码的情况**:按照A规则存储,同样按照A规则解析,那么就能显示正确的文本符号。反之,按照A规则存储,再按照B规则解析,就会导致乱码现象。 + +``` +编码:字符(人能看懂的)--字节(人看不懂的) + +解码:字节(人看不懂的)-->字符(人能看懂的) +``` + +#### 6.4.2 字符集 + +* **字符集Charset**:也叫编码表。是一个系统支持的所有字符的集合,包括各国家文字、标点符号、图形符号、数字等。 + +- 计算机要准确的存储和识别各种字符集符号,需要进行字符编码,一套字符集必然至少有一套字符编码。常见字符集有ASCII字符集、GBK字符集、Unicode字符集等。 + + +可见,当指定了**编码**,它所对应的**字符集**自然就指定了,所以**编码**才是我们最终要关心的。 + +* **ASCII字符集** : + + * ASCII码(American Standard Code for Information Interchange,美国信息交换标准代码):上个世纪60年代,美国制定了一套字符编码,对`英语字符`与二进制位之间的关系,做了统一规定。这被称为ASCII码。 + * ASCII码用于显示现代英语,主要包括控制字符(回车键、退格、换行键等)和可显示字符(英文大小写字符、阿拉伯数字和西文符号)。 + * 基本的ASCII字符集,使用7位(bits)表示一个字符(最前面的1位统一规定为0),共`128个`字符。比如:空格“SPACE”是32(二进制00100000),大写的字母A是65(二进制01000001)。 + * 缺点:不能表示所有字符。 + +* **ISO-8859-1字符集**: + * 拉丁码表,别名Latin-1,用于显示欧洲使用的语言,包括荷兰语、德语、意大利语、葡萄牙语等 + * ISO-8859-1使用单字节编码,兼容ASCII编码。 + +* **GBxxx字符集**: + * GB就是国标的意思,是为了`显示中文`而设计的一套字符集。 + * **GB2312**:简体中文码表。一个小于127的字符的意义与原来相同,即向下兼容ASCII码。但两个大于127的字符连在一起时,就表示一个汉字,这样大约可以组合了包含`7000多个简体汉字`,此外数学符号、罗马希腊的字母、日文的假名们都编进去了,这就是常说的"全角"字符,而原来在127号以下的那些符号就叫"半角"字符了。 + * **GBK**:最常用的中文码表。是在GB2312标准基础上的扩展规范,使用了`双字节`编码方案,共收录了`21003个`汉字,完全兼容GB2312标准,同时支持`繁体汉字`以及日韩汉字等。 + * **GB18030**:最新的中文码表。收录汉字`70244个`,采用`多字节`编码,每个字可以由1个、2个或4个字节组成。支持中国国内少数民族的文字,同时支持繁体汉字以及日韩汉字等。 + +* **Unicode字符集** : + * Unicode编码为表达`任意语言的任意字符`而设计,也称为统一码、标准万国码。Unicode 将世界上所有的文字用`2个字节`统一进行编码,为每个字符设定唯一的二进制编码,以满足跨语言、跨平台进行文本处理的要求。 + + - Unicode 的缺点:这里有三个问题: + - 第一,英文字母只用一个字节表示就够了,如果用更多的字节存储是`极大的浪费`。 + - 第二,如何才能`区别Unicode和ASCII`?计算机怎么知道两个字节表示一个符号,而不是分别表示两个符号呢? + - 第三,如果和GBK等双字节编码方式一样,用最高位是1或0表示两个字节和一个字节,就少了很多值无法用于表示字符,`不够表示所有字符`。 + - Unicode在很长一段时间内无法推广,直到互联网的出现,为解决Unicode如何在网络上传输的问题,于是面向传输的众多 UTF(UCS Transfer Format)标准出现。具体来说,有三种编码方案,UTF-8、UTF-16和UTF-32。 + +* **UTF-8字符集**: + + * Unicode是字符集,UTF-8、UTF-16、UTF-32是三种`将数字转换到程序数据`的编码方案。顾名思义,UTF-8就是每次8个位传输数据,而UTF-16就是每次16个位。其中,UTF-8 是在互联网上`使用最广`的一种 Unicode 的实现方式。 + * 互联网工程工作小组(IETF)要求所有互联网协议都必须支持UTF-8编码。所以,我们开发Web应用,也要使用UTF-8编码。UTF-8 是一种`变长的编码方式`。它使用1-4个字节为每个字符编码,编码规则: + 1. 128个US-ASCII字符,只需一个字节编码。 + 2. 拉丁文等字符,需要二个字节编码。 + 3. 大部分常用字(含中文),使用三个字节编码。 + 4. 其他极少使用的Unicode辅助字符,使用四字节编码。 + +- 举例 + +Unicode符号范围 | UTF-8编码方式 + +``` +(十六进制) | (二进制) + +————————————————————|—–—–—–—–—–—–—–—–—–—–—–—–—–—– + +0000 0000-0000 007F | 0xxxxxxx(兼容原来的ASCII) + +0000 0080-0000 07FF | 110xxxxx 10xxxxxx + +0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx + +0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx +``` + +![image-20220525164636164](images/image-20220525164636164.png) + +- 小结 + +![字符集](images/字符集.jpg) + +> 注意:在中文操作系统上,ANSI(美国国家标准学会、AMERICAN NATIONAL STANDARDS INSTITUTE: ANSI)编码即为GBK;在英文操作系统上,ANSI编码即为ISO-8859-1。 + +### 6.5 练习 + +把当前module下的《康师傅的话.txt》字符编码为GBK,复制到电脑桌面目录下的《寄语.txt》, +字符编码为UTF-8。 + +在当前module下的文本内容: + +``` +六项精进: +(一)付出不亚于任何人的努力 +(二)要谦虚,不要骄傲 +(三)要每天反省 +(四)活着,就要感谢 +(五)积善行、思利他 +(六)不要有感性的烦恼 +``` + +代码: + +```java +/** + * @author 尚硅谷-宋红康 + * @create 9:06 + */ +public class InputStreamReaderDemo { + + @Test + public void test() { + InputStreamReader isr = null; + OutputStreamWriter osw = null; + try { + isr = new InputStreamReader(new FileInputStream("康师傅的话.txt"),"gbk"); + + osw = new OutputStreamWriter(new FileOutputStream("C:\\Users\\shkstart\\Desktop\\寄语.txt"),"utf-8"); + + char[] cbuf = new char[1024]; + int len; + while ((len = isr.read(cbuf)) != -1) { + osw.write(cbuf, 0, len); + osw.flush(); + } + System.out.println("文件复制完成"); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (isr != null) + isr.close(); + } catch (IOException e) { + e.printStackTrace(); + } + try { + if (osw != null) + osw.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + +} +``` + +## 7. 处理流之三/四:数据流、对象流 + +### 7.1 数据流与对象流说明 + +如果需要将内存中定义的变量(包括基本数据类型或引用数据类型)保存在文件中,那怎么办呢? + +```java +int age = 300; +char gender = '男'; +int energy = 5000; +double price = 75.5; +boolean relive = true; + +String name = "巫师"; +Student stu = new Student("张三",23,89); +``` + +Java提供了数据流和对象流来处理这些类型的数据: + +- **数据流:DataOutputStream、DataInputStream** + - DataOutputStream:允许应用程序将基本数据类型、String类型的变量写入输出流中 + + - DataInputStream:允许应用程序以与机器无关的方式从底层输入流中读取基本数据类型、String类型的变量。 +- 对象流DataInputStream中的方法: + +```java + byte readByte() short readShort() + int readInt() long readLong() + float readFloat() double readDouble() + char readChar() boolean readBoolean() + String readUTF() void readFully(byte[] b) +``` + +- 对象流DataOutputStream中的方法:将上述的方法的read改为相应的write即可。 +- 数据流的弊端:只支持Java基本数据类型和字符串的读写,而不支持其它Java对象的类型。而ObjectOutputStream和ObjectInputStream既支持Java基本数据类型的数据读写,又支持Java对象的读写,所以重点介绍对象流ObjectOutputStream和ObjectInputStream。 +- **对象流:ObjectOutputStream、ObjectInputStream** + + - ObjectOutputStream:将 Java 基本数据类型和对象写入字节输出流中。通过在流中使用文件可以实现Java各种基本数据类型的数据以及对象的持久存储。 + - ObjectInputStream:ObjectInputStream 对以前使用 ObjectOutputStream 写出的基本数据类型的数据和对象进行读入操作,保存在内存中。 + +> 说明:对象流的强大之处就是可以把Java中的对象写入到数据源中,也能把对象从数据源中还原回来。 + +### 7.2 对象流API + +**ObjectOutputStream中的构造器:** + +`public ObjectOutputStream(OutputStream out) `: 创建一个指定的ObjectOutputStream。 + +```java +FileOutputStream fos = new FileOutputStream("game.dat"); +ObjectOutputStream oos = new ObjectOutputStream(fos); +``` + +**ObjectOutputStream中的方法:** + +- public void writeBoolean(boolean val):写出一个 boolean 值。 +- public void writeByte(int val):写出一个8位字节 +- public void writeShort(int val):写出一个16位的 short 值 +- public void writeChar(int val):写出一个16位的 char 值 +- public void writeInt(int val):写出一个32位的 int 值 +- public void writeLong(long val):写出一个64位的 long 值 +- public void writeFloat(float val):写出一个32位的 float 值。 +- public void writeDouble(double val):写出一个64位的 double 值 +- public void writeUTF(String str):将表示长度信息的两个字节写入输出流,后跟字符串 s 中每个字符的 UTF-8 修改版表示形式。根据字符的值,将字符串 s 中每个字符转换成一个字节、两个字节或三个字节的字节组。注意,将 String 作为基本数据写入流中与将它作为 Object 写入流中明显不同。 如果 s 为 null,则抛出 NullPointerException。 +- `public void writeObject(Object obj)`:写出一个obj对象 +- public void close() :关闭此输出流并释放与此流相关联的任何系统资源 + +**ObjectInputStream中的构造器:** + +`public ObjectInputStream(InputStream in) `: 创建一个指定的ObjectInputStream。 + +```java +FileInputStream fis = new FileInputStream("game.dat"); +ObjectInputStream ois = new ObjectInputStream(fis); +``` + +**ObjectInputStream中的方法:** + +- public boolean readBoolean():读取一个 boolean 值 +- public byte readByte():读取一个 8 位的字节 +- public short readShort():读取一个 16 位的 short 值 +- public char readChar():读取一个 16 位的 char 值 +- public int readInt():读取一个 32 位的 int 值 +- public long readLong():读取一个 64 位的 long 值 +- public float readFloat():读取一个 32 位的 float 值 +- public double readDouble():读取一个 64 位的 double 值 +- public String readUTF():读取 UTF-8 修改版格式的 String +- `public void readObject(Object obj)`:读入一个obj对象 +- public void close() :关闭此输入流并释放与此流相关联的任何系统资源 + +### 7.3 认识对象序列化机制 + +**1、何为对象序列化机制?** + +`对象序列化机制`允许把内存中的Java对象转换成平台无关的二进制流,从而允许把这种二进制流持久地保存在磁盘上,或通过网络将这种二进制流传输到另一个网络节点。//当其它程序获取了这种二进制流,就可以恢复成原来的Java对象。 + +- 序列化过程:用一个字节序列可以表示一个对象,该字节序列包含该`对象的类型`和`对象中存储的属性`等信息。字节序列写出到文件之后,相当于文件中`持久保存`了一个对象的信息。 + + +- 反序列化过程:该字节序列还可以从文件中读取回来,重构对象,对它进行`反序列化`。`对象的数据`、`对象的类型`和`对象中存储的数据`信息,都可以用来在内存中创建对象。 + +image-20220503123328452 + +**2、序列化机制的重要性** + +序列化是 RMI(Remote Method Invoke、远程方法调用)过程的参数和返回值都必须实现的机制,而 RMI 是 JavaEE 的基础。因此序列化机制是 JavaEE 平台的基础。 + +序列化的好处,在于可将任何实现了Serializable接口的对象转化为**字节数据**,使其在保存和传输时可被还原。 + +**3、实现原理** + +- 序列化:用ObjectOutputStream类保存基本类型数据或对象的机制。方法为: + - `public final void writeObject (Object obj)` : 将指定的对象写出。 + +- 反序列化:用ObjectInputStream类读取基本类型数据或对象的机制。方法为: + - `public final Object readObject ()` : 读取一个对象。 + + + +### 7.4 如何实现序列化机制 + +如果需要让某个对象支持序列化机制,则必须让对象所属的类及其属性是可序列化的,为了让某个类是可序列化的,该类必须实现`java.io.Serializable ` 接口。`Serializable` 是一个`标记接口`,不实现此接口的类将不会使任何状态序列化或反序列化,会抛出`NotSerializableException` 。 + +* 如果对象的某个属性也是引用数据类型,那么如果该属性也要序列化的话,也要实现`Serializable` 接口 +* 该类的所有属性必须是可序列化的。如果有一个属性不需要可序列化的,则该属性必须注明是瞬态的,使用`transient` 关键字修饰。 +* `静态(static)变量`的值不会序列化。因为静态变量的值不属于某个对象。 + +举例1: + +```java +package com.atguigu.object; + +import org.junit.Test; + +import java.io.*; + +public class ReadWriteDataOfAnyType { + @Test + public void save() throws IOException { + String name = "巫师"; + int age = 300; + char gender = '男'; + int energy = 5000; + double price = 75.5; + boolean relive = true; + + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("game.dat")); + oos.writeUTF(name); + oos.writeInt(age); + oos.writeChar(gender); + oos.writeInt(energy); + oos.writeDouble(price); + oos.writeBoolean(relive); + oos.close(); + } + @Test + public void reload()throws IOException{ + ObjectInputStream ois = new ObjectInputStream(new FileInputStream("game.dat")); + String name = ois.readUTF(); + int age = ois.readInt(); + char gender = ois.readChar(); + int energy = ois.readInt(); + double price = ois.readDouble(); + boolean relive = ois.readBoolean(); + + System.out.println(name+"," + age + "," + gender + "," + energy + "," + price + "," + relive); + + ois.close(); + } +} + +``` + +举例2: + +```java +package com.atguigu.object; + +import java.io.Serializable; + +public class Employee implements Serializable { + //static final long serialVersionUID = 23234234234L; + public static String company; //static修饰的类变量,不会被序列化 + public String name; + public String address; + public transient int age; // transient瞬态修饰成员,不会被序列化 + + public Employee(String name, String address, int age) { + this.name = name; + this.address = address; + this.age = age; + } + + public static String getCompany() { + return company; + } + + public static void setCompany(String company) { + Employee.company = company; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return "Employee{" + + "name='" + name + '\'' + + ", address='" + address + '\'' + + ", age=" + age + + ", company=" + company + + '}'; + } +} + +``` + +```java +package com.atguigu.object; + +import org.junit.Test; + +import java.io.*; + +public class ReadWriteObject { + @Test + public void save() throws IOException { + Employee.setCompany("尚硅谷"); + Employee e = new Employee("小谷姐姐", "宏福苑", 23); + // 创建序列化流对象 + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("employee.dat")); + // 写出对象 + oos.writeObject(e); + // 释放资源 + oos.close(); + System.out.println("Serialized data is saved"); // 姓名,地址被序列化,年龄没有被序列化。 + } + + @Test + public void reload() throws IOException, ClassNotFoundException { + // 创建反序列化流 + FileInputStream fis = new FileInputStream("employee.dat"); + ObjectInputStream ois = new ObjectInputStream(fis); + // 读取一个对象 + Employee e = (Employee) ois.readObject(); + // 释放资源 + ois.close(); + fis.close(); + + System.out.println(e); + } +} +``` + +举例3:如果有多个对象需要序列化,则可以将对象放到集合中,再序列化集合对象即可。 + +```java +package com.atguigu.object; + +import org.junit.Test; + +import java.io.*; +import java.util.ArrayList; + +public class ReadWriteCollection { + @Test + public void save() throws IOException { + ArrayList list = new ArrayList<>(); + list.add(new Employee("张三", "宏福苑", 23)); + list.add(new Employee("李四", "白庙", 24)); + list.add(new Employee("王五", "平西府", 25)); + // 创建序列化流对象 + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("employees.dat")); + // 写出对象 + oos.writeObject(list); + // 释放资源 + oos.close(); + } + + @Test + public void reload() throws IOException, ClassNotFoundException { + // 创建反序列化流 + FileInputStream fis = new FileInputStream("employees.dat"); + ObjectInputStream ois = new ObjectInputStream(fis); + // 读取一个对象 + ArrayList list = (ArrayList) ois.readObject(); + // 释放资源 + ois.close(); + fis.close(); + + System.out.println(list); + } +} + +``` + +### 7.5 反序列化失败问题 + +**问题1:** + +对于JVM可以反序列化对象,它必须是能够找到class文件的类。如果找不到该类的class文件,则抛出一个 `ClassNotFoundException` 异常。 + +**问题2:** + +当JVM反序列化对象时,能找到class文件,但是class文件在序列化对象之后发生了修改,那么反序列化操作也会失败,抛出一个`InvalidClassException`异常。发生这个异常的原因如下: + +* 该类的序列版本号与从流中读取的类描述符的版本号不匹配 +* 该类包含未知数据类型 + +解决办法: + +`Serializable` 接口给需要序列化的类,提供了一个序列版本号:`serialVersionUID` 。凡是实现 Serializable接口的类都应该有一个表示序列化版本标识符的静态变量: + +```java +static final long serialVersionUID = 234242343243L; //它的值由程序员随意指定即可。 +``` + +- serialVersionUID用来表明类的不同版本间的兼容性。简单来说,Java的序列化机制是通过在运行时判断类的serialVersionUID来验证版本一致性的。在进行反序列化时,JVM会把传来的字节流中的serialVersionUID与本地相应实体类的serialVersionUID进行比较,如果相同就认为是一致的,可以进行反序列化,否则就会出现序列化版本不一致的异常(InvalidCastException)。 +- 如果类没有显示定义这个静态常量,它的值是Java运行时环境根据类的内部细节`自动生成`的。若类的实例变量做了修改,serialVersionUID `可能发生变化`。因此,建议显式声明。 +- 如果声明了serialVersionUID,即使在序列化完成之后修改了类导致类重新编译,则原来的数据也能正常反序列化,只是新增的字段值是默认值而已。 + +```java +package com.atguigu.object; + +import java.io.Serializable; + +public class Employee implements Serializable { + private static final long serialVersionUID = 1324234L; //增加serialVersionUID + + //其它结构:略 +} +``` + +### 7.6 面试题&练习 + +面试题:谈谈你对java.io.Serializable接口的理解,我们知道它用于序列化,是空方法接口,还有其它认识吗? + +```java +实现了Serializable接口的对象,可将它们转换成一系列字节,并可在以后完全恢复回原来的样子。这一过程亦可通过网络进行。这意味着序列化机制能自动补偿操作系统间的差异。换句话说,可以先在Windows机器上创建一个对象,对其序列化,然后通过网络发给一台Unix机器,然后在那里准确无误地重新“装配”。不必关心数据在不同机器上如何表示,也不必关心字节的顺序或者其他任何细节。 + +由于大部分作为参数的类如String、Integer等都实现了java.io.Serializable的接口,也可以利用多态的性质,作为参数使接口更灵活。 + +``` + +练习: + +- 需求说明: + - 网上购物时某用户填写订单,订单内容为产品列表,保存在“save.bin”中。 + - 运行时,如果不存在“save.bin”,则进行新订单录入,如果存在,则显示并计算客户所需付款。 + +- 分析: + - 编写Save()方法保存对象到“save.bin” + - 编写Load()方法获得对象,计算客户所需付款 + +image-20220503123603551 + +## 8. 其他流的使用 + +### 8.1 标准输入、输出流 + +- System.in和System.out分别代表了系统标准的输入和输出设备 +- 默认输入设备是:键盘,输出设备是:显示器 +- System.in的类型是InputStream +- System.out的类型是PrintStream,其是OutputStream的子类FilterOutputStream 的子类 +- 重定向:通过System类的setIn,setOut方法对默认设备进行改变。 + - public static void setIn(InputStream in) + - public static void setOut(PrintStream out) + +**举例:** + +从键盘输入字符串,要求将读取到的整行字符串转成大写输出。然后继续进行输入操作,直至当输入“e”或者“exit”时,退出程序。 + +```java +System.out.println("请输入信息(退出输入e或exit):"); +// 把"标准"输入流(键盘输入)这个字节流包装成字符流,再包装成缓冲流 +BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); +String s = null; +try { + while ((s = br.readLine()) != null) { // 读取用户输入的一行数据 --> 阻塞程序 + if ("e".equalsIgnoreCase(s) || "exit".equalsIgnoreCase(s)) { + System.out.println("安全退出!!"); + break; + } + // 将读取到的整行字符串转成大写输出 + System.out.println("-->:" + s.toUpperCase()); + System.out.println("继续输入信息"); + } +} catch (IOException e) { + e.printStackTrace(); +} finally { + try { + if (br != null) { + br.close(); // 关闭过滤流时,会自动关闭它包装的底层节点流 + } + } catch (IOException e) { + e.printStackTrace(); + } +} + +``` + +**拓展:** + +System类中有三个常量对象:System.out、System.in、System.err + +查看System类中这三个常量对象的声明: + +```java +public final static InputStream in = null; +public final static PrintStream out = null; +public final static PrintStream err = null; +``` + +奇怪的是, + +- 这三个常量对象有final声明,但是却初始化为null。final声明的常量一旦赋值就不能修改,那么null不会空指针异常吗? +- 这三个常量对象为什么要小写?final声明的常量按照命名规范不是应该大写吗? +- 这三个常量的对象有set方法?final声明的常量不是不能修改值吗?set方法是如何修改它们的值的? + +```java +final声明的常量,表示在Java的语法体系中它们的值是不能修改的,而这三个常量对象的值是由C/C++等系统函数进行初始化和修改值的,所以它们故意没有用大写,也有set方法。 +``` + +```java +public static void setOut(PrintStream out) { + checkIO(); + setOut0(out); +} +public static void setErr(PrintStream err) { + checkIO(); + setErr0(err); +} +public static void setIn(InputStream in) { + checkIO(); + setIn0(in); +} +private static void checkIO() { + SecurityManager sm = getSecurityManager(); + if (sm != null) { + sm.checkPermission(new RuntimePermission("setIO")); + } +} +private static native void setIn0(InputStream in); +private static native void setOut0(PrintStream out); +private static native void setErr0(PrintStream err); +``` + +**练习:** + +Create a program named MyInput.java: Contain the methods for reading int, double, float, boolean, short, byte and String values from the keyboard. + +image-20220412232254819 + +```java +package com.atguigu.java; +// MyInput.java: Contain the methods for reading int, double, float, boolean, short, byte and +// string values from the keyboard + +import java.io.*; + +public class MyInput { + // Read a string from the keyboard + public static String readString() { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + + // Declare and initialize the string + String string = ""; + + // Get the string from the keyboard + try { + string = br.readLine(); + + } catch (IOException ex) { + System.out.println(ex); + } + + // Return the string obtained from the keyboard + return string; + } + + // Read an int value from the keyboard + public static int readInt() { + return Integer.parseInt(readString()); + } + + // Read a double value from the keyboard + public static double readDouble() { + return Double.parseDouble(readString()); + } + + // Read a byte value from the keyboard + public static double readByte() { + return Byte.parseByte(readString()); + } + + // Read a short value from the keyboard + public static double readShort() { + return Short.parseShort(readString()); + } + + // Read a long value from the keyboard + public static double readLong() { + return Long.parseLong(readString()); + } + + // Read a float value from the keyboard + public static double readFloat() { + return Float.parseFloat(readString()); + } +} + +``` + +### 8.2 打印流 + +- 实现将基本数据类型的数据格式转化为字符串输出。 + + +- 打印流:`PrintStream`和`PrintWriter` + - 提供了一系列重载的print()和println()方法,用于多种数据类型的输出 + + ![image-20220131021502089](images/image-20220131021502089.png) + + ![image-20220131021528397](images/image-20220131021528397.png) + + - PrintStream和PrintWriter的输出不会抛出IOException异常 + + - PrintStream和PrintWriter有自动flush功能 + + - PrintStream 打印的所有字符都使用平台的默认字符编码转换为字节。在需要写入字符而不是写入字节的情况下,应该使用 PrintWriter 类。 + + - System.out返回的是PrintStream的实例 + +- 构造器 + - PrintStream(File file) :创建具有指定文件且不带自动行刷新的新打印流。 + - PrintStream(File file, String csn):创建具有指定文件名称和字符集且不带自动行刷新的新打印流。 + - PrintStream(OutputStream out) :创建新的打印流。 + - PrintStream(OutputStream out, boolean autoFlush):创建新的打印流。 autoFlush如果为 true,则每当写入 byte 数组、调用其中一个 println 方法或写入换行符或字节 ('\n') 时都会刷新输出缓冲区。 + - PrintStream(OutputStream out, boolean autoFlush, String encoding) :创建新的打印流。 + - PrintStream(String fileName):创建具有指定文件名称且不带自动行刷新的新打印流。 + - PrintStream(String fileName, String csn) :创建具有指定文件名称和字符集且不带自动行刷新的新打印流。 + +- 代码举例1 + + +```java +package com.atguigu.systemio; + +import java.io.FileNotFoundException; +import java.io.PrintStream; + +public class TestPrintStream { + public static void main(String[] args) throws FileNotFoundException { + PrintStream ps = new PrintStream("io.txt"); + ps.println("hello"); + ps.println(1); + ps.println(1.5); + ps.close(); + } +} + +``` + +- 代码举例2 + +```java +PrintStream ps = null; +try { + FileOutputStream fos = new FileOutputStream(new File("D:\\IO\\text.txt")); + // 创建打印输出流,设置为自动刷新模式(写入换行符或字节 '\n' 时都会刷新输出缓冲区) + ps = new PrintStream(fos, true); + if (ps != null) {// 把标准输出流(控制台输出)改成文件 + System.setOut(ps); + } + for (int i = 0; i <= 255; i++) { // 输出ASCII字符 + System.out.print((char) i); + if (i % 50 == 0) { // 每50个数据一行 + System.out.println(); // 换行 + } + } +} catch (FileNotFoundException e) { + e.printStackTrace(); +} finally { + if (ps != null) { + ps.close(); + } +} + +``` + +- 代码举例3:自定义一个日志工具 + +```java +/* +日志工具 + */ +public class Logger { + /* + 记录日志的方法。 + */ + public static void log(String msg) { + try { + // 指向一个日志文件 + PrintStream out = new PrintStream(new FileOutputStream("log.txt", true)); + // 改变输出方向 + System.setOut(out); + // 日期当前时间 + Date nowTime = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS"); + String strTime = sdf.format(nowTime); + + System.out.println(strTime + ": " + msg); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } +} +``` + +```java +public class LogTest { + public static void main(String[] args) { + //测试工具类是否好用 + Logger.log("调用了System类的gc()方法,建议启动垃圾回收"); + Logger.log("调用了TeamView的addMember()方法"); + Logger.log("用户尝试进行登录,验证失败"); + } +} +``` + +### 8.3 Scanner类 + +构造方法 + +* Scanner(File source) :构造一个新的 Scanner,它生成的值是从指定文件扫描的。 +* Scanner(File source, String charsetName) :构造一个新的 Scanner,它生成的值是从指定文件扫描的。 +* Scanner(InputStream source) :构造一个新的 Scanner,它生成的值是从指定的输入流扫描的。 +* Scanner(InputStream source, String charsetName) :构造一个新的 Scanner,它生成的值是从指定的输入流扫描的。 + +常用方法: + +* boolean hasNextXxx(): 如果通过使用nextXxx()方法,此扫描器输入信息中的下一个标记可以解释为默认基数中的一个 Xxx 值,则返回 true。 +* Xxx nextXxx(): 将输入信息的下一个标记扫描为一个Xxx + +```java +package com.atguigu.systemio; + +import org.junit.Test; + +import java.io.*; +import java.util.Scanner; + +public class TestScanner { + + @Test + public void test01() throws IOException { + Scanner input = new Scanner(System.in); + PrintStream ps = new PrintStream("1.txt"); + while(true){ + System.out.print("请输入一个单词:"); + String str = input.nextLine(); + if("stop".equals(str)){ + break; + } + ps.println(str); + } + input.close(); + ps.close(); + } + + @Test + public void test2() throws IOException { + Scanner input = new Scanner(new FileInputStream("1.txt")); + while(input.hasNextLine()){ + String str = input.nextLine(); + System.out.println(str); + } + input.close(); + } +} +``` + +## 9. apache-common包的使用 + +### 9.1 介绍 + +IO技术开发中,代码量很大,而且代码的重复率较高,为此Apache软件基金会,开发了IO技术的工具类`commonsIO`,大大简化了IO开发。 + +Apahce软件基金会属于第三方,(Oracle公司第一方,我们自己第二方,其他都是第三方)我们要使用第三方开发好的工具,需要添加jar包。 + +### 9.2 导包及举例 + +- 在导入commons-io-2.5.jar包之后,内部的API都可以使用。 + + + ![image-20220416004246436](images/image-20220416004246436.png) + +- IOUtils类的使用 + +```java +- 静态方法:IOUtils.copy(InputStream in,OutputStream out)传递字节流,实现文件复制。 +- 静态方法:IOUtils.closeQuietly(任意流对象)悄悄的释放资源,自动处理close()方法抛出的异常。 +``` + +```java +public class Test01 { + public static void main(String[] args)throws Exception { + //- 静态方法:IOUtils.copy(InputStream in,OutputStream out)传递字节流,实现文件复制。 + IOUtils.copy(new FileInputStream("E:\\Idea\\io\\1.jpg"),new FileOutputStream("E:\\Idea\\io\\file\\柳岩.jpg")); + //- 静态方法:IOUtils.closeQuietly(任意流对象)悄悄的释放资源,自动处理close()方法抛出的异常。 + /* FileWriter fw = null; + try { + fw = new FileWriter("day21\\io\\writer.txt"); + fw.write("hahah"); + } catch (IOException e) { + e.printStackTrace(); + }finally { + IOUtils.closeQuietly(fw); + }*/ + } +} +``` + +- FileUtils类的使用 + +```java +- 静态方法:void copyDirectoryToDirectory(File src,File dest):整个目录的复制,自动进行递归遍历 + 参数: + src:要复制的文件夹路径 + dest:要将文件夹粘贴到哪里去 + +- 静态方法:void writeStringToFile(File file,String content):将内容content写入到file中 +- 静态方法:String readFileToString(File file):读取文件内容,并返回一个String +- 静态方法:void copyFile(File srcFile,File destFile):文件复制 +``` + +```java +public class Test02 { + public static void main(String[] args) { + try { + //- 静态方法:void copyDirectoryToDirectory(File src,File dest); + FileUtils.copyDirectoryToDirectory(new File("E:\\Idea\\io\\aa"),new File("E:\\Idea\\io\\file")); + + + //- 静态方法:writeStringToFile(File file,String str) + FileUtils.writeStringToFile(new File("day21\\io\\commons.txt"),"柳岩你好"); + + //- 静态方法:String readFileToString(File file) + String s = FileUtils.readFileToString(new File("day21\\io\\commons.txt")); + System.out.println(s); + //- 静态方法:void copyFile(File srcFile,File destFile) + FileUtils.copyFile(new File("io\\yangm.png"),new File("io\\yangm2.png")); + System.out.println("复制成功"); + } catch (IOException e) { + e.printStackTrace(); + } + } +} +``` + + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/ChatClientTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/ChatClientTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..342a9987ef28c3dc396ee177fd89fed6e14e2b49 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/ChatClientTest.java" @@ -0,0 +1,89 @@ +//package com.atguigu02.tcpudp.chat; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.Socket; +import java.util.Scanner; + +/** + * °¸Àý£ºÁÄÌìÊҵÄʵÏÖ £¨¿ͻ§¶ˣ© + * + * @author Éйè¹È-Ëκ쿵 + * @create 16:42 + */ +public class ChatClientTest { + public static void main(String[] args)throws Exception { + //1¡¢Á¬½ӷþÎñÆ÷ + Socket socket = new Socket("127.0.0.1",8989); + + //2¡¢¿ªÆôÁ½¸öÏ߳Ì + //(1)һ¸öÏ̸߳ºÔ𿴱ðÈËÁ쬼´½ÓÊշþÎñÆ÷ת·¢µÄÏûϢ + Receive receive = new Receive(socket); + receive.start(); + + //(2)һ¸öÏ̸߳ºÔð·¢ËÍ×ԼºµĻ° + Send send = new Send(socket); + send.start(); + + send.join();//µÈÎҷ¢ËÍÏ߳̽áÊøÁˣ¬²ŽáÊøÕû¸ö³ÌÐò + + socket.close(); + } +} +class Send extends Thread{ + private Socket socket; + + public Send(Socket socket) { + super(); + this.socket = socket; + } + + public void run(){ + try { + Scanner input = new Scanner(System.in); + + OutputStream outputStream = socket.getOutputStream(); + //°´Ðдòӡ + PrintStream ps = new PrintStream(outputStream); + + //´ӼüÅ̲»¶ϵÄÊäÈë×ԼºµĻ°£¬¸ø·þÎñÆ÷·¢Ëͣ¬ÓɷþÎñÆ÷¸øÆäËûÈËת·¢ + while(true){ + System.out.print("×ԼºµĻ°£º"); + String str = input.nextLine(); //×èÈûʽµķ½·¨ + if("bye".equals(str)){ + break; + } + ps.println(str); + } + + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} +class Receive extends Thread{ + private Socket socket; + + public Receive(Socket socket) { + super(); + this.socket = socket; + } + + public void run(){ + try { + InputStream inputStream = socket.getInputStream(); + Scanner input = new Scanner(inputStream); + + while(input.hasNextLine()){ + String line = input.nextLine(); + System.out.println(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/ChatServerTest.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/ChatServerTest.java" new file mode 100644 index 0000000000000000000000000000000000000000..658acdad9dc7a34e9708f3da63a50e6da140b1a9 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/ChatServerTest.java" @@ -0,0 +1,87 @@ +//package com.atguigu02.tcpudp.chat; + +import java.io.*; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.ArrayList; + +/** + * °¸Àý£ºÁÄÌìÊҵÄʵÏÖ £¨·þÎñÆ÷¶ˣ© + * + * @author Éйè¹È-Ëκ쿵 + * @create 16:45 + */ +public class ChatServerTest { + //Õâ¸ö¼¯ºÏÓÃÀ´´洢ËùÓÐÔÚÏߵĿͻ§¶Ë + static ArrayList online = new ArrayList(); + + public static void main(String[] args)throws Exception { + //1¡¢Æô¶¯·þÎñÆ÷£¬°󶨶˿ںÅ + ServerSocket server = new ServerSocket(8989); + + //2¡¢½ÓÊÕn¶àµĿͻ§¶ËͬʱÁ¬½Ó + while(true){ + Socket socket = server.accept(); //×èÈûʽµķ½·¨ + + online.add(socket);//°ÑÐÂÁ¬½ӵĿͻ§¶ËÌí¼ӵ½onlineÁбíÖÐ + + //Ö÷Ҫ¸ºÔð»ñȡµ±ǰsocketÖеÄÊý¾ݣ¬²¢·ַ¢¸øµ±ǰÁÄÌìÊҵÄËùÓеĿͻ§¶ˡ£ + MessageHandler mh = new MessageHandler(socket); + mh.start();// + } + } + + static class MessageHandler extends Thread{ + private Socket socket; + private String ip; + + public MessageHandler(Socket socket) { + super(); + this.socket = socket; + } + + public void run(){ + try { + ip = socket.getInetAddress().getHostAddress(); + + //²åÈ룺¸øÆäËû¿ͻ§¶Ëת·¢¡°ÎÒÉÏÏßÁˡ± + sendToOther(ip+"ÉÏÏßÁË"); + + //(1)½ÓÊոÿͻ§¶˵ķ¢Ë͵ÄÏûϢ + InputStream input = socket.getInputStream(); + InputStreamReader reader = new InputStreamReader(input); + BufferedReader br = new BufferedReader(reader); + + String str; + while((str = br.readLine())!=null){ + //(2)¸øÆäËûÔÚÏ߿ͻ§¶Ëת·¢ + sendToOther(ip+":"+str); + } + + sendToOther(ip+"ÏÂÏßÁË"); + } catch (IOException e) { + try { + sendToOther(ip+"µôÏßÁË"); + } catch (IOException e1) { + e1.printStackTrace(); + } + }finally{ + //´ÓÔÚÏßÈËԱÖÐÒƳýÎÒ + online.remove(socket); + } + } + + //·âװһ¸ö·½·¨£º¸øÆäËû¿ͻ§¶Ëת·¢xxxÏûϢ + public void sendToOther(String message) throws IOException{ + //±éÀúËùÓеÄÔÚÏ߿ͻ§¶ˣ¬һһת·¢ + for (Socket on : online) { + OutputStream every = on.getOutputStream(); + //ΪʲôÓÃPrintStream£¿ĿµÄÓÃËüµÄprintln·½·¨£¬°´Ðдòӡ + PrintStream ps = new PrintStream(every); + + ps.println(message); + } + } + } +} + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/apache-tomcat-8.5.15-windows-x64.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/apache-tomcat-8.5.15-windows-x64.zip" new file mode 100644 index 0000000000000000000000000000000000000000..4a68d14bad8dedb914b6a140bb0e0d750a185386 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/apache-tomcat-8.5.15-windows-x64.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76ee79ff3090b0ae0849a037078b5fac87bc5d2fd77f90e86c4e3f5b41b268b7 +size 11015137 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564019044385.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564019044385.png" new file mode 100644 index 0000000000000000000000000000000000000000..0841ed9732f017b97fbb272c742807d95464b24e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564019044385.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564020243342.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564020243342.png" new file mode 100644 index 0000000000000000000000000000000000000000..b42432883168bad26426b7c6d334b7876a53d48a Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564020243342.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564021582928.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564021582928.png" new file mode 100644 index 0000000000000000000000000000000000000000..e66ecc3defdddf74d4fdc92db18466a1ba3e0cdc Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564021582928.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564024137998.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564024137998.png" new file mode 100644 index 0000000000000000000000000000000000000000..c88005c666c96d8981dd3a8aabac88ecd43e6a2b Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564024137998.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564024229499.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564024229499.png" new file mode 100644 index 0000000000000000000000000000000000000000..17f7a5e6abd14cb434e551373bd87f9f049d9239 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564024229499.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564025942044.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564025942044.png" new file mode 100644 index 0000000000000000000000000000000000000000..03460fe2ed39483ab420d1089170c97030bc682f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564025942044.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564027041074.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564027041074.png" new file mode 100644 index 0000000000000000000000000000000000000000..12fb73159e0aca49eb53132bf0bd16c402861ffa Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1564027041074.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1_cs.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1_cs.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..61db3ba7a4a3a5a1205871b270b62e1ec5b344d5 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/1_cs.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/20220518_101503.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/20220518_101503.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..3a3d9e81f37d1aa6c69490b525da2100d6516f5d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/20220518_101503.jpg" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0799da9b5fb5151cedb9460a43d600a29ba5c4491422a867b37209398e04f043 +size 134447 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/20220518_101504.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/20220518_101504.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..6a84e0421d13d6488d377e3254be04807d4859e3 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/20220518_101504.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/2_bs.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/2_bs.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..dc307b8996d9fb5d97fc99ab18122f9e12ff8590 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/2_bs.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220131125934581.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220131125934581.png" new file mode 100644 index 0000000000000000000000000000000000000000..e3aa3f898d9bdfc9cdd38e071cf3e85ef1a9685a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220131125934581.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01d792dd35ac5f870483441522e2aa97191bcd062d990c2883336bacb58fb148 +size 272762 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220131144712460.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220131144712460.png" new file mode 100644 index 0000000000000000000000000000000000000000..3c4ef71564c2743b20c32506b2a3031de7e97dde Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220131144712460.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415001614195.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415001614195.png" new file mode 100644 index 0000000000000000000000000000000000000000..9bcaf6a7a5938cff2557ef9c3fe59f60d0d26b06 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415001614195.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:71850faa238e8ccf6f43db9ce2e5bce62a5876c4b3a0347507bb5ad78c956103 +size 1295528 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415002146129.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415002146129.png" new file mode 100644 index 0000000000000000000000000000000000000000..77558c70531455b065d558510a16f922ee8ac001 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415002146129.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415003729013.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415003729013.png" new file mode 100644 index 0000000000000000000000000000000000000000..9812adcf151534c7ca1598fc4b794e7beb833556 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415003729013.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9b92d9c660943a9d8010f4da2795268c3e93a3a2ba85440ff3cbf4d506c8b3d +size 235069 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415004400166.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415004400166.png" new file mode 100644 index 0000000000000000000000000000000000000000..891cc031265e0090a716e2612c6767b0ef94b05e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415004400166.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415010105484.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415010105484.png" new file mode 100644 index 0000000000000000000000000000000000000000..d97a2795699c887c0a7a78f8ed72ffd62de0fa95 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415010105484.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415010205891.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415010205891.png" new file mode 100644 index 0000000000000000000000000000000000000000..cb965732c5212422f0685c06fd3b2295254de3f2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415010205891.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:400301c7bed3572e2f38a2e699b2aa065c2cf6bf858ba8db26b8e2419fea7ce3 +size 117359 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415011744915.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415011744915.png" new file mode 100644 index 0000000000000000000000000000000000000000..9204c2d65216ca798d0d254d65e2143eccc4a19e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415011744915.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:424444c1655462bede5f0e4f50698fe5a6564166b42f833307a0dd91805a274f +size 264237 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415011844298.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415011844298.png" new file mode 100644 index 0000000000000000000000000000000000000000..3f9f790790b627bf027515e6eb2d126c0cf0743c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415011844298.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eba9fbf7ad9357ffa99fdfb8a94fc94d86444f07b4c2df23ba556eaa06d3fc21 +size 420869 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415013546074.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415013546074.png" new file mode 100644 index 0000000000000000000000000000000000000000..72d9fdbbf6c6ec251a9a9660aeeabed16b26f175 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220415013546074.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:62d9109033cd9d26f4e3c9a61fc8734ba541962856de52f0b7da0976a2d5be3c +size 101215 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220426174424602.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220426174424602.png" new file mode 100644 index 0000000000000000000000000000000000000000..514ad921e8b4ef47d5be55d26d5b18dce35210fc Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220426174424602.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220426180130832.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220426180130832.png" new file mode 100644 index 0000000000000000000000000000000000000000..99d873cde780c1770792929a3db0bb2fd4e62a1e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220426180130832.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503144420721.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503144420721.png" new file mode 100644 index 0000000000000000000000000000000000000000..b057c6685c9489477dad041c681454cdb78bca00 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503144420721.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:63856beab31a97fed4a6b886be69838f32c7d60e64fab2a1de70bd2153fe1f5a +size 700174 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503144450241.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503144450241.png" new file mode 100644 index 0000000000000000000000000000000000000000..d45faaa160d3aed675d15e072e69e8256d1d193f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503144450241.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1906faeedb52fe0569d8db4773fc5f676a8b5ef7c35e86a4342d40545f4a39b9 +size 558596 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503145929568.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503145929568.png" new file mode 100644 index 0000000000000000000000000000000000000000..1845e7f8f105876fc1ff0cfb64ba0ee05252af57 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503145929568.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503150300743.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503150300743.png" new file mode 100644 index 0000000000000000000000000000000000000000..fee5b2ad5f9ea5c29aa2f270cdc0a47aa8a24bb4 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220503150300743.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220512234904047.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220512234904047.png" new file mode 100644 index 0000000000000000000000000000000000000000..5200e6052967d2b8a31e9e43345021fca7f57e94 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220512234904047.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9cec4894b090d80af8c6866cc78dfd848da052e250dbfa8164ebc479631c8a5f +size 126140 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172130459.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172130459.png" new file mode 100644 index 0000000000000000000000000000000000000000..4160a4f58cce413608c2c7d2757a8913389eee3a Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172130459.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172435398.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172435398.png" new file mode 100644 index 0000000000000000000000000000000000000000..e62605e75b55e6a0b1c0149281327165cfbad367 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172435398.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172833216.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172833216.png" new file mode 100644 index 0000000000000000000000000000000000000000..0552194b8d3a338463a11088053c56dea2ffe084 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514172833216.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0d8e4fff7ee087e49178113407312530ec6773e361a768b9a4f8f781b4336728 +size 177261 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514173031651.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514173031651.png" new file mode 100644 index 0000000000000000000000000000000000000000..31b5f3cc4f0bf198d4238c7411fca5e333f6a4bd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/image-20220514173031651.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2020ce78a1baee5af972e075c3cf12fb3e9957143826e35b58b7d9d3aedb22f +size 113972 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25416\347\253\240.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25416\347\253\240.png" new file mode 100644 index 0000000000000000000000000000000000000000..e1868f0d597423939dbfe249a578168567a9e8fc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25416\347\253\240.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d61bac84c096cebc32cf42136566bbe3049ea28c107ce3c0d0ff734a0cd2251f +size 395218 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_Tomcat8.5\345\277\253\351\200\237\351\203\250\347\275\262.docx" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_Tomcat8.5\345\277\253\351\200\237\351\203\250\347\275\262.docx" new file mode 100644 index 0000000000000000000000000000000000000000..7c6a694ec3062334165683782b1b2720e73b6ccd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_Tomcat8.5\345\277\253\351\200\237\351\203\250\347\275\262.docx" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:985d4e92b380bdaa628a26ece9ff37dcab3a480197b14ea52324f14933802c59 +size 189000 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213.md" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213.md" new file mode 100644 index 0000000000000000000000000000000000000000..7eea63decad2196025b1e8f4081eabca71218fee --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213.md" @@ -0,0 +1,1133 @@ +# 第16章_网络编程 + +讲师:尚硅谷-宋红康(江湖人称:康师傅) + +官网:[http://www.atguigu.com](http://www.atguigu.com/) + +*** + +## 本章专题与脉络 + +第3阶段:Java高级应用-第16章 + +*** + +## 1. 网络编程概述 + +Java是 Internet 上的语言,它从语言级上提供了对网络应用程序的支持,程序员能够很容易开发常见的网络应用程序。 + +Java提供的网络类库,可以实现无痛的网络连接,联网的底层细节被隐藏在 Java 的本机安装系统里,由 JVM 进行控制。并且 Java 实现了一个跨平台的网络库,`程序员面对的是一个统一的网络编程环境`。 + +### 1.1 软件架构 + +- **C/S架构** :全称为Client/Server结构,是指客户端和服务器结构。常见程序有QQ、美团app、360安全卫士等软件。 + + + +**B/S架构** :全称为Browser/Server结构,是指浏览器和服务器结构。常见浏览器有IE、谷歌、火狐等。 + + + +两种架构各有优势,但是无论哪种架构,都离不开网络的支持。**网络编程**,就是在一定的协议下,实现两台计算机的通信的程序。 + +### 1.2 网络基础 + +- **计算机网络:** + 把分布在不同地理区域的计算机与专门的外部设备用通信线路互连成一个规模大、功能强的网络系统,从而使众多的计算机可以方便地互相传递信息、共享硬件、软件、数据信息等资源。 + +- **网络编程的目的:**直接或间接地通过网络协议与其它计算机实现数据交换,进行通讯。 + +- **网络编程中有三个主要的问题:** + - 问题1:如何准确地定位网络上一台或多台主机 + - 问题2:如何定位主机上的特定的应用 + - 问题3:找到主机后,如何可靠、高效地进行数据传输 + +image-20220415001614195 + +## 2. 网络通信要素 + +### 2.1 如何实现网络中的主机互相通信 + +- 通信双方地址 + - IP + - 端口号 +- 一定的规则:不同的硬件、操作系统之间的通信,所有的这一切都需要一种规则。而我们就把这种规则称为协议,即网络通信协议。 + +**生活类比:** + +image-20220503144420721 + +image-20220503144450241 + +### 2.2 通信要素一:IP地址和域名 + +#### 2.2.1 IP地址 + +**IP地址:指互联网协议地址(Internet Protocol Address)**,俗称IP。IP地址用来给网络中的一台计算机设备做唯一的编号。假如我们把“个人电脑”比作“一台电话”的话,那么“IP地址”就相当于“电话号码”。 + +**IP地址分类方式一:** + +- `IPv4`:是一个32位的二进制数,通常被分为4个字节,表示成`a.b.c.d` 的形式,以点分`十进制`表示,例如`192.168.65.100` 。其中a、b、c、d都是0~255之间的十进制整数。 + + - + + image-20220503145929568 + + - 这种方式最多可以表示42亿个。其中,30亿都在北美,亚洲4亿,中国2.9亿。2011年初已经用尽。 + + - IP地址 = 网络地址 +主机地址 + - 网络地址:标识计算机或网络设备所在的网段 + - 主机地址:标识特定主机或网络设备 + + ![20220518_101503](images/20220518_101503.jpg) + + 其中,E类用于科研。 + +- `IPv6`:由于互联网的蓬勃发展,IP地址的需求量愈来愈大,但是网络地址资源有限,使得IP的分配越发紧张。 + + 为了扩大地址空间,拟通过IPv6重新定义地址空间,采用128位地址长度,共16个字节,写成8个无符号整数,每个整数用四个十六进制位表示,数之间用冒号(:)分开。比如:`ABCD:EF01:2345:6789:ABCD:EF01:2345:6789`,按保守方法估算IPv6实际可分配的地址,整个地球的每平方米面积上仍可分配1000多个地址,这样就解决了网络地址资源数量不够的问题。2012年6月6日,国际互联网协会举行了世界IPv6启动纪念日,这一天,全球IPv6网络正式启动。多家知名网站,如Google、Facebook和Yahoo等,于当天全球标准时间0点(北京时间8点整)开始永久性支持IPv6访问。2018年6月,三大运营商联合阿里云宣布,将全面对外提供IPv6服务,并计划在2025年前助推中国互联网真正实现“IPv6 Only”。 + + 在IPv6的设计过程中除了一劳永逸地解决了地址短缺问题以外,还考虑了在IPv4中解决不好的其它问题,主要有端到端IP连接、服务质量(QoS)、安全性、多播、移动性、即插即用等。 + +**IP地址分类方式二:** + +公网地址( 万维网使用)和 私有地址( 局域网使用)。192.168.开头的就是私有地址,范围即为192.168.0.0--192.168.255.255,专门为组织机构内部使用。 + +**常用命令:** + +- 查看本机IP地址,在控制台输入: + +```java +ipconfig +``` + +- 检查网络是否连通,在控制台输入: + +```java +ping 空格 IP地址 +ping 220.181.57.216 +``` + +**特殊的IP地址:** + +- 本地回环地址(hostAddress):`127.0.0.1` +- 主机名(hostName):`localhost` + +#### 2.2.2 域名 + +Internet上的主机有两种方式表示地址: + +- 域名(hostName):www.atguigu.com +- IP 地址(hostAddress):202.108.35.210 + +**域名解析:**因为IP地址数字不便于记忆,因此出现了域名。域名容易记忆,当在连接网络时输入一个主机的域名后,域名服务器(DNS,Domain Name System,域名系统)负责将域名转化成IP地址,这样才能和主机建立连接。 + +简单理解: + +image-20220415003729013 + +详细理解: + +![image-20220131125934581](images/image-20220131125934581.png) + +1. 在浏览器中输入www . qq .com 域名,操作系统会先检查自己本地的`hosts文件`是否有这个网址映射关系,如果有,就先调用这个IP地址映射,完成域名解析。 +2. 如果hosts里没有这个域名的映射,则查找`本地DNS解析器缓存`,是否有这个网址映射关系,如果有,直接返回,完成域名解析。 +3. 如果hosts与本地DNS解析器缓存都没有相应的网址映射关系,首先会找TCP/IP参数中设置的首选DNS服务器,在此我们叫它`本地DNS服务器`,此服务器收到查询时,如果要查询的域名,包含在本地配置区域资源中,则返回解析结果给客户机,完成域名解析,此解析具有权威性。 +4. 如果要查询的域名,不由本地DNS服务器区域解析,但该服务器已`缓存`了此网址映射关系,则调用这个IP地址映射,完成域名解析,此解析不具有权威性。 +5. 如果本地DNS服务器本地区域文件与缓存解析都失效,则根据本地DNS服务器的设置(是否设置转发器)进行查询,如果未用转发模式,本地DNS就把请求发至13台根DNS,根DNS服务器收到请求后会判断这个域名(.com)是谁来授权管理,并会返回一个负责该顶级域名服务器的一个IP。本地DNS服务器收到IP信息后,将会联系负责.com域的这台服务器。这台负责.com域的服务器收到请求后,如果自己无法解析,它就会找一个管理.com域的下一级DNS服务器地址(http://qq.com)给本地DNS服务器。当本地DNS服务器收到这个地址后,就会找(http://qq.com)域服务器,重复上面的动作,进行查询,直至找到www.qq.com主机。 +6. 如果用的是转发模式,此DNS服务器就会把请求转发至上一级DNS服务器,由上一级服务器进行解析,上一级服务器如果不能解析,或找根DNS或把转请求转至上上级,以此循环。不管是本地DNS服务器用是是转发,还是根提示,最后都是把结果返回给本地DNS服务器,由此DNS服务器再返回给客户机。 + +### 2.3 通信要素二:端口号 + +网络的通信,本质上是两个进程(应用程序)的通信。每台计算机都有很多的进程,那么在网络通信时,如何区分这些进程呢? + +如果说**IP地址**可以唯一标识网络中的设备,那么**端口号**就可以唯一标识设备中的进程(应用程序)。 + +不同的进程,设置不同的端口号。 + +- **端口号:用两个字节表示的整数,它的取值范围是0~65535**。 + - 公认端口:0~1023。被预先定义的服务通信占用,如:HTTP(80),FTP(21),Telnet(23) + - 注册端口:1024~49151。分配给用户进程或应用程序。如:Tomcat(8080),MySQL(3306),Oracle(1521)。 + - 动态/ 私有端口:49152~65535。 + +如果端口号被另外一个服务或应用所占用,会导致当前程序启动失败。 + +image-20220415004400166 + +### 2.4 通信要素三:网络通信协议 + +通过计算机网络可以使多台计算机实现连接,位于同一个网络中的计算机在进行连接和通信时需要遵守一定的规则,这就好比在道路中行驶的汽车一定要遵守交通规则一样。 + +- `网络通信协议`:在计算机网络中,这些连接和通信的规则被称为网络通信协议,它对数据的传输格式、传输速率、传输步骤、出错控制等做了统一规定,通信双方必须同时遵守才能完成数据交换。 + +**新的问题:网络协议涉及内容太多、太复杂。如何解决?** + +计算机网络通信涉及内容很多,比如指定源地址和目标地址,加密解密,压缩解压缩,差错控制,流量控制,路由控制,如何实现如此复杂的网络协议呢?`通信协议分层思想`。 + +在制定协议时,把复杂成份分解成一些简单的成份,再将它们复合起来。最常用的复合方式是层次方式,即`同层间可以通信、上一层可以调用下一层,而与再下一层不发生关系`。各层互不影响,利于系统的开发和扩展。 + +这里有两套参考模型 + +- OSI参考模型:模型过于理想化,未能在因特网上进行广泛推广 +- TCP/IP参考模型(或TCP/IP协议):事实上的国际标准。 + +![image-20220514172130459](images/image-20220514172130459.png) + +上图中,OSI参考模型:模型`过于理想化`,未能在因特网上进行广泛推广。 TCP/IP参考模型(或TCP/IP协议):事实上的`国际标准`。 + +- **TCP/IP协议:** 传输控制协议/因特网互联协议( Transmission Control Protocol/Internet Protocol),TCP/IP 以其两个主要协议:传输控制协议(TCP)和网络互联协议(IP)而得名,实际上是一组协议,包括多个具有不同功能且互为关联的协议。是Internet最基本、最广泛的协议。 + + image-20220512234904047 + +**TCP/IP协议中的四层介绍:** + +- `应用层`:应用层决定了向用户提供应用服务时通信的活动。主要协议有:HTTP协议、FTP协议、SNMP(简单网络管理协议)、SMTP(简单邮件传输协议)和POP3(Post Office Protocol 3的简称,即邮局协议的第3个版)等。 +- `传输层`:主要使网络程序进行通信,在进行网络通信时,可以采用TCP协议,也可以采用UDP协议。TCP(Transmission Control Protocol)协议,即传输控制协议,是一种面向连接的、可靠的、基于字节流的传输层通信协议。UDP(User Datagram Protocol,用户数据报协议):是一个无连接的传输层协议、提供面向事务的简单不可靠的信息传送服务。 +- `网络层`:网络层是整个TCP/IP协议的核心,支持网间互连的数据通信。它主要用于将传输的数据进行分组,将分组数据发送到目标计算机或者网络。而IP协议是一种非常重要的协议。IP(internet protocal)又称为互联网协议。IP的责任就是把数据从源传送到目的地。它在源地址和目的地址之间传送一种称之为数据包的东西,它还提供对数据大小的重新组装功能,以适应不同网络对包大小的要求。 + +* `物理+数据链路层`:链路层是用于定义物理传输通道,通常是对某些网络连接设备的驱动协议,例如针对光纤、网线提供的驱动。 + +![image-20220514172435398](images/image-20220514172435398.png) + +## 2. 谈传输层协议:TCP与UDP协议 + +通信的协议还是比较复杂的,`java.net` 包中包含的类和接口,它们提供低层次的通信细节。我们可以直接使用这些类和接口,来专注于网络程序开发,而不用考虑通信的细节。 + +`java.net` 包中提供了两种常见的网络协议的支持: + +- **UDP**:用户数据报协议(User Datagram Protocol)。 +- **TCP**:传输控制协议 (Transmission Control Protocol)。 + +### 2.1 TCP协议与UDP协议 + +**TCP协议:** + +- TCP协议进行通信的两个应用进程:客户端、服务端。 +- 使用TCP协议前,须先`建立TCP连接`,形成基于字节流的传输数据通道 +- 传输前,采用“三次握手”方式,点对点通信,是`可靠的` + - TCP协议使用`重发机制`,当一个通信实体发送一个消息给另一个通信实体后,需要收到另一个通信实体确认信息,如果没有收到另一个通信实体确认信息,则会再次重复刚才发送的消息。 +- 在连接中可进行`大数据量的传输` +- 传输完毕,需`释放已建立的连接,效率低` + +**UDP协议:** + +- UDP协议进行通信的两个应用进程:发送端、接收端。 +- 将数据、源、目的封装成数据包(传输的基本单位),`不需要建立连接` +- 发送不管对方是否准备好,接收方收到也不确认,不能保证数据的完整性,故是`不可靠的` +- 每个数据报的大小限制在`64K`内 +- 发送数据结束时`无需释放资源,开销小,通信效率高` +- 适用场景:音频、视频和普通数据的传输。例如视频会议 + +> TCP生活案例:打电话 +> +> UDP生活案例:发送短信、发电报 + +### 2.2 三次握手 + +TCP协议中,在发送数据的准备阶段,客户端与服务器之间的三次交互,以保证连接的可靠。 + +- 第一次握手,客户端向服务器端发起TCP连接的请求 +- 第二次握手,服务器端发送针对客户端TCP连接请求的确认 +- 第三次握手,客户端发送确认的确认 + +image-20220415010105484 + +> 1、客户端会随机一个初始序列号seq=x,设置SYN=1 ,表示这是SYN握手报文。然后就可以把这个 SYN 报文发送给服务端了,表示向服务端发起连接,之后客户端处于`同步已发送`状态。 +> +> 2、服务端收到客户端的 SYN 报文后,也随机一个初始序列号(seq=y),设置ack=x+1,表示收到了客户端的x之前的数据,希望客户端下次发送的数据从x+1开始。 +> 设置 SYN=1 和 ACK=1。表示这是一个SYN握手和ACK确认应答报文。最后把该报文发给客户端,该报文也不包含应用层数据,之后服务端处于`同步已接收`状态。 +> +> 3、客户端收到服务端报文后,还要向服务端回应最后一个应答报文,将ACK置为 1 ,表示这是一个应答报文 +> ack=y+1 ,表示收到了服务器的y之前的数据,希望服务器下次发送的数据从y+1开始。 +> 最后把报文发送给服务端,这次报文可以携带数据,之后客户端处于 连接已建立 状态。服务器收到客户端的应答报文后,也进入`连接已建立`状态。 + +完成三次握手,连接建立后,客户端和服务器就可以开始进行数据传输了。由于这种面向连接的特性,TCP协议可以保证传输数据的安全,所以应用十分广泛,例如下载文件、浏览网页等。 + +### 2.3 四次挥手 + +TCP协议中,在发送数据结束后,释放连接时需要经过四次挥手。 + +* 第一次挥手:客户端向服务器端提出结束连接,`让服务器做最后的准备工作`。此时,客户端处于半关闭状态,即表示不再向服务器发送数据了,但是还可以接受数据。 +* 第二次挥手:服务器接收到客户端释放连接的请求后,`会将最后的数据发给客户端`。并告知上层的应用进程不再接收数据。 +* 第三次挥手:服务器发送完数据后,会给客户端`发送一个释放连接的报文`。那么客户端接收后就知道可以正式释放连接了。 +* 第四次挥手:客户端接收到服务器最后的释放连接报文后,要`回复一个彻底断开的报文`。这样服务器收到后才会彻底释放连接。这里客户端,发送完最后的报文后,会等待2MSL,因为有可能服务器没有收到最后的报文,那么服务器迟迟没收到,就会再次给客户端发送释放连接的报文,此时客户端在等待时间范围内接收到,会重新发送最后的报文,并重新计时。如果等待2MSL后,没有收到,那么彻底断开。 + +image-20220415010205891 + +> 1、客户端打算断开连接,向服务器发送FIN报文(FIN标记位被设置为1,1表示为FIN,0表示不是),FIN报文中会指定一个序列号,之后客户端进入FIN_WAIT_1状态。也就是客户端发出连接释放报文段(FIN报文),指定序列号seq = u,主动关闭TCP连接,等待服务器的确认。 +> +> 2、服务器收到连接释放报文段(FIN报文)后,就向客户端发送ACK应答报文,以客户端的FIN报文的序列号 seq+1 作为ACK应答报文段的确认序列号ack = seq+1 = u + 1。接着服务器进入CLOSE_WAIT(等待关闭)状态,此时的TCP处于半关闭状态(下面会说什么是半关闭状态),客户端到服务器的连接释放。客户端收到来自服务器的ACK应答报文段后,进入FIN_WAIT_2状态。 +> +> 3、服务器也打算断开连接,向客户端发送连接释放(FIN)报文段,之后服务器进入LASK_ACK(最后确认)状态,等待客户端的确认。服务器的连接释放(FIN)报文段的FIN=1,ACK=1,序列号seq=m,确认序列号ack=u+1。 +> +> 4、客户端收到来自服务器的连接释放(FIN)报文段后,会向服务器发送一个ACK应答报文段,以连接释放(FIN)报文段的确认序号 ack 作为ACK应答报文段的序列号 seq,以连接释放(FIN)报文段的序列号 seq+1作为确认序号ack。 +> +> 之后客户端进入TIME_WAIT(时间等待)状态,服务器收到ACK应答报文段后,服务器就进入CLOSE(关闭)状态,到此服务器的连接已经完成关闭。客户端处于TIME_WAIT状态时,此时的TCP还未释放掉,需要等待2MSL后,客户端才进入CLOSE状态。 +> + +## 3. 网络编程API + +### 3.1 InetAddress类 + +InetAddress类主要表示IP地址,两个子类:Inet4Address、Inet6Address。 + +InetAddress 类没有提供公共的构造器,而是提供 了 如下几个 静态方法来获取InetAddress 实例 + +* public static InetAddress getLocalHost() +* public static InetAddress getByName(String host) +* public static InetAddress getByAddress(byte[] addr) + +InetAddress 提供了如下几个常用的方法 + +* public String getHostAddress() :返回 IP 地址字符串(以文本表现形式) +* public String getHostName() :获取此 IP 地址的主机名 +* public boolean isReachable(int timeout):测试是否可以达到该地址 + +```java +package com.atguigu.ip; + +import java.net.InetAddress; +import java.net.UnknownHostException; + +import org.junit.Test; + +public class TestInetAddress { + @Test + public void test01() throws UnknownHostException{ + InetAddress localHost = InetAddress.getLocalHost(); + System.out.println(localHost); + } + + @Test + public void test02()throws UnknownHostException{ + InetAddress atguigu = InetAddress.getByName("www.atguigu.com"); + System.out.println(atguigu); + } + + @Test + public void test03()throws UnknownHostException{ +// byte[] addr = {112,54,108,98}; + byte[] addr = {(byte)192,(byte)168,24,56}; + InetAddress atguigu = InetAddress.getByAddress(addr); + System.out.println(atguigu); + } +} +``` + +![1564024137998](images/1564024137998.png) + +### 3.2 Socket类 + +- 网络上具有唯一标识的IP地址和端口号组合在一起构成唯一能识别的标识符套接字(Socket)。 +- 利用套接字(Socket)开发网络应用程序早已被广泛的采用,以至于成为事实上的标准。网络通信其实就是Socket间的通信。 + + +- 通信的两端都要有Socket,是两台机器间通信的端点。 + +- Socket允许程序把网络连接当成一个流,数据在两个Socket间通过IO传输。 + +- 一般主动发起通信的应用程序属客户端,等待通信请求的为服务端。 + +- Socket分类: + - 流套接字(stream socket):使用TCP提供可依赖的字节流服务 + - ServerSocket:此类实现TCP服务器套接字。服务器套接字等待请求通过网络传入。 + - Socket:此类实现客户端套接字(也可以就叫“套接字”)。套接字是两台机器间通信的端点。 + - 数据报套接字(datagram socket):使用UDP提供“尽力而为”的数据报服务 + - DatagramSocket:此类表示用来发送和接收UDP数据报包的套接字。 + +### 3.3 Socket相关类API + +#### 3.3.1 ServerSocket类 + +**ServerSocket类的构造方法:** + +* ServerSocket(int port) :创建绑定到特定端口的服务器套接字。 + +**ServerSocket类的常用方法:** + +* Socket accept():侦听并接受到此套接字的连接。 + +#### 3.3.2 Socket类 + +**Socket类的常用构造方法**: + +* public Socket(InetAddress address,int port):创建一个流套接字并将其连接到指定 IP 地址的指定端口号。 +* public Socket(String host,int port):创建一个流套接字并将其连接到指定主机上的指定端口号。 + +**Socket类的常用方法**: + +* public InputStream getInputStream():返回此套接字的输入流,可以用于接收消息 +* public OutputStream getOutputStream():返回此套接字的输出流,可以用于发送消息 +* public InetAddress getInetAddress():此套接字连接到的远程 IP 地址;如果套接字是未连接的,则返回 null。 +* public InetAddress getLocalAddress():获取套接字绑定的本地地址。 +* public int getPort():此套接字连接到的远程端口号;如果尚未连接套接字,则返回 0。 +* public int getLocalPort():返回此套接字绑定到的本地端口。如果尚未绑定套接字,则返回 -1。 +* public void close():关闭此套接字。套接字被关闭后,便不可在以后的网络连接中使用(即无法重新连接或重新绑定)。需要创建新的套接字对象。 关闭此套接字也将会关闭该套接字的 InputStream 和 OutputStream。 +* public void shutdownInput():如果在套接字上调用 shutdownInput() 后从套接字输入流读取内容,则流将返回 EOF(文件结束符)。 即不能在从此套接字的输入流中接收任何数据。 +* public void shutdownOutput():禁用此套接字的输出流。对于 TCP 套接字,任何以前写入的数据都将被发送,并且后跟 TCP 的正常连接终止序列。 如果在套接字上调用 shutdownOutput() 后写入套接字输出流,则该流将抛出 IOException。 即不能通过此套接字的输出流发送任何数据。 + +**注意:**先后调用Socket的shutdownInput()和shutdownOutput()方法,仅仅关闭了输入流和输出流,并不等于调用Socket的close()方法。在通信结束后,仍然要调用Scoket的close()方法,因为只有该方法才会释放Socket占用的资源,比如占用的本地端口号等。 + +#### 3.3.3 DatagramSocket类 + +**DatagramSocket 类的常用方法:** + +* public DatagramSocket(int port)创建数据报套接字并将其绑定到本地主机上的指定端口。套接字将被绑定到通配符地址,IP 地址由内核来选择。 +* public DatagramSocket(int port,InetAddress laddr)创建数据报套接字,将其绑定到指定的本地地址。本地端口必须在 0 到 65535 之间(包括两者)。如果 IP 地址为 0.0.0.0,套接字将被绑定到通配符地址,IP 地址由内核选择。 +* public void close()关闭此数据报套接字。 +* public void send(DatagramPacket p)从此套接字发送数据报包。DatagramPacket 包含的信息指示:将要发送的数据、其长度、远程主机的 IP 地址和远程主机的端口号。 +* public void receive(DatagramPacket p)从此套接字接收数据报包。当此方法返回时,DatagramPacket 的缓冲区填充了接收的数据。数据报包也包含发送方的 IP 地址和发送方机器上的端口号。 此方法在接收到数据报前一直阻塞。数据报包对象的 length 字段包含所接收信息的长度。如果信息比包的长度长,该信息将被截短。 +* public InetAddress getLocalAddress()获取套接字绑定的本地地址。 +* public int getLocalPort()返回此套接字绑定的本地主机上的端口号。 +* public InetAddress getInetAddress()返回此套接字连接的地址。如果套接字未连接,则返回 null。 +* public int getPort()返回此套接字的端口。如果套接字未连接,则返回 -1。 + +#### 3.3.4 DatagramPacket类 + +**DatagramPacket类的常用方法:** + +* public DatagramPacket(byte[] buf,int length)构造 DatagramPacket,用来接收长度为 length 的数据包。 length 参数必须小于等于 buf.length。 +* public DatagramPacket(byte[] buf,int length,InetAddress address,int port)构造数据报包,用来将长度为 length 的包发送到指定主机上的指定端口号。length 参数必须小于等于 buf.length。 +* public InetAddress getAddress()返回某台机器的 IP 地址,此数据报将要发往该机器或者是从该机器接收到的。 +* public int getPort()返回某台远程主机的端口号,此数据报将要发往该主机或者是从该主机接收到的。 +* `public byte[] getData()`返回数据缓冲区。接收到的或将要发送的数据从缓冲区中的偏移量 offset 处开始,持续 length 长度。 +* `public int getLength()`返回将要发送或接收到的数据的长度。 + +## 4. TCP网络编程 + +### 4.1 通信模型 + +Java语言的基于套接字TCP编程分为服务端编程和客户端编程,其通信模型如图所示: + +image-20220514172833216 + +### 4.2 开发步骤 + +**客户端程序包含以下四个基本的步骤 :** + +* 创建 Socket :根据指定服务端的 IP 地址或端口号构造 Socket 类对象。若服务器端响应,则建立客户端到服务器的通信线路。若连接失败,会出现异常。 +* 打开连接到 Socket 的输入/ 出流: 使用 getInputStream()方法获得输入流,使用getOutputStream()方法获得输出流,进行数据传输 +* 按照一定的协议对 Socket 进行读/ 写操作:通过输入流读取服务器放入线路的信息(但不能读取自己放入线路的信息),通过输出流将信息写入线路。 +* 关闭 Socket :断开客户端到服务器的连接,释放线路 + +**服务器端程序包含以下四个基本的 步骤:** + +* 调用 ServerSocket(int port) :创建一个服务器端套接字,并绑定到指定端口上。用于监听客户端的请求。 +* 调用 accept() :监听连接请求,如果客户端请求连接,则接受连接,返回通信套接字对象。 +* 调用 该Socket 类对象的 getOutputStream() 和 getInputStream () :获取输出流和输入流,开始网络数据的发送和接收。 +* 关闭Socket 对象:客户端访问结束,关闭通信套接字。 + +### 4.3 例题与练习 + +> 例题1:客户端发送内容给服务端,服务端将内容打印到控制台上。 +> +> 例题2:客户端发送文件给服务端,服务端将文件保存在本地。 +> +> 例题3:从客户端发送文件给服务端,服务端保存到本地。并返回“发送成功”给客户端。并关闭相应的连接。 +> + +练习1:服务端读取图片并发送给客户端,客户端保存图片到本地 + +练习2:客户端给服务端发送文本,服务端会将文本转成大写在返回给客户端。 + +**演示单个客户端与服务器单次通信:** + +需求:客户端连接服务器,连接成功后给服务发送“lalala”,服务器收到消息后,给客户端返回“欢迎登录”,客户端接收消息后,断开连接 + +**1、服务器端示例代码** + +```java +package com.atguigu.tcp.one; + +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.ServerSocket; +import java.net.Socket; + +public class Server { + + public static void main(String[] args)throws Exception { + //1、准备一个ServerSocket对象,并绑定8888端口 + ServerSocket server = new ServerSocket(8888); + System.out.println("等待连接...."); + + //2、在8888端口监听客户端的连接,该方法是个阻塞的方法,如果没有客户端连接,将一直等待 + Socket socket = server.accept(); + InetAddress inetAddress = socket.getInetAddress(); + System.out.println(inetAddress.getHostAddress() + "客户端连接成功!!"); + + //3、获取输入流,用来接收该客户端发送给服务器的数据 + InputStream input = socket.getInputStream(); + //接收数据 + byte[] data = new byte[1024]; + StringBuilder s = new StringBuilder(); + int len; + while ((len = input.read(data)) != -1) { + s.append(new String(data, 0, len)); + } + System.out.println(inetAddress.getHostAddress() + "客户端发送的消息是:" + s); + + //4、获取输出流,用来发送数据给该客户端 + OutputStream out = socket.getOutputStream(); + //发送数据 + out.write("欢迎登录".getBytes()); + out.flush(); + + //5、关闭socket,不再与该客户端通信 + //socket关闭,意味着InputStream和OutputStream也关闭了 + socket.close(); + + //6、如果不再接收任何客户端通信,可以关闭ServerSocket + server.close(); + } +} + +``` + +**2、客户端示例代码** + +```java +package com.atguigu.tcp.one; + +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; + +public class Client { + + public static void main(String[] args) throws Exception { + // 1、准备Socket,连接服务器,需要指定服务器的IP地址和端口号 + Socket socket = new Socket("127.0.0.1", 8888); + + // 2、获取输出流,用来发送数据给服务器 + OutputStream out = socket.getOutputStream(); + // 发送数据 + out.write("lalala".getBytes()); + //会在流末尾写入一个“流的末尾”标记,对方才能读到-1,否则对方的读取方法会一致阻塞 + socket.shutdownOutput(); + + //3、获取输入流,用来接收服务器发送给该客户端的数据 + InputStream input = socket.getInputStream(); + // 接收数据 + byte[] data = new byte[1024]; + StringBuilder s = new StringBuilder(); + int len; + while ((len = input.read(data)) != -1) { + s.append(new String(data, 0, len)); + } + System.out.println("服务器返回的消息是:" + s); + + //4、关闭socket,不再与服务器通信,即断开与服务器的连接 + //socket关闭,意味着InputStream和OutputStream也关闭了 + socket.close(); + } +} + +``` + + + +**演示多个客户端与服务器之间的多次通信:** + +通常情况下,服务器不应该只接受一个客户端请求,而应该不断地接受来自客户端的所有请求,所以Java程序通常会通过循环,不断地调用ServerSocket的accept()方法。 + +如果服务器端要“同时”处理多个客户端的请求,因此服务器端需要为**每一个客户端单独分配一个线程**来处理,否则无法实现“同时”。 + +咱们之前学习IO流的时候,提到过装饰者设计模式,该设计使得不管底层IO流是怎样的节点流:文件流也好,网络Socket产生的流也好,程序都可以将其包装成处理流,甚至可以多层包装,从而提供更多方便的处理。 + +案例需求:多个客户端连接服务器,并进行多次通信 + +* 每一个客户端连接成功后,从键盘输入英文单词或中国成语,并发送给服务器 +* 服务器收到客户端的消息后,把词语“反转”后返回给客户端 +* 客户端接收服务器返回的“词语”,打印显示 +* 当客户端输入“stop”时断开与服务器的连接 +* 多个客户端可以同时给服务器发送“词语”,服务器可以“同时”处理多个客户端的请求 + +image-20220514173031651 + +**1、服务器端示例代码** + +```java +package com.atguigu.tcp.many; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.net.ServerSocket; +import java.net.Socket; + +public class Server { + public static void main(String[] args) throws IOException { + // 1、准备一个ServerSocket + ServerSocket server = new ServerSocket(8888); + System.out.println("等待连接..."); + + int count = 0; + while(true){ + // 2、监听一个客户端的连接 + Socket socket = server.accept(); + System.out.println("第" + ++count + "个客户端"+socket.getInetAddress().getHostAddress()+"连接成功!!"); + + ClientHandlerThread ct = new ClientHandlerThread(socket); + ct.start(); + } + + //这里没有关闭server,永远监听 + } + static class ClientHandlerThread extends Thread{ + private Socket socket; + private String ip; + + public ClientHandlerThread(Socket socket) { + super(); + this.socket = socket; + ip = socket.getInetAddress().getHostAddress(); + } + + public void run(){ + try{ + //(1)获取输入流,用来接收该客户端发送给服务器的数据 + BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); + //(2)获取输出流,用来发送数据给该客户端 + PrintStream ps = new PrintStream(socket.getOutputStream()); + String str; + // (3)接收数据 + while ((str = br.readLine()) != null) { + //(4)反转 + StringBuilder word = new StringBuilder(str); + word.reverse(); + + //(5)返回给客户端 + ps.println(word); + } + System.out.println("客户端" + ip+"正常退出"); + }catch(Exception e){ + System.out.println("客户端" + ip+"意外退出"); + }finally{ + try { + //(6)断开连接 + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } +} + +``` + +**2、客户端示例代码** + +```java +package com.atguigu.tcp.many; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.Socket; +import java.util.Scanner; + +public class Client { + public static void main(String[] args) throws Exception { + // 1、准备Socket,连接服务器,需要指定服务器的IP地址和端口号 + Socket socket = new Socket("127.0.0.1", 8888); + + // 2、获取输出流,用来发送数据给服务器 + OutputStream out = socket.getOutputStream(); + PrintStream ps = new PrintStream(out); + + // 3、获取输入流,用来接收服务器发送给该客户端的数据 + InputStream input = socket.getInputStream(); + BufferedReader br; + if(args!= null && args.length>0) { + String encoding = args[0]; + br = new BufferedReader(new InputStreamReader(input,encoding)); + }else{ + br = new BufferedReader(new InputStreamReader(input)); + } + + Scanner scanner = new Scanner(System.in); + while(true){ + System.out.println("输入发送给服务器的单词或成语:"); + String message = scanner.nextLine(); + if(message.equals("stop")){ + socket.shutdownOutput(); + break; + } + + // 4、 发送数据 + ps.println(message); + // 接收数据 + String feedback = br.readLine(); + System.out.println("从服务器收到的反馈是:" + feedback); + } + + //5、关闭socket,断开与服务器的连接 + scanner.close(); + socket.close(); + } +} +``` + +### 4.4 案例:聊天室 + +服务端: + +```java +package com.atguigu.tcp; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.ArrayList; + +public class TestChatServer { + //这个集合用来存储所有在线的客户端 + static ArrayList online = new ArrayList(); + + public static void main(String[] args)throws Exception { + //1、启动服务器,绑定端口号 + ServerSocket server = new ServerSocket(8989); + + //2、接收n多的客户端同时连接 + while(true){ + Socket accept = server.accept(); + + online.add(accept);//把新连接的客户端添加到online列表中 + + MessageHandler mh = new MessageHandler(accept); + mh.start();// + } + } + + static class MessageHandler extends Thread{ + private Socket socket; + private String ip; + + public MessageHandler(Socket socket) { + super(); + this.socket = socket; + } + + public void run(){ + try { + ip = socket.getInetAddress().getHostAddress(); + + //插入:给其他客户端转发“我上线了” + sendToOther(ip+"上线了"); + + //(1)接收该客户端的发送的消息 + InputStream input = socket.getInputStream(); + InputStreamReader reader = new InputStreamReader(input); + BufferedReader br = new BufferedReader(reader); + + String str; + while((str = br.readLine())!=null){ + //(2)给其他在线客户端转发 + sendToOther(ip+":"+str); + } + + sendToOther(ip+"下线了"); + } catch (IOException e) { + try { + sendToOther(ip+"掉线了"); + } catch (IOException e1) { + e1.printStackTrace(); + } + }finally{ + //从在线人员中移除我 + online.remove(socket); + } + } + + //封装一个方法:给其他客户端转发xxx消息 + public void sendToOther(String message) throws IOException{ + //遍历所有的在线客户端,一一转发 + for (Socket on : online) { + OutputStream every = on.getOutputStream(); + //为什么用PrintStream?目的用它的println方法,按行打印 + PrintStream ps = new PrintStream(every); + + ps.println(message); + } + } + } +} + + +``` + +客户端: + +```java +package com.atguigu.tcp; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintStream; +import java.net.Socket; +import java.util.Scanner; + +public class TestChatClient { + public static void main(String[] args)throws Exception { + //1、连接服务器 + Socket socket = new Socket("127.0.0.1",8989); + + //2、开启两个线程 + //(1)一个线程负责看别人聊,即接收服务器转发的消息 + Receive receive = new Receive(socket); + receive.start(); + + //(2)一个线程负责发送自己的话 + Send send = new Send(socket); + send.start(); + + send.join();//等我发送线程结束了,才结束整个程序 + + socket.close(); + } +} +class Send extends Thread{ + private Socket socket; + + public Send(Socket socket) { + super(); + this.socket = socket; + } + + public void run(){ + try { + OutputStream outputStream = socket.getOutputStream(); + //按行打印 + PrintStream ps = new PrintStream(outputStream); + + Scanner input = new Scanner(System.in); + + //从键盘不断的输入自己的话,给服务器发送,由服务器给其他人转发 + while(true){ + System.out.print("自己的话:"); + String str = input.nextLine(); + if("bye".equals(str)){ + break; + } + ps.println(str); + } + + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} +class Receive extends Thread{ + private Socket socket; + + public Receive(Socket socket) { + super(); + this.socket = socket; + } + + public void run(){ + try { + InputStream inputStream = socket.getInputStream(); + Scanner input = new Scanner(inputStream); + + while(input.hasNextLine()){ + String line = input.nextLine(); + System.out.println(line); + } + } catch (IOException e) { + e.printStackTrace(); + } + } +} +``` + + + +### 4.5 理解客户端、服务端 + +- 客户端: + - 自定义 + - 浏览器(browser --- server) + +- 服务端: + - 自定义 + - Tomcat服务器 + +## 5. UDP网络编程 + +UDP(User Datagram Protocol,用户数据报协议):是一个无连接的传输层协议、提供面向事务的简单不可靠的信息传送服务,类似于短信。 + +### 5.1 通信模型 + +UDP协议是一种**面向非连接**的协议,面向非连接指的是在正式通信前不必与对方先建立连接,不管对方状态就直接发送,至于对方是否可以接收到这些数据内容,UDP协议无法控制,因此说,UDP协议是一种**不可靠的**协议。无连接的好处就是快,省内存空间和流量,因为维护连接需要创建大量的数据结构。UDP会尽最大努力交付数据,但不保证可靠交付,没有TCP的确认机制、重传机制,如果因为网络原因没有传送到对端,UDP也不会给应用层返回错误信息。 + +UDP协议是面向数据报文的信息传送服务。UDP在发送端没有缓冲区,对于应用层交付下来的报文在添加了首部之后就直接交付于ip层,不会进行合并,也不会进行拆分,而是一次交付一个完整的报文。比如我们要发送100个字节的报文,我们调用一次send()方法就会发送100字节,接收方也需要用receive()方法一次性接收100字节,不能使用循环每次获取10个字节,获取十次这样的做法。 + +UDP协议没有拥塞控制,所以当网络出现的拥塞不会导致主机发送数据的速率降低。虽然UDP的接收端有缓冲区,但是这个缓冲区只负责接收,并不会保证UDP报文的到达顺序是否和发送的顺序一致。因为网络传输的时候,由于网络拥塞的存在是很大的可能导致先发的报文比后发的报文晚到达。如果此时缓冲区满了,后面到达的报文将直接被丢弃。这个对实时应用来说很重要,比如:视频通话、直播等应用。 + +因此UDP适用于一次只传送少量数据、对可靠性要求不高的应用环境,数据报大小限制在64K以下。 + +![image-20220131144712460](images/image-20220131144712460.png) + +类 DatagramSocket 和 DatagramPacket 实现了基于 UDP 协议网络程序。 + + UDP数据报通过数据报套接字 DatagramSocket 发送和接收,系统不保证 UDP数据报一定能够安全送到目的地,也不能确定什么时候可以抵达。 + + DatagramPacket 对象封装了UDP数据报,在数据报中包含了发送端的IP地址和端口号以及接收端的IP地址和端口号。 + + UDP协议中每个数据报都给出了完整的地址信息,因此无须建立发送方和接收方的连接。如同发快递包裹一样。 + +### 5.2 开发步骤 + +**发送端程序包含以下四个基本的步骤:** + +* 创建DatagramSocket :默认使用系统随机分配端口号。 +* 创建DatagramPacket:将要发送的数据用字节数组表示,并指定要发送的数据长度,接收方的IP地址和端口号。 +* 调用 该DatagramSocket 类对象的 send方法 :发送数据报DatagramPacket对象。 +* 关闭DatagramSocket 对象:发送端程序结束,关闭通信套接字。 + +**接收端程序包含以下四个基本的步骤 :** + +* 创建DatagramSocket :指定监听的端口号。 +* 创建DatagramPacket:指定接收数据用的字节数组,起到临时数据缓冲区的效果,并指定最大可以接收的数据长度。 +* 调用 该DatagramSocket 类对象的receive方法 :接收数据报DatagramPacket对象。。 +* 关闭DatagramSocket :接收端程序结束,关闭通信套接字。 + +### 5.3 演示发送和接收消息 + +基于UDP协议的网络编程仍然需要在通信实例的两端各建立一个Socket,但这两个Socket之间并没有虚拟链路,这两个Socket只是发送、接收数据报的对象,Java提供了DatagramSocket对象作为基于UDP协议的Socket,使用DatagramPacket代表DatagramSocket发送、接收的数据报。 + +#### 举例1: + +发送端: + +```java +DatagramSocket ds = null; +try { + ds = new DatagramSocket(); + byte[] by = "hello,atguigu.com".getBytes(); + DatagramPacket dp = new DatagramPacket(by, 0, by.length, InetAddress.getByName("127.0.0.1"), 10000); + ds.send(dp); +} catch (Exception e) { + e.printStackTrace(); +} finally { + if (ds != null) + ds.close(); +} + +``` + +接收端: + +```java +DatagramSocket ds = null; +try { + ds = new DatagramSocket(10000); + byte[] by = new byte[1024*64]; + DatagramPacket dp = new DatagramPacket(by, by.length); + ds.receive(dp); + String str = new String(dp.getData(), 0, dp.getLength()); + System.out.println(str + "--" + dp.getAddress()); +} catch (Exception e) { + e.printStackTrace(); +} finally { + if (ds != null) + ds.close(); +} + +``` + +#### 举例2: + +**发送端:** + +```java +package com.atguigu.udp; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.util.ArrayList; + +public class Send { + + public static void main(String[] args)throws Exception { +// 1、建立发送端的DatagramSocket + DatagramSocket ds = new DatagramSocket(); + + //要发送的数据 + ArrayList all = new ArrayList(); + all.add("尚硅谷让天下没有难学的技术!"); + all.add("学高端前沿的IT技术来尚硅谷!"); + all.add("尚硅谷让你的梦想变得更具体!"); + all.add("尚硅谷让你的努力更有价值!"); + + //接收方的IP地址 + InetAddress ip = InetAddress.getByName("127.0.0.1"); + //接收方的监听端口号 + int port = 9999; + //发送多个数据报 + for (int i = 0; i < all.size(); i++) { +// 2、建立数据包DatagramPacket + byte[] data = all.get(i).getBytes(); + DatagramPacket dp = new DatagramPacket(data, 0, data.length, ip, port); +// 3、调用Socket的发送方法 + ds.send(dp); + } + +// 4、关闭Socket + ds.close(); + } +} +``` + +**接收端:** + +```java +package com.atguigu.udp; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; + +public class Receive { + + public static void main(String[] args) throws Exception { +// 1、建立接收端的DatagramSocket,需要指定本端的监听端口号 + DatagramSocket ds = new DatagramSocket(9999); + + //一直监听数据 + while(true){ + //2、建立数据包DatagramPacket + byte[] buffer = new byte[1024*64]; + DatagramPacket dp = new DatagramPacket(buffer,buffer.length); + + //3、调用Socket的接收方法 + ds.receive(dp); + + //4、拆封数据 + String str = new String(dp.getData(),0,dp.getLength()); + System.out.println(str); + } + +// ds.close(); + } +} +``` + +## 6. URL编程 + +### 6.1 URL类 + +- URL(Uniform Resource Locator):统一资源定位符,它表示 Internet 上某一资源的地址。 + +- 通过 URL 我们可以访问 Internet 上的各种网络资源,比如最常见的 www,ftp 站点。浏览器通过解析给定的 URL 可以在网络上查找相应的文件或其他资源。 + +- URL的基本结构由5部分组成: + +```http +<传输协议>://<主机名>:<端口号>/<文件名>#片段名?参数列表 +``` + +- 例如: http://192.168.1.100:8080/helloworld/index.jsp#a?username=shkstart&password=123 + - 片段名:即锚点,例如看小说,直接定位到章节 + - 参数列表格式:参数名=参数值&参数名=参数值.... + +- 为了表示URL,java.net 中实现了类 URL。我们可以通过下面的构造器来初始化一个 URL 对象: + + - public URL (String spec):通过一个表示URL地址的字符串可以构造一个URL对象。例如: + + ```http + URL url = new URL("http://www. atguigu.com/"); + ``` + + - public URL(URL context, String spec):通过基 URL 和相对 URL 构造一个 URL 对象。例如: + + ```http + URL downloadUrl = new URL(url, “download.html") + ``` + + public URL(String protocol, String host, String file); 例如: + + ```http + URL url = new URL("http", "www.atguigu.com", “download. html"); + ``` + + - public URL(String protocol, String host, int port, String file); 例如: + + ```java + URL gamelan = new URL("http", "www.atguigu.com", 80, “download.html"); + ``` + +- URL类的构造器都声明抛出非运行时异常,必须要对这一异常进行处理,通常是用 try-catch 语句进行捕获。 + +![image-20220415013546074](images/image-20220415013546074.png) + +### 6.2 URL类常用方法 + +一个URL对象生成后,其属性是不能被改变的,但可以通过它给定的方法来获取这些属性: + +- public String getProtocol( ) 获取该URL的协议名 + +- public String getHost( ) 获取该URL的主机名 + +- public String getPort( ) 获取该URL的端口号 + +- public String getPath( ) 获取该URL的文件路径 + +- public String getFile( ) 获取该URL的文件名 + +- public String getQuery( ) 获取该URL的查询名 + +```java +URL url = new URL("http://localhost:8080/examples/myTest.txt"); +System.out.println("getProtocol() :"+url.getProtocol()); +System.out.println("getHost() :"+url.getHost()); +System.out.println("getPort() :"+url.getPort()); +System.out.println("getPath() :"+url.getPath()); +System.out.println("getFile() :"+url.getFile()); +System.out.println("getQuery() :"+url.getQuery()); +``` + +### 6.3 针对HTTP协议的URLConnection类 + +- URL的方法 openStream():能从网络上读取数据 +- 若希望输出数据,例如向服务器端的 CGI (公共网关接口-Common Gateway Interface-的简称,是用户浏览器和服务器端的应用程序进行连接的接口)程序发送一些数据,则必须先与URL建立连接,然后才能对其进行读写,此时需要使用 URLConnection 。 +- URLConnection:表示到URL所引用的远程对象的连接。当与一个URL建立连接时,首先要在一个 URL 对象上通过方法 openConnection() 生成对应的 URLConnection 对象。如果连接过程失败,将产生IOException. + - URL netchinaren = new URL ("http://www.atguigu.com/index.shtml"); + - URLConnectonn u = netchinaren.openConnection( ); + +- 通过URLConnection对象获取的输入流和输出流,即可以与现有的CGI程序进行交互。 + - public Object getContent( ) throws IOException + + - public int getContentLength( ) + - public String getContentType( ) + - public long getDate( ) + - public long getLastModified( ) + - **public InputStream getInputStream ( ) throws IOException** + - public OutputSteram getOutputStream( )throws IOException + +### 6.4 小结 + +- 位于网络中的计算机具有唯一的IP地址,这样不同的主机可以互相区分。 + +- 客户端-服务器是一种最常见的网络应用程序模型。服务器是一个为其客户端提供某种特定服务的硬件或软件。客户机是一个用户应用程序,用于访问某台服务器提供的服务。端口号是对一个服务的访问场所,它用于区分同一物理计算机上的多个服务。套接字用于连接客户端和服务器,客户端和服务器之间的每个通信会话使用一个不同的套接字。TCP协议用于实现面向连接的会话。 + +- Java 中有关网络方面的功能都定义在 java.net 程序包中。Java 用 InetAddress 对象表示 IP 地址,该对象里有两个字段:主机名(String) 和 IP 地址(int)。 + +- 类 Socket 和 ServerSocket 实现了基于TCP协议的客户端-服务器程序。Socket是客户端和服务器之间的一个连接,连接创建的细节被隐藏了。这个连接提供了一个安全的数据传输通道,这是因为 TCP 协议可以解决数据在传送过程中的丢失、损坏、重复、乱序以及网络拥挤等问题,它保证数据可靠的传送。 + +- 类 URL 和 URLConnection 提供了最高级网络应用。URL 的网络资源的位置来同一表示 Internet 上各种网络资源。通过URL对象可以创建当前应用程序和 URL 表示的网络资源之间的连接,这样当前程序就可以读取网络资源数据,或者把自己的数据传送到网络上去。 \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\350\201\212\345\244\251\345\256\244.pptx" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\350\201\212\345\244\251\345\256\244.pptx" new file mode 100644 index 0000000000000000000000000000000000000000..e47ab1c0189ea49592bde2d457b6e9d39382179e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25416\347\253\240_\347\275\221\347\273\234\347\274\226\347\250\213/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\350\201\212\345\244\251\345\256\244.pptx" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2c5c7f6a101fb35bf18493290c890fd8ff88631cbeba6f983840769382e7d0b +size 1946956 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/1560767438339.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/1560767438339.png" new file mode 100644 index 0000000000000000000000000000000000000000..e98a0d779c5e09ea62d6495d922944a9dc5d9992 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/1560767438339.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20200521081637509.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20200521081637509.png" new file mode 100644 index 0000000000000000000000000000000000000000..b49bebdb370f2b129044a5f6b95b4c7e1561b90f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20200521081637509.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20210726091034587.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20210726091034587.png" new file mode 100644 index 0000000000000000000000000000000000000000..aa191381f8c644610c313b6ab14e3240a78d10d4 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20210726091034587.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20211218091234964.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20211218091234964.png" new file mode 100644 index 0000000000000000000000000000000000000000..fdf03f025d419adf9a39e59edc446188b97852dc --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20211218091234964.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c89a756cfef219a2a90eba360f8899cb6d02872dd66fc719e38b98df2a47a035 +size 143900 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220201131358864.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220201131358864.png" new file mode 100644 index 0000000000000000000000000000000000000000..0c626ee38662c5450724f63bd2f2d9af8923248e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220201131358864.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220201131623646.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220201131623646.png" new file mode 100644 index 0000000000000000000000000000000000000000..74f13b456f40bf1ab0874b765b6bfdd7a8345573 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220201131623646.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417161529285.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417161529285.png" new file mode 100644 index 0000000000000000000000000000000000000000..aa76049125bd3f7b7b9a03aca39e5e94df5d6a75 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417161529285.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417162559217.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417162559217.png" new file mode 100644 index 0000000000000000000000000000000000000000..80af4d09c5b507faab158348f7d99ef46c523c18 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417162559217.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417171411631.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417171411631.png" new file mode 100644 index 0000000000000000000000000000000000000000..8c62fa6bfc0a6b79b2f058476f9612ef067dde60 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417171411631.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0701eff448227f5aac2b9979ecc55caeba932dd330e1f3cb2a33b6fccb02d357 +size 199584 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173216385.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173216385.png" new file mode 100644 index 0000000000000000000000000000000000000000..cab10a3903f18bd503bbe07b6f0348421e0a9d0d Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173216385.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173459849.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173459849.png" new file mode 100644 index 0000000000000000000000000000000000000000..9d6fdd92fd261ef653eeea1a7915762107128b64 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173459849.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173616344.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173616344.png" new file mode 100644 index 0000000000000000000000000000000000000000..162f7d813a3444ab2188fd680e77b5e9f020e01e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173616344.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173647473.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173647473.png" new file mode 100644 index 0000000000000000000000000000000000000000..5c9530a8599d3b39638e490962f467521ca1718b Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173647473.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173819953.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173819953.png" new file mode 100644 index 0000000000000000000000000000000000000000..39c8a50fbe65642060fec34ece14b20e5e6e7818 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417173819953.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417174032702.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417174032702.png" new file mode 100644 index 0000000000000000000000000000000000000000..9825a3549775e5e676c895efa21d148a5c07446d Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417174032702.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417181700813.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417181700813.png" new file mode 100644 index 0000000000000000000000000000000000000000..154cb4ec1fc421075982d11fcfd431a354e564ae Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220417181700813.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220514180100176.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220514180100176.png" new file mode 100644 index 0000000000000000000000000000000000000000..e04b3c63c97b82f485436f5ec247d73f3cbec92f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220514180100176.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220524101441695.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220524101441695.png" new file mode 100644 index 0000000000000000000000000000000000000000..77183e90c8d6fc0f4613e17ce792e6ba8b3bbf7f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220524101441695.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1fb2fb13009ac83cc2c31d19f8cae1d392fa114a7121207ec8f989a4cf283a5 +size 297244 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220524101448625.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220524101448625.png" new file mode 100644 index 0000000000000000000000000000000000000000..77183e90c8d6fc0f4613e17ce792e6ba8b3bbf7f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/image-20220524101448625.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1fb2fb13009ac83cc2c31d19f8cae1d392fa114a7121207ec8f989a4cf283a5 +size 297244 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\345\217\215\345\260\204\346\234\272\345\210\266.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\345\217\215\345\260\204\346\234\272\345\210\266.png" new file mode 100644 index 0000000000000000000000000000000000000000..d39faf5aef0f0e5203ea1aecb3b3ba200f4a83f5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\345\217\215\345\260\204\346\234\272\345\210\266.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b31e810ec8d99dc657ad6032014ac474674232a36ddc9a622f65db821dd24563 +size 480225 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25417\347\253\240.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25417\347\253\240.png" new file mode 100644 index 0000000000000000000000000000000000000000..536cdf799de4f997bad7128bcc2a89120af89dd5 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/images/\347\254\2543\351\230\266\346\256\265\357\274\232Java\351\253\230\347\272\247\345\272\224\347\224\250-\347\254\25417\347\253\240.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1afdc5a0e1e52f9db6009a7e16d79980844e4a6c6071f61f555ba361a1a93cbc +size 584430 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266.md" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266.md" new file mode 100644 index 0000000000000000000000000000000000000000..bcf55d6c677adc369166bbdcd7e542af9630332a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25417\347\253\240_\345\217\215\345\260\204\346\234\272\345\210\266.md" @@ -0,0 +1,1446 @@ +# 第17章_反射机制 + +讲师:尚硅谷-宋红康(江湖人称:康师傅) + +官网:[http://www.atguigu.com](http://www.atguigu.com/) + +*** + +## 本章专题与脉络 + +![第3阶段:Java高级应用-第17章](images/第3阶段:Java高级应用-第17章.png) + +*** + +## 1. 反射(Reflection)的概念 + +### 1.1 反射的出现背景 + +Java程序中,所有的对象都有两种类型:`编译时类型`和`运行时类型`,而很多时候对象的编译时类型和运行时类型`不一致`。 Object obj = new String("hello"); obj.getClass() + +例如:某些变量或形参的声明类型是Object类型,但是程序却需要调用该对象运行时类型的方法,该方法不是Object中的方法,那么如何解决呢? + +解决这个问题,有两种方案: + +方案1:在编译和运行时都完全知道类型的具体信息,在这种情况下,我们可以直接先使用`instanceof`运算符进行判断,再利用强制类型转换符将其转换成运行时类型的变量即可。 + +方案2:编译时根本无法预知该对象和类的真实信息,程序只能依靠`运行时信息`来发现该对象和类的真实信息,这就必须使用反射。 + +### 1.2 反射概述 + +Reflection(反射)是被视为`动态语言`的关键,反射机制允许程序在`运行期间`借助于Reflection API取得任何类的内部信息,并能直接操作任意对象的内部属性及方法。 + +加载完类之后,在堆内存的方法区中就产生了一个Class类型的对象(一个类只有一个Class对象),这个对象就包含了完整的类的结构信息。我们可以通过这个对象看到类的结构。`这个对象就像一面镜子,透过这个镜子看到类的结构,所以,我们形象的称之为:反射。` + +image-20220417161529285 + +**从内存加载上看反射:** + +![image-20220524101448625](images/image-20220524101448625.png) + +### 1.3 Java反射机制研究及应用 + +Java反射机制提供的功能: + +- 在运行时判断任意一个对象所属的类 +- 在运行时构造任意一个类的对象 +- 在运行时判断任意一个类所具有的成员变量和方法 +- 在运行时获取泛型信息 +- 在运行时调用任意一个对象的成员变量和方法 +- 在运行时处理注解 +- 生成动态代理 + +### 1.4 反射相关的主要API + +`java.lang.Class`:代表一个类 +java.lang.reflect.Method:代表类的方法 +java.lang.reflect.Field:代表类的成员变量 +java.lang.reflect.Constructor:代表类的构造器 +… … + +### 1.5 反射的优缺点 + +**优点:** + +- 提高了Java程序的灵活性和扩展性,`降低了耦合性`,提高`自适应`能力 + +- 允许程序创建和控制任何类的对象,无需提前`硬编码`目标类 + +**缺点:** + +- 反射的`性能较低`。 + - 反射机制主要应用在对灵活性和扩展性要求很高的系统框架上 + +- 反射会`模糊`程序内部逻辑,`可读性较差`。 + +## 2. 理解Class类并获取Class实例 + +要想`解剖`一个类,必须先要获取到该类的Class对象。而剖析一个类或用反射解决具体的问题就是使用相关API: + +- java.lang.Class +- java.lang.reflect.* + +所以,Class对象是反射的根源。 + +### 2.1 理解Class + +#### 2.1.1 理论上 + +在Object类中定义了以下的方法,此方法将被所有子类继承: + +```java +public final Class getClass() +``` + +以上的方法返回值的类型是一个Class类,此类是Java反射的源头,实际上所谓反射从程序的运行结果来看也很好理解,即:可以通过对象反射求出类的名称。 + +image-20220417162559217 + +对象照镜子后可以得到的信息:某个类的属性、方法和构造器、某个类到底实现了哪些接口。对于每个类而言,JRE 都为其保留一个不变的 Class 类型的对象。一个 Class 对象包含了特定某个结构(class/interface/enum/annotation/primitive type/void/[])的有关信息。 + +- Class本身也是一个类 +- Class 对象只能由系统建立对象 +- 一个加载的类在 JVM 中只会有一个Class实例 +- 一个Class对象对应的是一个加载到JVM中的一个.class文件 +- 每个类的实例都会记得自己是由哪个 Class 实例所生成 +- 通过Class可以完整地得到一个类中的所有被加载的结构 +- Class类是Reflection的根源,针对任何你想动态加载、运行的类,唯有先获得相应的Class对象 + +#### 2.1.2 内存结构上 + +image-20220514180100176 + +说明:上图中字符串常量池在JDK6中存储在方法区;JDK7及以后,存储在堆空间。 + +### 2.2 获取Class类的实例(四种方法) + +方式1:要求编译期间已知类型 + +前提:若已知具体的类,通过类的class属性获取,该方法最为安全可靠,程序性能最高 + +实例: + +```java +Class clazz = String.class; +``` + +方式2:获取对象的运行时类型 + +前提:已知某个类的实例,调用该实例的getClass()方法获取Class对象 + +实例: + +```java +Class clazz = "www.atguigu.com".getClass(); +``` + +方式3:可以获取编译期间未知的类型 + +前提:已知一个类的全类名,且该类在类路径下,可通过Class类的静态方法forName()获取,可能抛出ClassNotFoundException + +实例: + +```java +Class clazz = Class.forName("java.lang.String"); +``` + +方式4:其他方式(不做要求) + +前提:可以用系统类加载对象或自定义加载器对象加载指定路径下的类型 + +实例: + +```java +ClassLoader cl = this.getClass().getClassLoader(); +Class clazz4 = cl.loadClass("类的全类名"); +``` + +再举例: + +```java +public class GetClassObject { + @Test + public void test01() throws ClassNotFoundException{ + Class c1 = GetClassObject.class; + GetClassObject obj = new GetClassObject(); + Class c2 = obj.getClass(); + Class c3 = Class.forName("com.atguigu.classtype.GetClassObject"); + Class c4 = ClassLoader.getSystemClassLoader().loadClass("com.atguigu.classtype.GetClassObject"); + + System.out.println("c1 = " + c1); + System.out.println("c2 = " + c2); + System.out.println("c3 = " + c3); + System.out.println("c4 = " + c4); + + System.out.println(c1 == c2); + System.out.println(c1 == c3); + System.out.println(c1 == c4); + } +} +``` + +### 2.3 哪些类型可以有Class对象 + +简言之,所有Java类型! + +(1)class:外部类,成员(成员内部类,静态内部类),局部内部类,匿名内部类 +(2)interface:接口 +(3)[]:数组 +(4)enum:枚举 +(5)annotation:注解@interface +(6)primitive type:基本数据类型 +(7)void + +举例: + +```java +Class c1 = Object.class; +Class c2 = Comparable.class; +Class c3 = String[].class; +Class c4 = int[][].class; +Class c5 = ElementType.class; +Class c6 = Override.class; +Class c7 = int.class; +Class c8 = void.class; +Class c9 = Class.class; + +int[] a = new int[10]; +int[] b = new int[100]; +Class c10 = a.getClass(); +Class c11 = b.getClass(); +// 只要元素类型与维度一样,就是同一个Class +System.out.println(c10 == c11); +``` + +### 2.4 Class类的常用方法 + +| **方法名** | **功能说明** | +| -------------------------------------------------- | ------------------------------------------------------------ | +| static Class forName(String name) | 返回指定类名 name 的 Class 对象 | +| Object newInstance() | 调用缺省构造函数,返回该Class对象的一个实例 | +| getName() | 返回此Class对象所表示的实体(类、接口、数组类、基本类型或void)名称 | +| Class getSuperClass() | 返回当前Class对象的父类的Class对象 | +| Class [] getInterfaces() | 获取当前Class对象的接口 | +| ClassLoader getClassLoader() | 返回该类的类加载器 | +| Class getSuperclass() | 返回表示此Class所表示的实体的超类的Class | +| Constructor[] getConstructors() | 返回一个包含某些Constructor对象的数组 | +| Field[] getDeclaredFields() | 返回Field对象的一个数组 | +| Method getMethod(String name,Class … paramTypes) | 返回一个Method对象,此对象的形参类型为paramType | + +举例: + +```java +String str = "test4.Person"; +Class clazz = Class.forName(str); + +Object obj = clazz.newInstance(); + +Field field = clazz.getField("name"); +field.set(obj, "Peter"); +Object name = field.get(obj); +System.out.println(name); + +//注:test4.Person是test4包下的Person类 +``` + +## 3. 类的加载与ClassLoader的理解 + +### 3.1 类的生命周期 + +类在内存中完整的生命周期:加载-->使用-->卸载。其中加载过程又分为:装载、链接、初始化三个阶段。 + +![image-20220417173459849](images/image-20220417173459849.png) + +### 3.2 类的加载过程 + +当程序主动使用某个类时,如果该类还未被加载到内存中,系统会通过加载、链接、初始化三个步骤来对该类进行初始化。如果没有意外,JVM将会连续完成这三个步骤,所以有时也把这三个步骤统称为类加载。 + +image-20220417171411631 + +类的加载又分为三个阶段: + +(1)装载(Loading) + +将类的class文件读入内存,并为之创建一个java.lang.Class对象。此过程由类加载器完成 + +(2)链接(Linking) + +①验证Verify:确保加载的类信息符合JVM规范,例如:以cafebabe开头,没有安全方面的问题。 + +②准备Prepare:正式为类变量(static)分配内存并`设置类变量默认初始值`的阶段,这些内存都将在方法区中进行分配。 + +③解析Resolve:虚拟机常量池内的符号引用(常量名)替换为直接引用(地址)的过程。 + +(3)初始化(Initialization) + +- 执行`类构造器()方法`的过程。`类构造器()方法`是由编译期自动收集类中所有类变量的赋值动作和静态代码块中的语句合并产生的。(类构造器是构造类信息的,不是构造该类对象的构造器)。 + +- 当初始化一个类的时候,如果发现其父类还没有进行初始化,则需要先触发其父类的初始化。 + +- 虚拟机会保证一个`类的()方法`在多线程环境中被正确加锁和同步。 + +### 3.3 类加载器(classloader) + +image-20220417173647473 + +#### 3.3.1 类加载器的作用 + +将class文件字节码内容加载到内存中,并将这些静态数据转换成方法区的运行时数据结构,然后在堆中生成一个代表这个类的java.lang.Class对象,作为方法区中类数据的访问入口。 + +类缓存:标准的JavaSE类加载器可以按要求查找类,但一旦某个类被加载到类加载器中,它将维持加载(缓存)一段时间。不过JVM垃圾回收机制可以回收这些Class对象。 + +image-20220417173616344 + +#### 3.3.2 类加载器的分类(JDK8为例) + +JVM支持两种类型的类加载器,分别为`引导类加载器(Bootstrap ClassLoader)`和`自定义类加载器(User-Defined ClassLoader)`。 + +从概念上来讲,自定义类加载器一般指的是程序中由开发人员自定义的一类类加载器,但是Java虚拟机规范却没有这么定义,而是将所有派生于抽象类ClassLoader的类加载器都划分为自定义类加载器。无论类加载器的类型如何划分,在程序中我们最常见的类加载器结构主要是如下情况: + +image-20220417173819953 + + + +**(1)启动类加载器(引导类加载器,Bootstrap ClassLoader)** + +- 这个类加载使用`C/C++语言`实现的,嵌套在JVM内部。获取它的对象时往往返回null +- 它用来加载Java的核心库(JAVA_HOME/jre/lib/rt.jar或sun.boot.class.path路径下的内容)。用于提供JVM自身需要的类。 +- 并不继承自java.lang.ClassLoader,没有父加载器。 +- 出于安全考虑,Bootstrap启动类加载器只加载包名为java、javax、sun等开头的类 +- 加载扩展类和应用程序类加载器,并指定为他们的父类加载器。 + +**(2)扩展类加载器(Extension ClassLoader)** + +- Java语言编写,由sun.misc.Launcher$ExtClassLoader实现。 +- 继承于ClassLoader类 +- 父类加载器为启动类加载器 +- 从java.ext.dirs系统属性所指定的目录中加载类库,或从JDK的安装目录的jre/lib/ext子目录下加载类库。如果用户创建的JAR放在此目录下,也会自动由扩展类加载器加载。 + +![image-20220417174032702](images/image-20220417174032702.png) + +**(3)应用程序类加载器(系统类加载器,AppClassLoader)** + +- java语言编写,由sun.misc.Launcher$AppClassLoader实现 +- 继承于ClassLoader类 +- 父类加载器为扩展类加载器 +- 它负责加载环境变量classpath或系统属性 java.class.path 指定路径下的类库 +- 应用程序中的类加载器默认是系统类加载器。 +- 它是用户自定义类加载器的默认父加载器 +- 通过ClassLoader的getSystemClassLoader()方法可以获取到该类加载器 + +**(4)用户自定义类加载器(了解)** + +- 在Java的日常应用程序开发中,类的加载几乎是由上述3种类加载器相互配合执行的。在必要时,我们还可以自定义类加载器,来定制类的加载方式。 +- 体现Java语言强大生命力和巨大魅力的关键因素之一便是,Java开发者可以自定义类加载器来实现类库的动态加载,加载源可以是本地的JAR包,也可以是网络上的远程资源。 +- 同时,自定义加载器能够实现`应用隔离`,例如 Tomcat,Spring等中间件和组件框架都在内部实现了自定义的加载器,并通过自定义加载器隔离不同的组件模块。这种机制比C/C++程序要好太多,想不修改C/C++程序就能为其新增功能,几乎是不可能的,仅仅一个兼容性便能阻挡住所有美好的设想。 +- 自定义类加载器通常需要继承于ClassLoader。 + +#### 3.3.3 查看某个类的类加载器对象 + +(1)获取默认的系统类加载器 + +```java +ClassLoader classloader = ClassLoader.getSystemClassLoader(); +``` + +(2)查看某个类是哪个类加载器加载的 + +```java +ClassLoader classloader = Class.forName("exer2.ClassloaderDemo").getClassLoader(); + +//如果是根加载器加载的类,则会得到null +ClassLoader classloader1 = Class.forName("java.lang.Object").getClassLoader(); +``` + +(3)获取某个类加载器的父加载器 + +```java +ClassLoader parentClassloader = classloader.getParent(); +``` + +示例代码: + +```java +package com.atguigu.loader; + +import org.junit.Test; + +public class TestClassLoader { + @Test + public void test01(){ + ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); + System.out.println("systemClassLoader = " + systemClassLoader); + } + + @Test + public void test02()throws Exception{ + ClassLoader c1 = String.class.getClassLoader(); + System.out.println("加载String类的类加载器:" + c1); + + ClassLoader c2 = Class.forName("sun.util.resources.cldr.zh.TimeZoneNames_zh").getClassLoader(); + System.out.println("加载sun.util.resources.cldr.zh.TimeZoneNames_zh类的类加载器:" + c2); + + ClassLoader c3 = TestClassLoader.class.getClassLoader(); + System.out.println("加载当前类的类加载器:" + c3); + } + + @Test + public void test03(){ + ClassLoader c1 = TestClassLoader.class.getClassLoader(); + System.out.println("加载当前类的类加载器c1=" + c1); + + ClassLoader c2 = c1.getParent(); + System.out.println("c1.parent = " + c2); + + ClassLoader c3 = c2.getParent(); + System.out.println("c2.parent = " + c3); + + } +} +``` + +#### 3.3.4 使用ClassLoader获取流 + +关于类加载器的一个主要方法:getResourceAsStream(String str):获取类路径下的指定文件的输入流 + +```java + +InputStream in = null; +in = this.getClass().getClassLoader().getResourceAsStream("exer2\\test.properties"); +System.out.println(in); + +``` + +举例: + +```java +//需要掌握如下的代码 + @Test + public void test5() throws IOException { + Properties pros = new Properties(); + //方式1:此时默认的相对路径是当前的module +// FileInputStream is = new FileInputStream("info.properties"); +// FileInputStream is = new FileInputStream("src//info1.properties"); + + //方式2:使用类的加载器 + //此时默认的相对路径是当前module的src目录 + InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("info1.properties"); + + + pros.load(is); + + //获取配置文件中的信息 + String name = pros.getProperty("name"); + String password = pros.getProperty("password"); + System.out.println("name = " + name + ", password = " + password); + } +``` + +## 4. 反射的基本应用 + +有了Class对象,能做什么? + +### 4.1 应用1:创建运行时类的对象 + +这是反射机制应用最多的地方。创建运行时类的对象有两种方式: + +**方式1:直接调用Class对象的newInstance()方法** + +要 求: 1)类必须有一个无参数的构造器。2)类的构造器的访问权限需要足够。 + +**方式2:通过获取构造器对象来进行实例化** + +方式一的步骤: + +1)获取该类型的Class对象 2)调用Class对象的newInstance()方法创建对象 + +方式二的步骤: + +1)通过Class类的getDeclaredConstructor(Class … parameterTypes)取得本类的指定形参类型的构造器 +2)向构造器的形参中传递一个对象数组进去,里面包含了构造器中所需的各个参数。 +3)通过Constructor实例化对象。 + +> 如果构造器的权限修饰符修饰的范围不可见,也可以调用setAccessible(true) + +示例代码: + +```java +package com.atguigu.reflect; + +import org.junit.Test; + +import java.lang.reflect.Constructor; + +public class TestCreateObject { + @Test + public void test1() throws Exception{ +// AtGuiguClass obj = new AtGuiguClass();//编译期间无法创建 + + Class clazz = Class.forName("com.atguigu.ext.demo.AtGuiguClass"); + //clazz代表com.atguigu.ext.demo.AtGuiguClass类型 + //clazz.newInstance()创建的就是AtGuiguClass的对象 + Object obj = clazz.newInstance(); + System.out.println(obj); + } + + @Test + public void test2()throws Exception{ + Class clazz = Class.forName("com.atguigu.ext.demo.AtGuiguDemo"); + //java.lang.InstantiationException: com.atguigu.ext.demo.AtGuiguDemo + //Caused by: java.lang.NoSuchMethodException: com.atguigu.ext.demo.AtGuiguDemo.() + //即说明AtGuiguDemo没有无参构造,就没有无参实例初始化方法 + Object stu = clazz.newInstance(); + System.out.println(stu); + } + + @Test + public void test3()throws Exception{ + //(1)获取Class对象 + Class clazz = Class.forName("com.atguigu.ext.demo.AtGuiguDemo"); + /* + * 获取AtGuiguDemo类型中的有参构造 + * 如果构造器有多个,我们通常是根据形参【类型】列表来获取指定的一个构造器的 + * 例如:public AtGuiguDemo(String title, int num) + */ + //(2)获取构造器对象 + Constructor constructor = clazz.getDeclaredConstructor(String.class,int.class); + + //(3)创建实例对象 + // T newInstance(Object... initargs) 这个Object...是在创建对象时,给有参构造的实参列表 + Object obj = constructor.newInstance("尚硅谷",2022); + System.out.println(obj); + } +} +``` + +### 4.2 应用2:获取运行时类的完整结构 + +可以获取:包、修饰符、类型名、父类(包括泛型父类)、父接口(包括泛型父接口)、成员(属性、构造器、方法)、注解(类上的、方法上的、属性上的)。 + +#### 4.2.1 相关API + +```java +//1.实现的全部接口 +public Class[] getInterfaces() +//确定此对象所表示的类或接口实现的接口。 + +//2.所继承的父类 +public Class getSuperclass() +//返回表示此 Class 所表示的实体(类、接口、基本类型)的父类的 Class。 + +//3.全部的构造器 +public Constructor[] getConstructors() +//返回此 Class 对象所表示的类的所有public构造方法。 +public Constructor[] getDeclaredConstructors() +//返回此 Class 对象表示的类声明的所有构造方法。 + +//Constructor类中: +//取得修饰符: +public int getModifiers(); +//取得方法名称: +public String getName(); +//取得参数的类型: +public Class[] getParameterTypes(); + +//4.全部的方法 +public Method[] getDeclaredMethods() +//返回此Class对象所表示的类或接口的全部方法 +public Method[] getMethods() +//返回此Class对象所表示的类或接口的public的方法 + +//Method类中: +public Class getReturnType() +//取得全部的返回值 +public Class[] getParameterTypes() +//取得全部的参数 +public int getModifiers() +//取得修饰符 +public Class[] getExceptionTypes() +//取得异常信息 + +//5.全部的Field +public Field[] getFields() +//返回此Class对象所表示的类或接口的public的Field。 +public Field[] getDeclaredFields() +//返回此Class对象所表示的类或接口的全部Field。 + +//Field方法中: +public int getModifiers() +//以整数形式返回此Field的修饰符 +public Class getType() +//得到Field的属性类型 +public String getName() +//返回Field的名称。 + +//6. Annotation相关 +get Annotation(Class annotationClass) +getDeclaredAnnotations() + +//7.泛型相关 +//获取父类泛型类型: +Type getGenericSuperclass() +//泛型类型:ParameterizedType +//获取实际的泛型类型参数数组: +getActualTypeArguments() + +//8.类所在的包 +Package getPackage() +``` + +#### 4.2.2 获取所有的属性及相关细节 + +```java +package com.atguigu.java2; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; + +import org.junit.Test; + +import com.atguigu.java1.Person; + +public class FieldTest { + + @Test + public void test1(){ + + Class clazz = Person.class; + //getFields():获取到运行时类本身及其所有的父类中声明为public权限的属性 +// Field[] fields = clazz.getFields(); +// +// for(Field f : fields){ +// System.out.println(f); +// } + + //getDeclaredFields():获取当前运行时类中声明的所有属性 + Field[] declaredFields = clazz.getDeclaredFields(); + for(Field f : declaredFields){ + System.out.println(f); + } + } + + //权限修饰符 变量类型 变量名 + @Test + public void test2(){ + Class clazz = Person.class; + Field[] declaredFields = clazz.getDeclaredFields(); + for(Field f : declaredFields){ + //1.权限修饰符 + /* + * 0x是十六进制 + * PUBLIC = 0x00000001; 1 1 + * PRIVATE = 0x00000002; 2 10 + * PROTECTED = 0x00000004; 4 100 + * STATIC = 0x00000008; 8 1000 + * FINAL = 0x00000010; 16 10000 + * ... + * + * 设计的理念,就是用二进制的某一位是1,来代表一种修饰符,整个二进制中只有一位是1,其余都是0 + * + * mod = 17 0x00000011 + * if ((mod & PUBLIC) != 0) 说明修饰符中有public + * if ((mod & FINAL) != 0) 说明修饰符中有final + */ + int modifier = f.getModifiers(); + System.out.print(Modifier.toString(modifier) + "\t"); + +// //2.数据类型 + Class type = f.getType(); + System.out.print(type.getName() + "\t"); +// +// //3.变量名 + String fName = f.getName(); + System.out.print(fName); +// + System.out.println(); + } + } +} + +``` + +#### 4.2.3 获取所有的方法及相关细节 + +```java +package com.atguigu.java2; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +import org.junit.Test; + +import com.atguigu.java1.Person; + +public class MethodTest { + + @Test + public void test1() { + + Class clazz = Person.class; + // getMethods():获取到运行时类本身及其所有的父类中声明为public权限的方法 + // Method[] methods = clazz.getMethods(); + // + // for(Method m : methods){ + // System.out.println(m); + // } + + // getDeclaredMethods():获取当前运行时类中声明的所有方法 + Method[] declaredMethods = clazz.getDeclaredMethods(); + for (Method m : declaredMethods) { + System.out.println(m); + } + // + } + + // 注解信息 + // 权限修饰符 返回值类型 方法名(形参类型1 参数1,形参类型2 参数2,...) throws 异常类型1,...{} + @Test + public void test2() { + Class clazz = Person.class; + Method[] declaredMethods = clazz.getDeclaredMethods(); + for (Method m : declaredMethods) { + // 1.获取方法声明的注解 + Annotation[] annos = m.getAnnotations(); + for (Annotation a : annos) { + System.out.println(a); + } + + // 2.权限修饰符 + System.out.print(Modifier.toString(m.getModifiers()) + "\t"); + + // 3.返回值类型 + System.out.print(m.getReturnType().getName() + "\t"); + + // 4.方法名 + System.out.print(m.getName()); + System.out.print("("); + // 5.形参列表 + Class[] parameterTypes = m.getParameterTypes(); + if (!(parameterTypes == null && parameterTypes.length == 0)) { + for (int i = 0; i < parameterTypes.length; i++) { + + if (i == parameterTypes.length - 1) { + System.out.print(parameterTypes[i].getName() + " args_" + i); + break; + } + + System.out.print(parameterTypes[i].getName() + " args_" + i + ","); + } + } + + System.out.print(")"); + + // 6.抛出的异常 + Class[] exceptionTypes = m.getExceptionTypes(); + if (exceptionTypes.length > 0) { + System.out.print("throws "); + for (int i = 0; i < exceptionTypes.length; i++) { + if (i == exceptionTypes.length - 1) { + System.out.print(exceptionTypes[i].getName()); + break; + } + System.out.print(exceptionTypes[i].getName() + ","); + } + } + System.out.println(); + } + } +} + +``` + +#### 4.2.4 获取其他结构(构造器、父类、接口、包、注解等) + +```java +package com.atguigu.java2; + +import com.atguigu.java1.Person; +import org.junit.Test; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; + +/** + * @author 尚硅谷-宋红康 + * @create 2020 下午 2:47 + */ +public class OtherTest { + + /* + 获取当前类中的所有的构造器 + */ + @Test + public void test1(){ + Class clazz = Person.class; + Constructor[] cons = clazz.getDeclaredConstructors(); + for(Constructor c :cons){ + System.out.println(c); + } + } + /* + 获取运行时类的父类 + */ + @Test + public void test2(){ + Class clazz = Person.class; + Class superclass = clazz.getSuperclass(); + System.out.println(superclass);//class com.atguigu.java1.Creature + } + /* + 获取运行时类的所在的包 + */ + @Test + public void test3(){ + Class clazz = Person.class; + Package pack = clazz.getPackage(); + System.out.println(pack); + + } + /* + 获取运行时类的注解 + */ + @Test + public void test4(){ + Class clazz = Person.class; + Annotation[] annos = clazz.getAnnotations(); + for (Annotation anno : annos) { + + System.out.println(anno); + } + + } + + /* + 获取运行时类所实现的接口 + */ + @Test + public void test5(){ + Class clazz = Person.class; + Class[] interfaces = clazz.getInterfaces(); + for (Class anInterface : interfaces) { + + System.out.println(anInterface); + } + + } + /* + 获取运行时类的带泛型的父类 + */ + @Test + public void test6(){ + Class clazz = Person.class; + Type genericSuperclass = clazz.getGenericSuperclass(); + System.out.println(genericSuperclass);//com.atguigu.java1.Creature + } +} + +``` + +#### 4.2.5 获取泛型父类信息(选讲) + +示例代码获取泛型父类信息: + +```java +/* Type: + * (1)Class + * (2)ParameterizedType + * 例如:Father + * ArrayList + * (3)TypeVariable + * 例如:T,U,E,K,V + * (4)WildcardType + * 例如: + * ArrayList + * ArrayList + * ArrayList + * (5)GenericArrayType + * 例如:T[] + * + */ +public class TestGeneric { + public static void main(String[] args) { + //需求:在运行时,获取Son类型的泛型父类的泛型实参 + + //(1)还是先获取Class对象 + Class clazz = Son.class;//四种形式任意一种都可以 + + //(2)获取泛型父类 +// Class sc = clazz.getSuperclass(); +// System.out.println(sc); + /* + * getSuperclass()只能得到父类名,无法得到父类的泛型实参列表 + */ + Type type = clazz.getGenericSuperclass(); + + // Father属于ParameterizedType + ParameterizedType pt = (ParameterizedType) type; + + //(3)获取泛型父类的泛型实参列表 + Type[] typeArray = pt.getActualTypeArguments(); + for (Type type2 : typeArray) { + System.out.println(type2); + } + } +} +//泛型形参: +class Father{ + +} +//泛型实参: +class Son extends Father{ + +} +``` + +#### 4.2.6 获取内部类或外部类信息(选讲) + +public Class[] getClasses():返回所有公共内部类和内部接口。包括从超类继承的公共类和接口成员以及该类声明的公共类和接口成员。 + +public Class[] getDeclaredClasses():返回 Class 对象的一个数组,这些对象反映声明为此 Class 对象所表示的类的成员的所有类和接口。包括该类所声明的公共、保护、默认(包)访问及私有类和接口,但不包括继承的类和接口。 + +public Class getDeclaringClass():如果此 Class 对象所表示的类或接口是一个内部类或内部接口,则返回它的外部类或外部接口,否则返回null。 + +Class getEnclosingClass() :返回某个内部类的外部类 + +```java + @Test + public void test5(){ + Class clazz = Map.class; + Class[] inners = clazz.getDeclaredClasses(); + for (Class inner : inners) { + System.out.println(inner); + } + + Class ec = Map.Entry.class; + Class outer = ec.getDeclaringClass(); + System.out.println(outer); + } +``` + + + +#### 4.2.7 小 结 + +1. 在实际的操作中,取得类的信息的操作代码,并不会经常开发。 + +2. 一定要熟悉java.lang.reflect包的作用,反射机制。 + +### 4.3 应用3:调用运行时类的指定结构 + +#### 4.3.1 调用指定的属性 + +在反射机制中,可以直接通过Field类操作类中的属性,通过Field类提供的set()和get()方法就可以完成设置和取得属性内容的操作。 + +(1)获取该类型的Class对象 + +Class clazz = Class.forName("包.类名"); + +(2)获取属性对象 + +Field field = clazz.getDeclaredField("属性名"); + +(3)如果属性的权限修饰符不是public,那么需要设置属性可访问 + +field.setAccessible(true); + +(4)创建实例对象:如果操作的是非静态属性,需要创建实例对象 + +Object obj = clazz.newInstance(); //有公共的无参构造 + +Object obj = 构造器对象.newInstance(实参...);//通过特定构造器对象创建实例对象 + +(4)设置指定对象obj上此Field的属性内容 + +field.set(obj,"属性值"); + +> 如果操作静态变量,那么实例对象可以省略,用null表示 + +(5)取得指定对象obj上此Field的属性内容 + +Object value = field.get(obj); + +> 如果操作静态变量,那么实例对象可以省略,用null表示 + +示例代码: + +```java +package com.atguigu.reflect; + +public class Student { + private int id; + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Student{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } +} + +``` + +```java +package com.atguigu.reflect; + +import java.lang.reflect.Field; + +public class TestField { + public static void main(String[] args)throws Exception { + //1、获取Student的Class对象 + Class clazz = Class.forName("com.atguigu.reflect.Student"); + + //2、获取属性对象,例如:id属性 + Field idField = clazz.getDeclaredField("id"); + + //3、如果id是私有的等在当前类中不可访问access的,我们需要做如下操作 + idField.setAccessible(true); + + //4、创建实例对象,即,创建Student对象 + Object stu = clazz.newInstance(); + + //5、获取属性值 + /* + * 以前:int 变量= 学生对象.getId() + * 现在:Object id属性对象.get(学生对象) + */ + Object value = idField.get(stu); + System.out.println("id = "+ value); + + //6、设置属性值 + /* + * 以前:学生对象.setId(值) + * 现在:id属性对象.set(学生对象,值) + */ + idField.set(stu, 2); + + value = idField.get(stu); + System.out.println("id = "+ value); + } +} +``` + +**关于setAccessible方法的使用:** + +- Method和Field、Constructor对象都有setAccessible()方法。 +- setAccessible启动和禁用访问安全检查的开关。 +- 参数值为true则指示反射的对象在使用时应该取消Java语言访问检查。 + - 提高反射的效率。如果代码中必须用反射,而该句代码需要频繁的被调用,那么请设置为true。 + - 使得原本无法访问的私有成员也可以访问 +- 参数值为false则指示反射的对象应该实施Java语言访问检查。 + +#### 4.3.2 调用指定的方法 + +image-20220417181700813 + +(1)获取该类型的Class对象 + +Class clazz = Class.forName("包.类名"); + +(2)获取方法对象 + +Method method = clazz.getDeclaredMethod("方法名",方法的形参类型列表); + +(3)创建实例对象 + +Object obj = clazz.newInstance(); + +(4)调用方法 + +Object result = method.invoke(obj, 方法的实参值列表); + +> 如果方法的权限修饰符修饰的范围不可见,也可以调用setAccessible(true) +> +> 如果方法是静态方法,实例对象也可以省略,用null代替 + +示例代码: + +```java +package com.atguigu.reflect; + +import org.junit.Test; + +import java.lang.reflect.Method; + +public class TestMethod { + @Test + public void test()throws Exception { + // 1、获取Student的Class对象 + Class clazz = Class.forName("com.atguigu.reflect.Student"); + + //2、获取方法对象 + /* + * 在一个类中,唯一定位到一个方法,需要:(1)方法名(2)形参列表,因为方法可能重载 + * + * 例如:void setName(String name) + */ + Method setNameMethod = clazz.getDeclaredMethod("setName", String.class); + + //3、创建实例对象 + Object stu = clazz.newInstance(); + + //4、调用方法 + /* + * 以前:学生对象.setName(值) + * 现在:方法对象.invoke(学生对象,值) + */ + Object setNameMethodReturnValue = setNameMethod.invoke(stu, "张三"); + + System.out.println("stu = " + stu); + //setName方法返回值类型void,没有返回值,所以setNameMethodReturnValue为null + System.out.println("setNameMethodReturnValue = " + setNameMethodReturnValue); + + Method getNameMethod = clazz.getDeclaredMethod("getName"); + Object getNameMethodReturnValue = getNameMethod.invoke(stu); + //getName方法返回值类型String,有返回值,getNameMethod.invoke的返回值就是getName方法的返回值 + System.out.println("getNameMethodReturnValue = " + getNameMethodReturnValue);//张三 + } + + @Test + public void test02()throws Exception{ + Class clazz = Class.forName("com.atguigu.ext.demo.AtGuiguClass"); + Method printInfoMethod = clazz.getMethod("printInfo", String.class); + //printInfo方法是静态方法 + printInfoMethod.invoke(null,"尚硅谷"); + } +} + +``` + +#### 4.3.3 练习 + +读取user.properties文件中的数据,通过反射完成User类对象的创建及对应方法的调用。 + +配置文件:user.properties + +``` +className:com.atguigu.bean.User +methodName:show +``` + +User.java文件: + +```java +package com.atguigu.bean; + +/** + * @author 尚硅谷-宋红康 + * @create 18:41 + */ +public class User { + private String name; + + public User() { + } + + public User(String name) { + this.name = name; + } + + public void show(){ + System.out.println("我是一个脉脉平台的用户"); + } +} +``` + +ReflectTest.java文件: + +```java +package com.atguigu.java4; + +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.Properties; + +/** + * @author 尚硅谷-宋红康 + * @create 18:43 + */ +public class ReflectTest { + @Test + public void test() throws Exception { + //1.创建Properties对象 + Properties pro = new Properties(); + + //2.加载配置文件,转换为一个集合 + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + InputStream is = classLoader.getResourceAsStream("user.properties"); + pro.load(is); + + //3.获取配置文件中定义的数据 + String className = pro.getProperty("className"); + String methodName = pro.getProperty("methodName"); + + //4.加载该类进内存 + Class clazz = Class.forName(className); + + //5.创建对象 + Object instance = clazz.newInstance(); + + //6.获取方法对象 + Method showMethod = clazz.getMethod(methodName); + + //7.执行方法 + showMethod.invoke(instance); + } +} + +``` + + + +## 5. 应用4:读取注解信息 + +一个完整的注解应该包含三个部分: +(1)声明 +(2)使用 +(3)读取 + +### 5.1 声明自定义注解 + +```java +package com.atguigu.annotation; + +import java.lang.annotation.*; + +@Inherited +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface Table { + String value(); +} +``` + +```java +package com.atguigu.annotation; + +import java.lang.annotation.*; + +@Inherited +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Column { + String columnName(); + String columnType(); +} +``` + +* 自定义注解可以通过四个元注解@Retention,@Target,@Inherited,@Documented,分别说明它的声明周期,使用位置,是否被继承,是否被生成到API文档中。 +* Annotation 的成员在 Annotation 定义中以无参数有返回值的抽象方法的形式来声明,我们又称为配置参数。返回值类型只能是八种基本数据类型、String类型、Class类型、enum类型、Annotation类型、以上所有类型的数组 +* 可以使用 default 关键字为抽象方法指定默认返回值 +* 如果定义的注解含有抽象方法,那么使用时必须指定返回值,除非它有默认值。格式是“方法名 = 返回值”,如果只有一个抽象方法需要赋值,且方法名为value,可以省略“value=”,所以如果注解只有一个抽象方法成员,建议使用方法名value。 + +### 5.2 使用自定义注解 + +```java +package com.atguigu.annotation; + +@Table("t_stu") +public class Student { + @Column(columnName = "sid",columnType = "int") + private int id; + @Column(columnName = "sname",columnType = "varchar(20)") + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Student{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } +} + +``` + +### 5.3 读取和处理自定义注解 + +自定义注解必须配上注解的信息处理流程才有意义。 + +我们自己定义的注解,只能使用反射的代码读取。所以自定义注解的声明周期必须是RetentionPolicy.RUNTIME。 + +```java +package com.atguigu.annotation; + +import java.lang.reflect.Field; + +public class TestAnnotation { + public static void main(String[] args) { + Class studentClass = Student.class; + Table tableAnnotation = (Table) studentClass.getAnnotation(Table.class); + String tableName = ""; + if(tableAnnotation != null){ + tableName = tableAnnotation.value(); + } + + Field[] declaredFields = studentClass.getDeclaredFields(); + String[] columns = new String[declaredFields.length]; + int index = 0; + for (Field declaredField : declaredFields) { + Column column = declaredField.getAnnotation(Column.class); + if(column!= null) { + columns[index++] = column.columnName(); + } + } + + String sql = "select "; + for (int i=0; i8->9 相比,Java 9->10->11的升级和 8->8u20->8u40 更相似。** + +新模式下的 Java 版本发布都会包含许多变更,包括`语言变更`和 `JVM 变更`,这两者都会对 IDE、字节码库和框架产生重大影响。此外,不仅会新增其他 API,还会有 `API被删除`(这在 Java 8 之前没有发生过)。 + +目前看这种发布策略是非常成功的,**解开了 Java/JVM 演进的许多枷锁,至关重要的是,OpenJDK 的权力中心,正在转移到开发社区和开发者手中。**在新的模式中,既可以利用 LTS 满足企业长期可靠支持的需求,也可以满足各种开发者对于新特性迭代的诉求。因为用 2-3 年的最小间隔粒度来试验一个特性,基本是不现实的。 + +### 1.2 名词解释 + +#### 名词解释:Oracle JDK和Open JDK + +这两个JDK最大不同就是许可证不一样。**但是对于个人用户来讲,没区别。** + +| | Oracle JDK | Open JDK | +| ------------ | ------------------------------------------------------------ | ------------------------- | +| 来源 | Oracle团队维护 | Oracle和Open Java社区 | +| 授权协议 | Java 17及更高版本 Oracle Java SE 许可证
Java16及更低版本甲骨文免费条款和条件 (NFTC) 许可协议 | GPL v2许可证 | +| 关系 | 由Open JDK构建,增加了少许内容 | | +| 是否收费 | 2021年9月起Java17及更高版本所有用户免费。 16及更低版本,个人用户、开发用户免费。 | 2017年9月起,所有版本免费 | +| 对语法的支持 | 一致 | 一致 | + +#### 名词解释:JEP + +JEP(JDK Enhancement Proposals):jdk 改进提案,每当需要有新的设想时候,JEP可以提出非正式的规范(specification),被正式认可的JEP正式写进JDK的发展路线图并分配版本号。 + +#### 名词解释:LTS + +LTS(Long-term Support)即长期支持。Oracle官网提供了对Oracle JDK个别版本的长期支持,即使发发行了新版本,比如目前最新的JDK19,在结束日期前,LTS版本都会被长期支持。(出了bug,会被修复,非LTS则不会再有补丁发布)所以,一定要选一个LTS版本,不然出了漏洞没人修复了。 + +| 版本 | 开始日期 | 结束日期 | 延期结束日期 | +| --------- | --------- | --------- | ------------ | +| 7(LTS) | 2011年7月 | 2019年7月 | 2022年7月 | +| 8(LTS) | 2014年3月 | 2022年3月 | 2030年12月 | +| 11(LTS) | 2018年9月 | 2023年9月 | 2026年9月 | +| 17(LTS) | 2021年9月 | 2026年9月 | 2029年9月 | +| 21(LTS) | 2023年9月 | 2028年9月 | 2031年9月 | + +如果要选择Oracle JDK,目前可选的LTS版本为8、11、17三个。 + +### 1.3 各版本支持时间路线图 + +![4428b288361296048](images/4428b288361296048.png) + +### 1.4 各版本介绍 + +![jdkxintexing](images/jdkxintexing.jpg) + +#### jdk 9 + +Java 9 提供了`超过150项`新功能特性,包括备受期待的模块化系统、可交互的 REPL 工具:jshell,JDK 编译工具,Java 公共 API 和私有代码,以及安全增强、扩展提升、性能管理改善等。 + +特性太多,查看链接: + +https://openjdk.java.net/projects/jdk9/ + +#### jdk 10 + +https://openjdk.java.net/projects/jdk/10/ + +> 286: [Local-Variable Type Inference](http://openjdk.java.net/jeps/286) 局部变量类型推断 +> 296: [Consolidate the JDK Forest into a Single Repository](http://openjdk.java.net/jeps/296) JDK库的合并 +> 304: [Garbage-Collector Interface](http://openjdk.java.net/jeps/304) 统一的垃圾回收接口 +> 307: [Parallel Full GC for G1](http://openjdk.java.net/jeps/307) 为G1提供并行的Full GC +> 310: [Application Class-Data Sharing](http://openjdk.java.net/jeps/310) 应用程序类数据(AppCDS)共享 +> 312: [Thread-Local Handshakes](http://openjdk.java.net/jeps/312) ThreadLocal握手交互 +> 313: [Remove the Native-Header Generation Tool (javah)](http://openjdk.java.net/jeps/313) 移除JDK中附带的javah工具 +> 314: [Additional Unicode Language-Tag Extensions](http://openjdk.java.net/jeps/314) 使用附加的Unicode语言标记扩展 +> 316: [Heap Allocation on Alternative Memory Devices](http://openjdk.java.net/jeps/316) 能将堆内存占用分配给用户指定的备用内存设备 +> 317: [Experimental Java-Based JIT Compiler](http://openjdk.java.net/jeps/317) 使用Graal基于Java的编译器 +> +> 319: [Root Certificates](http://openjdk.java.net/jeps/319) 根证书 +> 322: [Time-Based Release Versioning](http://openjdk.java.net/jeps/322) 基于时间定于的发布版本 + +#### jdk 11 + +https://openjdk.java.net/projects/jdk/11/ + +> 181: [Nest-Based Access Control](https://openjdk.java.net/jeps/181) 基于嵌套的访问控制 +> 309: [Dynamic Class-File Constants](https://openjdk.java.net/jeps/309) 动态类文件常量 +> 315: [Improve Aarch64 Intrinsics](https://openjdk.java.net/jeps/315) 改进 Aarch64 Intrinsics +> 318: [Epsilon: A No-Op Garbage Collector](https://openjdk.java.net/jeps/318) Epsilon — 一个No-Op(无操作)的垃圾收集器 +> 320: [Remove the Java EE and CORBA Modules](https://openjdk.java.net/jeps/320) 删除 Java EE 和 CORBA 模块 +> 321: [HTTP Client (Standard)](https://openjdk.java.net/jeps/321) HTTPClient API +> 323: [Local-Variable Syntax for Lambda Parameters](https://openjdk.java.net/jeps/323) 用于 Lambda 参数的局部变量语法 +> 324: [Key Agreement with Curve25519 and Curve448](https://openjdk.java.net/jeps/324) Curve25519 和 Curve448 算法的密钥协议 +> 327: [Unicode 10](https://openjdk.java.net/jeps/327) +> 328: [Flight Recorder](https://openjdk.java.net/jeps/328) 飞行记录仪 +> 329: [ChaCha20 and Poly1305 Cryptographic Algorithms](https://openjdk.java.net/jeps/329) ChaCha20 和 Poly1305 加密算法 +> 330: [Launch Single-File Source-Code Programs](https://openjdk.java.net/jeps/330) 启动单一文件的源代码程序 +> 331: [Low-Overhead Heap Profiling](https://openjdk.java.net/jeps/331) 低开销的 Heap Profiling +> 332: [Transport Layer Security (TLS) 1.3](https://openjdk.java.net/jeps/332) 支持 TLS 1.3 +> 333: [ZGC: A Scalable Low-Latency Garbage Collector +>    (Experimental)](https://openjdk.java.net/jeps/333) 可伸缩低延迟垃圾收集器 +> 335: [Deprecate the Nashorn JavaScript Engine](https://openjdk.java.net/jeps/335) 弃用 Nashorn JavaScript 引擎 +> 336: [Deprecate the Pack200 Tools and API](https://openjdk.java.net/jeps/336) 弃用 Pack200 工具和 API + +#### jdk 12 + +https://openjdk.java.net/projects/jdk/12/ + +> 189:[Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)](https://openjdk.java.net/jeps/189) 低暂停时间的GC +> 230: [Microbenchmark Suite](https://openjdk.java.net/jeps/230) 微基准测试套件 +> 325: [Switch Expressions (Preview)](https://openjdk.java.net/jeps/325) switch表达式 +> 334: [JVM Constants API ](https://openjdk.java.net/jeps/334) JVM常量API +> 340: [One AArch64 Port, Not Two](https://openjdk.java.net/jeps/340) 只保留一个AArch64实现 +> 341: [Default CDS Archives](https://openjdk.java.net/jeps/341) 默认类数据共享归档文件 +> 344: [Abortable Mixed Collections for G1](https://openjdk.java.net/jeps/344) 可中止的G1 Mixed GC +> 346: [Promptly Return Unused Committed Memory from G1](https://openjdk.java.net/jeps/346) G1及时返回未使用的已分配内存 + +#### jdk 13 + +https://openjdk.java.net/projects/jdk/13/ + +> 350: [Dynamic CDS Archives](https://openjdk.java.net/jeps/350) 动态CDS档案 +> 351: [ZGC: Uncommit Unused Memory](https://openjdk.java.net/jeps/351) ZGC:取消使用未使用的内存 +> 353: [Reimplement the Legacy Socket API](https://openjdk.java.net/jeps/353) 重新实现旧版套接字API +> 354: [Switch Expressions (Preview)](https://openjdk.java.net/jeps/354) switch表达式(预览) +> 355: [Text Blocks (Preview)](https://openjdk.java.net/jeps/355) 文本块(预览) + +#### jdk 14 + +https://openjdk.java.net/projects/jdk/14/ + +> 305: [Pattern Matching for instanceof (Preview)](https://openjdk.java.net/jeps/305) instanceof的模式匹配 +> 343: [Packaging Tool (Incubator)](https://openjdk.java.net/jeps/343) 打包工具 +> 345: [NUMA-Aware Memory Allocation for G1](https://openjdk.java.net/jeps/345) G1的NUMA-Aware内存分配 +> 349: [JFR Event Streaming](https://openjdk.java.net/jeps/349) JFR事件流 +> 352: [Non-Volatile Mapped Byte Buffers](https://openjdk.java.net/jeps/352) 非易失性映射字节缓冲区 +> 358: [Helpful NullPointerExceptions](https://openjdk.java.net/jeps/358) 实用的NullPointerExceptions +> 359: [Records (Preview)](https://openjdk.java.net/jeps/359) +> 361: [Switch Expressions (Standard)](https://openjdk.java.net/jeps/361) Switch表达式 +> 362: [Deprecate the Solaris and SPARC Ports](https://openjdk.java.net/jeps/362) 弃用Solaris和SPARC端口 +> 363: [Remove the Concurrent Mark Sweep (CMS) Garbage Collector](https://openjdk.java.net/jeps/363) 删除并发标记扫描(CMS)垃圾回收器 +> 364: [ZGC on macOS](https://openjdk.java.net/jeps/364) +> 365: [ZGC on Windows](https://openjdk.java.net/jeps/365) +> 366: [Deprecate the ParallelScavenge + SerialOld GC Combination](https://openjdk.java.net/jeps/366) 弃用ParallelScavenge + SerialOld GC组合 +> 367: [Remove the Pack200 Tools and API](https://openjdk.java.net/jeps/367) 删除Pack200工具和API +> 368: [Text Blocks (Second Preview)](https://openjdk.java.net/jeps/368) 文本块 +> 370: [Foreign-Memory Access API (Incubator)](https://openjdk.java.net/jeps/370) 外部存储器访问API + +#### jdk 15 + +https://openjdk.java.net/projects/jdk/15/ + +> 339: [Edwards-Curve Digital Signature Algorithm (EdDSA)](https://openjdk.java.net/jeps/339) EdDSA 数字签名算法 +> 360: [Sealed Classes (Preview)](https://openjdk.java.net/jeps/360) 密封类(预览) +> 371: [Hidden Classes](https://openjdk.java.net/jeps/371) 隐藏类 +> 372: [Remove the Nashorn JavaScript Engine](https://openjdk.java.net/jeps/372) 移除 Nashorn JavaScript 引擎 +> 373: [Reimplement the Legacy DatagramSocket API](https://openjdk.java.net/jeps/373) 重新实现 Legacy DatagramSocket API +> 374: [Disable and Deprecate Biased Locking](https://openjdk.java.net/jeps/374) 禁用偏向锁定 +> 375: [Pattern Matching for instanceof (Second Preview)](https://openjdk.java.net/jeps/375) instanceof 模式匹配(第二次预览) +> 377: [ZGC: A Scalable Low-Latency Garbage Collector](https://openjdk.java.net/jeps/377) ZGC:一个可扩展的低延迟垃圾收集器 +> 378: [Text Blocks](https://openjdk.java.net/jeps/378) 文本块 +> 379: [Shenandoah: A Low-Pause-Time Garbage Collector](https://openjdk.java.net/jeps/379) Shenandoah:低暂停时间垃圾收集器 +> 381: [Remove the Solaris and SPARC Ports](https://openjdk.java.net/jeps/381) 移除 Solaris 和 SPARC 端口 +> 383: [Foreign-Memory Access API (Second Incubator)](https://openjdk.java.net/jeps/383) 外部存储器访问 API(第二次孵化版) +> 384: [Records (Second Preview)](https://openjdk.java.net/jeps/384) Records(第二次预览) +> 385: [Deprecate RMI Activation for Removal](https://openjdk.java.net/jeps/385) 废弃 RMI 激活机制 + +#### jdk 16 + +https://openjdk.java.net/projects/jdk/16/ + +> 338: [Vector API (Incubator)](https://openjdk.java.net/jeps/338) Vector API(孵化器) +> 347: [Enable C++14 Language Features](https://openjdk.java.net/jeps/347) JDK C++的源码中允许使用C++14的语言特性 +> 357: [Migrate from Mercurial to Git](https://openjdk.java.net/jeps/357) OpenJDK源码的版本控制从Mercurial (hg) 迁移到git +> 369: [Migrate to GitHub](https://openjdk.java.net/jeps/369) OpenJDK源码的版本控制迁移到github上 +> 376: [ZGC: Concurrent Thread-Stack Processing](https://openjdk.java.net/jeps/376) ZGC:并发线程处理 +> 380: [Unix-Domain Socket Channels](https://openjdk.java.net/jeps/380) Unix域套接字通道 +> 386: [Alpine Linux Port](https://openjdk.java.net/jeps/386) 将glibc的jdk移植到使用musl的alpine linux上 +> 387: [Elastic Metaspace](https://openjdk.java.net/jeps/387) 弹性元空间 +> 388: [Windows/AArch64 Port](https://openjdk.java.net/jeps/388) 移植JDK到Windows/AArch64 +> 389: [Foreign Linker API (Incubator)](https://openjdk.java.net/jeps/389) 提供jdk.incubator.foreign来简化native code的调用 +> 390: [Warnings for Value-Based Classes](https://openjdk.java.net/jeps/390) 提供基于值的类的警告 +> 392: [Packaging Tool](https://openjdk.java.net/jeps/392) jpackage打包工具转正 +> 393: [Foreign-Memory Access API (Third Incubator)](https://openjdk.java.net/jeps/393) +> 394: [Pattern Matching for instanceof](https://openjdk.java.net/jeps/394) Instanceof的模式匹配转正 +> 395: [Records](https://openjdk.java.net/jeps/395) Records转正 +> 396: [Strongly Encapsulate JDK Internals by Default](https://openjdk.java.net/jeps/396) 默认情况下,封装了JDK内部构件 +> 397: [Sealed Classes (Second Preview)](https://openjdk.java.net/jeps/397) 密封类 + +#### jdk 17 + +https://openjdk.java.net/projects/jdk/17/ + +> 306: [Restore Always-Strict Floating-Point Semantics](https://openjdk.java.net/jeps/306) 恢复始终严格的浮点语义 +> +> 356: [Enhanced Pseudo-Random Number Generators](https://openjdk.java.net/jeps/356) 增强型伪随机数生成器 +> +> 382: [New macOS Rendering Pipeline](https://openjdk.java.net/jeps/382) 新的macOS渲染管道 +> +> 391: [macOS/AArch64 Port](https://openjdk.java.net/jeps/391) macOS/AArch64端口 +> +> 398: [Deprecate the Applet API for Removal](https://openjdk.java.net/jeps/398) 弃用Applet API后续将进行删除 +> +> 403: [Strongly Encapsulate JDK Internals](https://openjdk.java.net/jeps/403) 强封装JDK的内部API +> +> 406: [Pattern Matching for switch (Preview)](https://openjdk.java.net/jeps/406) switch模式匹配(预览) +> +> 407: [Remove RMI Activation](https://openjdk.java.net/jeps/407) 删除RMI激活机制 +> +> 409: [Sealed Classes](https://openjdk.java.net/jeps/409) 密封类转正 +> +> 410: [Remove the Experimental AOT and JIT Compiler](https://openjdk.java.net/jeps/410) 删除实验性的AOT和JIT编译器 +> +> 411: [Deprecate the Security Manager for Removal](https://openjdk.java.net/jeps/411) 弃用即将删除的安全管理器 +> +> 412: [Foreign Function & Memory API (Incubator)](https://openjdk.java.net/jeps/412) 外部函数和内存API(孵化特性) +> +> 414: [Vector API (Second Incubator)](https://openjdk.java.net/jeps/414) Vector API(第二次孵化特性) +> +> 415: [Context-Specific Deserialization Filters](https://openjdk.java.net/jeps/415) 上下文特定的反序列化过滤器 + +### 1.5 JDK各版本下载链接 + +```http +https://www.oracle.com/java/technologies/downloads/archive/ +``` + +image-20220525200441935 + +> 链接:https://pan.baidu.com/s/15QrBUOvfE9vjlTzN_EeVLg +> 提取码:yyds + +![image-20221213235332866](images/image-20221213235332866.png) + +### 1.6 如何学习新特性 + +对于新特性,我们应该从哪几个角度学习新特性呢? + +- 语法层面: + + - 比如JDK5中的自动拆箱、自动装箱、enum、泛型 + - 比如JDK8中的lambda表达式、接口中的默认方法、静态方法 + - 比如JDK10中局部变量的类型推断 + - 比如JDK12中的switch + - 比如JDK13中的文本块 + +- API层面: + + - 比如JDK8中的Stream、Optional、新的日期时间、HashMap的底层结构 + - 比如JDK9中String的底层结构 + - 新的 / 过时的 API + +- 底层优化 + + - 比如JDK8中永久代被元空间替代、新的JS执行引擎 + + - 比如新的垃圾回收器、GC参数、JVM的优化 + + +## 2. Java8新特性:Lambda表达式 + +### 2.1 关于Java8新特性简介 + +Java 8 (又称为 JDK 8或JDK1.8) 是 Java 语言开发的一个主要版本。 Java 8 是oracle公司于2014年3月发布,可以看成是自Java 5 以来最具革命性的版本。Java 8为Java语言、编译器、类库、开发工具与JVM带来了大量新特性。 + +image-20220525201653599 + +- 速度更快 + +- 代码更少(增加了新的语法:**Lambda** **表达式**) + +- 强大的 **Stream API** + +- 便于并行 + - **并行流**就是把一个内容分成多个数据块,并用不同的线程分别处理每个数据块的流。相比较串行的流,并行的流可以很大程度上提高程序的执行效率。 + - Java 8 中将并行进行了优化,我们可以很容易的对数据进行并行操作。Stream API 可以声明性地通过 parallel() 与 sequential() 在并行流与顺序流之间进行切换。 + +- 最大化减少空指针异常:Optional + +- Nashorn引擎,允许在JVM上运行JS应用 + - 发音“nass-horn”,是德国二战时一个坦克的命名 + - javascript运行在jvm已经不是新鲜事了,Rhino早在jdk6的时候已经存在。现在替代Rhino,官方的解释是Rhino相比其他JavaScript引擎(比如google的V8)实在太慢了,改造Rhino还不如重写。所以Nashorn的性能也是其一个亮点。 + - Nashorn 项目在 JDK 9 中得到改进;在JDK11 中`Deprecated`,后续JDK15版本中`remove`。在JDK11中取以代之的是GraalVM。(GraalVM是一个运行时平台,它支持Java和其他基于Java字节码的语言,但也支持其他语言,如JavaScript,Ruby,Python或LLVM。性能是Nashorn的2倍以上。) + +### 2.2 冗余的匿名内部类 + +当需要启动一个线程去完成任务时,通常会通过`java.lang.Runnable`接口来定义任务内容,并使用`java.lang.Thread`类来启动该线程。代码如下: + +```java +package com.atguigu.fp; + +public class UseFunctionalProgramming { + public static void main(String[] args) { + new Thread(new Runnable() { + @Override + public void run() { + System.out.println("多线程任务执行!"); + } + }).start(); // 启动线程 + } +} +``` + +本着“一切皆对象”的思想,这种做法是无可厚非的:首先创建一个`Runnable`接口的匿名内部类对象来指定任务内容,再将其交给一个线程来启动。 + +**代码分析:** + +对于`Runnable`的匿名内部类用法,可以分析出几点内容: + +* `Thread`类需要`Runnable`接口作为参数,其中的抽象`run`方法是用来指定线程任务内容的核心; +* 为了指定`run`的方法体,**不得不**需要`Runnable`接口的实现类; +* 为了省去定义一个`RunnableImpl`实现类的麻烦,**不得不**使用匿名内部类; +* 必须覆盖重写抽象`run`方法,所以方法名称、方法参数、方法返回值**不得不**再写一遍,且不能写错; +* 而实际上,**似乎只有方法体才是关键所在**。 + +### 2.3 好用的lambda表达式 + +lambda表达式 + +![image-20221111213355625](images/image-20221111213355625.png) + +### 2.4 Lambda 及其使用举例 + +Lambda 是一个**匿名函数**,我们可以把 Lambda 表达式理解为是**一段可以传递的代码**(将代码像数据一样进行传递)。使用它可以写出更简洁、更灵活的代码。作为一种更紧凑的代码风格,使Java的语言表达能力得到了提升。 + +- 从匿名类到 Lambda 的转换举例1 + +image-20220527101737072 + +- 从匿名类到 Lambda 的转换举例2 + +image-20220527101814203 + +### 2.5 语法 + +Lambda 表达式:在Java 8 语言中引入的一种新的语法元素和操作符。这个操作符为 “`->`” , 该操作符被称为 `Lambda 操作符`或`箭头操作符`。它将 Lambda 分为两个部分: + +- 左侧:指定了 Lambda 表达式需要的参数列表 +- 右侧:指定了 Lambda 体,是抽象方法的实现逻辑,也即 Lambda 表达式要执行的功能。 + +**语法格式一:**无参,无返回值 + +```java +@Test +public void test1(){ + //未使用Lambda表达式 + Runnable r1 = new Runnable() { + @Override + public void run() { + System.out.println("我爱北京天安门"); + } + }; + + r1.run(); + + System.out.println("***********************"); + + //使用Lambda表达式 + Runnable r2 = () -> { + System.out.println("我爱北京故宫"); + }; + + r2.run(); +} +``` + + + +**语法格式二:**Lambda 需要一个参数,但是没有返回值。 + +```java +@Test +public void test2(){ + //未使用Lambda表达式 + Consumer con = new Consumer() { + @Override + public void accept(String s) { + System.out.println(s); + } + }; + con.accept("谎言和誓言的区别是什么?"); + + System.out.println("*******************"); + + //使用Lambda表达式 + Consumer con1 = (String s) -> { + System.out.println(s); + }; + con1.accept("一个是听得人当真了,一个是说的人当真了"); + +} +``` + + + +**语法格式三:**数据类型可以省略,因为可由编译器推断得出,称为“类型推断” + +```java +@Test +public void test3(){ + //语法格式三使用前 + Consumer con1 = (String s) -> { + System.out.println(s); + }; + con1.accept("一个是听得人当真了,一个是说的人当真了"); + + System.out.println("*******************"); + //语法格式三使用后 + Consumer con2 = (s) -> { + System.out.println(s); + }; + con2.accept("一个是听得人当真了,一个是说的人当真了"); + +} +``` + + + +**语法格式四:**Lambda 若只需要一个参数时,参数的小括号可以省略 + +```java +@Test +public void test4(){ + //语法格式四使用前 + Consumer con1 = (s) -> { + System.out.println(s); + }; + con1.accept("一个是听得人当真了,一个是说的人当真了"); + + System.out.println("*******************"); + //语法格式四使用后 + Consumer con2 = s -> { + System.out.println(s); + }; + con2.accept("一个是听得人当真了,一个是说的人当真了"); + + +} +``` + + + +**语法格式五:**Lambda 需要两个或以上的参数,多条执行语句,并且可以有返回值 + +```java +@Test +public void test5(){ + //语法格式五使用前 + Comparator com1 = new Comparator() { + @Override + public int compare(Integer o1, Integer o2) { + System.out.println(o1); + System.out.println(o2); + return o1.compareTo(o2); + } + }; + + System.out.println(com1.compare(12,21)); + System.out.println("*****************************"); + //语法格式五使用后 + Comparator com2 = (o1,o2) -> { + System.out.println(o1); + System.out.println(o2); + return o1.compareTo(o2); + }; + + System.out.println(com2.compare(12,6)); + + +} +``` + + + +**语法格式六:**当 Lambda 体只有一条语句时,return 与大括号若有,都可以省略 + +```java +@Test +public void test6(){ + //语法格式六使用前 + Comparator com1 = (o1,o2) -> { + return o1.compareTo(o2); + }; + + System.out.println(com1.compare(12,6)); + + System.out.println("*****************************"); + //语法格式六使用后 + Comparator com2 = (o1,o2) -> o1.compareTo(o2); + + System.out.println(com2.compare(12,21)); + +} + +@Test +public void test7(){ + //语法格式六使用前 + Consumer con1 = s -> { + System.out.println(s); + }; + con1.accept("一个是听得人当真了,一个是说的人当真了"); + + System.out.println("*****************************"); + //语法格式六使用后 + Consumer con2 = s -> System.out.println(s); + + con2.accept("一个是听得人当真了,一个是说的人当真了"); + +} +``` + +### 2.6 关于类型推断 + +在语法格式三 Lambda 表达式中的参数类型都是由编译器推断得出的。Lambda 表达式中无需指定类型,程序依然可以编译,这是因为 javac 根据程序的上下文,在后台推断出了参数的类型。Lambda 表达式的类型依赖于上下文环境,是由编译器推断出来的。这就是所谓的“`类型推断`”。 + +image-20220527103215741 + +举例: + +```java +@Test +public void test() { + //类型推断1 + ArrayList list = new ArrayList<>(); + //类型推断2 + int[] arr = {1, 2, 3}; + +} +``` + + + +## 3. Java8新特性:函数式(Functional)接口 + +### 3.1 什么是函数式接口 + +- 只包含`一个抽象方法`(Single Abstract Method,简称SAM)的接口,称为函数式接口。当然该接口可以包含其他非抽象方法。 +- 你可以通过 Lambda 表达式来创建该接口的对象。(若 Lambda 表达式抛出一个受检异常(即:非运行时异常),那么该异常需要在目标接口的抽象方法上进行声明)。 +- 我们可以在一个接口上使用 `@FunctionalInterface` 注解,这样做可以检查它是否是一个函数式接口。同时 javadoc 也会包含一条声明,说明这个接口是一个函数式接口。 +- 在`java.util.function`包下定义了Java 8 的丰富的函数式接口 + +### 3.2 如何理解函数式接口 + +![](images/03-Overview.png) + +- Java从诞生日起就是一直倡导“一切皆对象”,在Java里面面向对象(OOP)编程是一切。但是随着python、scala等语言的兴起和新技术的挑战,Java不得不做出调整以便支持更加广泛的技术要求,即Java不但可以支持OOP还可以支持OOF(面向函数编程) + - Java8引入了Lambda表达式之后,Java也开始支持函数式编程。 + - Lambda表达式不是Java最早使用的。目前C++,C#,Python,Scala等均支持Lambda表达式。 +- 面向对象的思想: + * 做一件事情,找一个能解决这个事情的对象,调用对象的方法,完成事情。 +- 函数式编程思想: + * 只要能获取到结果,谁去做的,怎么做的都不重要,重视的是结果,不重视过程。 +- 在函数式编程语言当中,函数被当做一等公民对待。在将函数作为一等公民的编程语言中,Lambda表达式的类型是函数。但是在Java8中,有所不同。在Java8中,Lambda表达式是对象,而不是函数,它们必须依附于一类特别的对象类型——函数式接口。 +- 简单的说,在Java8中,Lambda表达式就是一个函数式接口的实例。这就是Lambda表达式和函数式接口的关系。也就是说,只要一个对象是函数式接口的实例,那么该对象就可以用Lambda表达式来表示。 + +### 3.3 举例 + +举例1: + +image-20220527111442115 + +举例2: + +image-20220527111621424 + +作为参数传递 Lambda 表达式: + +image-20220527111751485 + +> 作为参数传递 Lambda 表达式:为了将 Lambda 表达式作为参数传递,接收Lambda 表达式的参数类型必须是与该 Lambda 表达式兼容的函数式接口的类型。 + +### 3.4 Java 内置函数式接口 + +#### 3.4.1 之前的函数式接口 + +之前学过的接口,有些就是函数式接口,比如: + +- java.lang.Runnable + - public void run() +- java.lang.Iterable + - public Iterator iterate() +- java.lang.Comparable + - public int compareTo(T t) +- java.util.Comparator + - public int compare(T t1, T t2) + +#### 3.4.2 四大核心函数式接口 + +| 函数式接口 | 称谓 | 参数类型 | 用途 | +| ------------------ | ---------- | -------- | ------------------------------------------------------------ | +| `Consumer ` | 消费型接口 | T | 对类型为T的对象应用操作,包含方法: `void accept(T t) ` | +| `Supplier ` | 供给型接口 | 无 | 返回类型为T的对象,包含方法:`T get() ` | +| `Function ` | 函数型接口 | T | 对类型为T的对象应用操作,并返回结果。结果是R类型的对象。包含方法:`R apply(T t) ` | +| `Predicate ` | 判断型接口 | T | 确定类型为T的对象是否满足某约束,并返回 boolean 值。包含方法:`boolean test(T t) ` | + +#### 3.4.3 其它接口 + +**类型1:消费型接口** + +消费型接口的抽象方法特点:有形参,但是返回值类型是void + +| 接口名 | 抽象方法 | 描述 | +| -------------------- | ------------------------------ | -------------------------- | +| BiConsumer | void accept(T t, U u) | 接收两个对象用于完成功能 | +| DoubleConsumer | void accept(double value) | 接收一个double值 | +| IntConsumer | void accept(int value) | 接收一个int值 | +| LongConsumer | void accept(long value) | 接收一个long值 | +| ObjDoubleConsumer | void accept(T t, double value) | 接收一个对象和一个double值 | +| ObjIntConsumer | void accept(T t, int value) | 接收一个对象和一个int值 | +| ObjLongConsumer | void accept(T t, long value) | 接收一个对象和一个long值 | + +**类型2:供给型接口** + +这类接口的抽象方法特点:无参,但是有返回值 + +| 接口名 | 抽象方法 | 描述 | +| --------------- | ---------------------- | ----------------- | +| BooleanSupplier | boolean getAsBoolean() | 返回一个boolean值 | +| DoubleSupplier | double getAsDouble() | 返回一个double值 | +| IntSupplier | int getAsInt() | 返回一个int值 | +| LongSupplier | long getAsLong() | 返回一个long值 | + +**类型3:函数型接口** + +这类接口的抽象方法特点:既有参数又有返回值 + +| 接口名 | 抽象方法 | 描述 | +| ----------------------- | ----------------------------------------------- | --------------------------------------------------- | +| UnaryOperator | T apply(T t) | 接收一个T类型对象,返回一个T类型对象结果 | +| DoubleFunction | R apply(double value) | 接收一个double值,返回一个R类型对象 | +| IntFunction | R apply(int value) | 接收一个int值,返回一个R类型对象 | +| LongFunction | R apply(long value) | 接收一个long值,返回一个R类型对象 | +| ToDoubleFunction | double applyAsDouble(T value) | 接收一个T类型对象,返回一个double | +| ToIntFunction | int applyAsInt(T value) | 接收一个T类型对象,返回一个int | +| ToLongFunction | long applyAsLong(T value) | 接收一个T类型对象,返回一个long | +| DoubleToIntFunction | int applyAsInt(double value) | 接收一个double值,返回一个int结果 | +| DoubleToLongFunction | long applyAsLong(double value) | 接收一个double值,返回一个long结果 | +| IntToDoubleFunction | double applyAsDouble(int value) | 接收一个int值,返回一个double结果 | +| IntToLongFunction | long applyAsLong(int value) | 接收一个int值,返回一个long结果 | +| LongToDoubleFunction | double applyAsDouble(long value) | 接收一个long值,返回一个double结果 | +| LongToIntFunction | int applyAsInt(long value) | 接收一个long值,返回一个int结果 | +| DoubleUnaryOperator | double applyAsDouble(double operand) | 接收一个double值,返回一个double | +| IntUnaryOperator | int applyAsInt(int operand) | 接收一个int值,返回一个int结果 | +| LongUnaryOperator | long applyAsLong(long operand) | 接收一个long值,返回一个long结果 | +| BiFunction | R apply(T t, U u) | 接收一个T类型和一个U类型对象,返回一个R类型对象结果 | +| BinaryOperator | T apply(T t, T u) | 接收两个T类型对象,返回一个T类型对象结果 | +| ToDoubleBiFunction | double applyAsDouble(T t, U u) | 接收一个T类型和一个U类型对象,返回一个double | +| ToIntBiFunction | int applyAsInt(T t, U u) | 接收一个T类型和一个U类型对象,返回一个int | +| ToLongBiFunction | long applyAsLong(T t, U u) | 接收一个T类型和一个U类型对象,返回一个long | +| DoubleBinaryOperator | double applyAsDouble(double left, double right) | 接收两个double值,返回一个double结果 | +| IntBinaryOperator | int applyAsInt(int left, int right) | 接收两个int值,返回一个int结果 | +| LongBinaryOperator | long applyAsLong(long left, long right) | 接收两个long值,返回一个long结果 | + +**类型4:判断型接口** + +这类接口的抽象方法特点:有参,但是返回值类型是boolean结果。 + +| 接口名 | 抽象方法 | 描述 | +| ---------------- | -------------------------- | ---------------- | +| BiPredicate | boolean test(T t, U u) | 接收两个对象 | +| DoublePredicate | boolean test(double value) | 接收一个double值 | +| IntPredicate | boolean test(int value) | 接收一个int值 | +| LongPredicate | boolean test(long value) | 接收一个long值 | + +#### 3.4.4 内置接口代码演示 + +举例1: + +```java +package com.atguigu.four; + +import java.util.Arrays; +import java.util.List; + +public class TestConsumer { + public static void main(String[] args) { + List list = Arrays.asList("java","c","python","c++","VB","C#"); + //遍历Collection集合,并将传递给action参数的操作代码应用在每一个元素上。 + list.forEach(s -> System.out.println(s)); + } +} +``` + +举例2: + +```java +package com.atguigu.four; + +import java.util.function.Supplier; + +public class TestSupplier { + public static void main(String[] args) { + Supplier supplier = () -> "尚硅谷"; + System.out.println(supplier.get()); + } +} +``` + +举例3: + +```java +package com.atguigu.four; + +import java.util.ArrayList; + +public class TestPredicate { + public static void main(String[] args) { + ArrayList list = new ArrayList<>(); + list.add("hello"); + list.add("java"); + list.add("atguigu"); + list.add("ok"); + list.add("yes"); + + System.out.println("删除之前:"); + list.forEach(t-> System.out.println(t)); + + //用于删除集合中满足filter指定的条件判断的。 + //删除包含o字母的元素 + list.removeIf(s -> s.contains("o")); + + System.out.println("删除包含o字母的元素之后:"); + list.forEach(t-> System.out.println(t)); + } +} +``` + +举例4: + +```java +package com.atguigu.four; + +import java.util.function.Function; + +public class TestFunction { + public static void main(String[] args) { + //使用Lambda表达式实现Function接口,可以实现将一个字符串首字母转为大写的功能。 + Function fun = s -> s.substring(0,1).toUpperCase() + s.substring(1); + System.out.println(fun.apply("hello")); + } +} + +``` + +#### 3.4.5 练习 + +**练习1:无参无返回值形式** + +假如有自定义函数式接口Call如下: + +```java +public interface Call { + void shout(); +} +``` + +在测试类中声明一个如下方法: + +```java +public static void callSomething(Call call){ + call.shout(); +} +``` + +在测试类的main方法中调用callSomething方法,并用Lambda表达式为形参call赋值,可以喊出任意你想说的话。 + +```java +public class TestLambda { + public static void main(String[] args) { + callSomething(()->System.out.println("回家吃饭")); + callSomething(()->System.out.println("我爱你")); + callSomething(()->System.out.println("滚蛋")); + callSomething(()->System.out.println("回来")); + } + public static void callSomething(Call call){ + call.shout(); + } +} +interface Call { + void shout(); +} +``` + +**练习2:消费型接口** + +代码示例:Consumer接口 + +在JDK1.8中Collection集合接口的父接口Iterable接口中增加了一个默认方法: + +`public default void forEach(Consumer action) `遍历Collection集合的每个元素,执行“xxx消费型”操作。 + +在JDK1.8中Map集合接口中增加了一个默认方法: + +`public default void forEach(BiConsumer action)`遍历Map集合的每对映射关系,执行“xxx消费型”操作。 + +案例: + +(1)创建一个Collection系列的集合,添加一些字符串,调用forEach方法遍历查看 + +(2)创建一个Map系列的集合,添加一些(key,value)键值对,调用forEach方法遍历查看 + +示例代码: + +```java + @Test + public void test1(){ + List list = Arrays.asList("hello","java","lambda","atguigu"); + list.forEach(s -> System.out.println(s)); + } + @Test + public void test2(){ + HashMap map = new HashMap<>(); + map.put(1, "hello"); + map.put(2, "java"); + map.put(3, "lambda"); + map.put(4, "atguigu"); + map.forEach((k,v) -> System.out.println(k+"->"+v)); + } +``` + +**练习3:供给型接口** + +代码示例:Supplier接口 + +在JDK1.8中增加了StreamAPI,java.util.stream.Stream是一个数据流。这个类型有一个静态方法: + +`public static Stream generate(Supplier s)`可以创建Stream的对象。而又包含一个forEach方法可以遍历流中的元素:`public void forEach(Consumer action)`。 + +案例: + +现在请调用Stream的generate方法,来产生一个流对象,并调用Math.random()方法来产生数据,为Supplier函数式接口的形参赋值。最后调用forEach方法遍历流中的数据查看结果。 + +```java + @Test + public void test2(){ + Stream.generate(() -> Math.random()).forEach(num -> System.out.println(num)); + } +``` + +**练习4:功能型接口** + +代码示例:Function接口 + +在JDK1.8时Map接口增加了很多方法,例如: + +`public default void replaceAll(BiFunction function) `按照function指定的操作替换map中的value。 + +`public default void forEach(BiConsumer action)`遍历Map集合的每对映射关系,执行“xxx消费型”操作。 + +案例: + +(1)声明一个Employee员工类型,包含编号、姓名、薪资。 + +(2)添加n个员工对象到一个HashMap集合中,其中员工编号为key,员工对象为value。 + +(3)调用Map的forEach遍历集合 + +(4)调用Map的replaceAll方法,将其中薪资低于10000元的,薪资设置为10000。 + +(5)再次调用Map的forEach遍历集合查看结果 + +Employee类: + +```java +class Employee{ + private int id; + private String name; + private double salary; + public Employee(int id, String name, double salary) { + super(); + this.id = id; + this.name = name; + this.salary = salary; + } + public Employee() { + super(); + } + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public double getSalary() { + return salary; + } + public void setSalary(double salary) { + this.salary = salary; + } + @Override + public String toString() { + return "Employee [id=" + id + ", name=" + name + ", salary=" + salary + "]"; + } + +} +``` + +测试类: + +```java +import java.util.HashMap; + +public class TestLambda { + public static void main(String[] args) { + HashMap map = new HashMap<>(); + Employee e1 = new Employee(1, "张三", 8000); + Employee e2 = new Employee(2, "李四", 9000); + Employee e3 = new Employee(3, "王五", 10000); + Employee e4 = new Employee(4, "赵六", 11000); + Employee e5 = new Employee(5, "钱七", 12000); + + map.put(e1.getId(), e1); + map.put(e2.getId(), e2); + map.put(e3.getId(), e3); + map.put(e4.getId(), e4); + map.put(e5.getId(), e5); + + map.forEach((k,v) -> System.out.println(k+"="+v)); + System.out.println(); + + map.replaceAll((k,v)->{ + if(v.getSalary()<10000){ + v.setSalary(10000); + } + return v; + }); + map.forEach((k,v) -> System.out.println(k+"="+v)); + } +} +``` + +**练习5:判断型接口** + +代码示例:Predicate接口 + +JDK1.8时,Collecton接口增加了一下方法,其中一个如下: + +`public default boolean removeIf(Predicate filter)` 用于删除集合中满足filter指定的条件判断的。 + +`public default void forEach(Consumer action) `遍历Collection集合的每个元素,执行“xxx消费型”操作。 + +案例: + +(1)添加一些字符串到一个Collection集合中 + +(2)调用forEach遍历集合 + +(3)调用removeIf方法,删除其中字符串的长度<5的 + +(4)再次调用forEach遍历集合 + +```java +import java.util.ArrayList; + +public class TestLambda { + public static void main(String[] args) { + ArrayList list = new ArrayList<>(); + list.add("hello"); + list.add("java"); + list.add("atguigu"); + list.add("ok"); + list.add("yes"); + + list.forEach(str->System.out.println(str)); + System.out.println(); + + list.removeIf(str->str.length()<5); + list.forEach(str->System.out.println(str)); + } +} +``` + +**练习6:判断型接口** + +案例: + +(1)声明一个Employee员工类型,包含编号、姓名、性别,年龄,薪资。 + +(2)声明一个EmployeeSerice员工管理类,包含一个ArrayList集合的属性all,在EmployeeSerice的构造器中,创建一些员工对象,为all集合初始化。 + +(3)在EmployeeSerice员工管理类中,声明一个方法:ArrayList get(Predicate p),即将满足p指定的条件的员工,添加到一个新的ArrayList 集合中返回。 + +(4)在测试类中创建EmployeeSerice员工管理类的对象,并调用get方法,分别获取: + +* 所有员工对象 +* 所有年龄超过35的员工 +* 所有薪资高于15000的女员工 +* 所有编号是偶数的员工 +* 名字是“张三”的员工 +* 年龄超过25,薪资低于10000的男员工 + +示例代码: + +Employee类: + +```java +public class Employee{ + private int id; + private String name; + private char gender; + private int age; + private double salary; + + public Employee(int id, String name, char gender, int age, double salary) { + super(); + this.id = id; + this.name = name; + this.gender = gender; + this.age = age; + this.salary = salary; + } + public Employee() { + super(); + } + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public double getSalary() { + return salary; + } + public void setSalary(double salary) { + this.salary = salary; + } + @Override + public String toString() { + return "Employee [id=" + id + ", name=" + name + ", gender=" + gender + ", age=" + age + ", salary=" + salary + + "]"; + } +} +``` + +员工管理类: + +```java +class EmployeeService{ + private ArrayList all; + public EmployeeService(){ + all = new ArrayList(); + all.add(new Employee(1, "张三", '男', 33, 8000)); + all.add(new Employee(2, "翠花", '女', 23, 18000)); + all.add(new Employee(3, "无能", '男', 46, 8000)); + all.add(new Employee(4, "李四", '女', 23, 9000)); + all.add(new Employee(5, "老王", '男', 23, 15000)); + all.add(new Employee(6, "大嘴", '男', 23, 11000)); + } + public ArrayList get(Predicate p){ + ArrayList result = new ArrayList(); + for (Employee emp : result) { + if(p.test(emp)){ + result.add(emp); + } + } + return result; + } +} +``` + +测试类: + +```java +public class TestLambda { + public static void main(String[] args) { + EmployeeService es = new EmployeeService(); + + es.get(e -> true).forEach(e->System.out.println(e)); + System.out.println(); + es.get(e -> e.getAge()>35).forEach(e->System.out.println(e)); + System.out.println(); + es.get(e -> e.getSalary()>15000 && e.getGender()=='女').forEach(e->System.out.println(e)); + System.out.println(); + es.get(e -> e.getId()%2==0).forEach(e->System.out.println(e)); + System.out.println(); + es.get(e -> "张三".equals(e.getName())).forEach(e->System.out.println(e)); + System.out.println(); + es.get(e -> e.getAge()>25 && e.getSalary()<10000 && e.getGender()=='男').forEach(e->System.out.println(e)); + } +} +``` + +## 4. Java8新特性:方法引用与构造器引用 + +Lambda表达式是可以简化函数式接口的变量或形参赋值的语法。而方法引用和构造器引用是为了简化Lambda表达式的。 + +### 4.1 方法引用 + +当要传递给Lambda体的操作,已经有实现的方法了,可以使用方法引用! + +方法引用可以看做是Lambda表达式深层次的表达。换句话说,方法引用就是Lambda表达式,也就是函数式接口的一个实例,通过方法的名字来指向一个方法,可以认为是Lambda表达式的一个语法糖。 + +> 语法糖(Syntactic sugar),也译为糖衣语法,是由英国计算机科学家彼得·约翰·兰达(Peter J. Landin)发明的一个术语,指计算机语言中添加的某种语法,这种语法`对语言的功能并没有影响,但是更方便程序员使用`。通常来说使用语法糖能够增加程序的可读性,从而减少程序代码出错的机会。 + +#### 4.1.1 方法引用格式 + +- 格式:使用方法引用操作符 “`::`” 将类(或对象) 与 方法名分隔开来。 + - 两个:中间不能有空格,而且必须英文状态下半角输入 + +- 如下三种主要使用情况: + - 情况1:`对象 :: 实例方法名` + - 情况2:`类 :: 静态方法名` + - 情况3:`类 :: 实例方法名` + +#### 4.1.2 方法引用使用前提 + +**要求1:**Lambda体只有一句语句,并且是通过调用一个对象的/类现有的方法来完成的 + +例如:System.out对象,调用println()方法来完成Lambda体 + +​ Math类,调用random()静态方法来完成Lambda体 + +**要求2:** + +针对情况1:函数式接口中的抽象方法a在被重写时使用了某一个对象的方法b。如果方法a的形参列表、返回值类型与方法b的形参列表、返回值类型都相同,则我们可以使用方法b实现对方法a的重写、替换。 + + +针对情况2:函数式接口中的抽象方法a在被重写时使用了某一个类的静态方法b。如果方法a的形参列表、返回值类型与方法b的形参列表、返回值类型都相同,则我们可以使用方法b实现对方法a的重写、替换。 + +针对情况3:函数式接口中的抽象方法a在被重写时使用了某一个对象的方法b。如果方法a的返回值类型与方法b的返回值类型相同,同时方法a的形参列表中有n个参数,方法b的形参列表有n-1个参数,且方法a的第1个参数作为方法b的调用者,且方法a的后n-1参数与方法b的n-1参数匹配(类型相同或满足多态场景也可以) + +例如:t->System.out.println(t) + +​ () -> Math.random() 都是无参 + +#### 4.1.3 举例 + +```java +public class MethodRefTest { + + // 情况一:对象 :: 实例方法 + //Consumer中的void accept(T t) + //PrintStream中的void println(T t) + @Test + public void test1() { + Consumer con1 = str -> System.out.println(str); + con1.accept("北京"); + + System.out.println("*******************"); + PrintStream ps = System.out; + Consumer con2 = ps::println; + con2.accept("beijing"); + } + + //Supplier中的T get() + //Employee中的String getName() + @Test + public void test2() { + Employee emp = new Employee(1001,"Tom",23,5600); + + Supplier sup1 = () -> emp.getName(); + System.out.println(sup1.get()); + + System.out.println("*******************"); + Supplier sup2 = emp::getName; + System.out.println(sup2.get()); + + } + + // 情况二:类 :: 静态方法 + //Comparator中的int compare(T t1,T t2) + //Integer中的int compare(T t1,T t2) + @Test + public void test3() { + Comparator com1 = (t1,t2) -> Integer.compare(t1,t2); + System.out.println(com1.compare(12,21)); + + System.out.println("*******************"); + + Comparator com2 = Integer::compare; + System.out.println(com2.compare(12,3)); + + } + + //Function中的R apply(T t) + //Math中的Long round(Double d) + @Test + public void test4() { + Function func = new Function() { + @Override + public Long apply(Double d) { + return Math.round(d); + } + }; + + System.out.println("*******************"); + + Function func1 = d -> Math.round(d); + System.out.println(func1.apply(12.3)); + + System.out.println("*******************"); + + Function func2 = Math::round; + System.out.println(func2.apply(12.6)); + } + + // 情况三:类 :: 实例方法 (有难度) + // Comparator中的int comapre(T t1,T t2) + // String中的int t1.compareTo(t2) + @Test + public void test5() { + Comparator com1 = (s1,s2) -> s1.compareTo(s2); + System.out.println(com1.compare("abc","abd")); + + System.out.println("*******************"); + + Comparator com2 = String :: compareTo; + System.out.println(com2.compare("abd","abm")); + } + + //BiPredicate中的boolean test(T t1, T t2); + //String中的boolean t1.equals(t2) + @Test + public void test6() { + BiPredicate pre1 = (s1,s2) -> s1.equals(s2); + System.out.println(pre1.test("abc","abc")); + + System.out.println("*******************"); + BiPredicate pre2 = String :: equals; + System.out.println(pre2.test("abc","abd")); + } + + // Function中的R apply(T t) + // Employee中的String getName(); + @Test + public void test7() { + Employee employee = new Employee(1001, "Jerry", 23, 6000); + + + Function func1 = e -> e.getName(); + System.out.println(func1.apply(employee)); + + System.out.println("*******************"); + Function func2 = Employee::getName; + System.out.println(func2.apply(employee)); + } + +} +``` + +### 4.2 构造器引用 + +当Lambda表达式是创建一个对象,并且满足Lambda表达式形参,正好是给创建这个对象的构造器的实参列表,就可以使用构造器引用。 + +格式:`类名::new` + +举例: + +```java +public class ConstructorRefTest { + //构造器引用 + //Supplier中的T get() + //Employee的空参构造器:Employee() + @Test + public void test1(){ + + Supplier sup = new Supplier() { + @Override + public Employee get() { + return new Employee(); + } + }; + System.out.println("*******************"); + + Supplier sup1 = () -> new Employee(); + System.out.println(sup1.get()); + + System.out.println("*******************"); + + Supplier sup2 = Employee :: new; + System.out.println(sup2.get()); + } + + //Function中的R apply(T t) + @Test + public void test2(){ + Function func1 = id -> new Employee(id); + Employee employee = func1.apply(1001); + System.out.println(employee); + + System.out.println("*******************"); + + Function func2 = Employee :: new; + Employee employee1 = func2.apply(1002); + System.out.println(employee1); + + } + + //BiFunction中的R apply(T t,U u) + @Test + public void test3(){ + BiFunction func1 = (id,name) -> new Employee(id,name); + System.out.println(func1.apply(1001,"Tom")); + + System.out.println("*******************"); + + BiFunction func2 = Employee :: new; + System.out.println(func2.apply(1002,"Tom")); + + } + +} +``` + +```java +package com.atguigu.java2; + +/** + * @author 尚硅谷-宋红康 邮箱:shkstart@126.com + */ +public class Employee { + + private int id; + private String name; + private int age; + private double salary; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + + public Employee() { + System.out.println("Employee()....."); + } + + public Employee(int id) { + this.id = id; + System.out.println("Employee(int id)....."); + } + + public Employee(int id, String name) { + this.id = id; + this.name = name; + } + + public Employee(int id, String name, int age, double salary) { + + this.id = id; + this.name = name; + this.age = age; + this.salary = salary; + } + + @Override + public String toString() { + return "Employee{" + "id=" + id + ", name='" + name + '\'' + ", age=" + age + ", salary=" + salary + '}'; + } + +} + +``` + +### 4.3 数组构造引用 + +当Lambda表达式是创建一个数组对象,并且满足Lambda表达式形参,正好是给创建这个数组对象的长度,就可以数组构造引用。 + +格式:`数组类型名::new` + +举例: + +```java +//数组引用 +//Function中的R apply(T t) +@Test +public void test4(){ + Function func1 = length -> new String[length]; + String[] arr1 = func1.apply(5); + System.out.println(Arrays.toString(arr1)); + + System.out.println("*******************"); + + Function func2 = String[] :: new; + String[] arr2 = func2.apply(10); + System.out.println(Arrays.toString(arr2)); + +} +``` + +## 5. Java8新特性:强大的Stream API + +### 5.1 说明 + +- Java8中有两大最为重要的改变。第一个是 Lambda 表达式;另外一个则是 Stream API。 +- Stream API ( java.util.stream) 把真正的函数式编程风格引入到Java中。这是目前为止对Java类库`最好的补充`,因为Stream API可以极大提供Java程序员的生产力,让程序员写出高效率、干净、简洁的代码。 +- Stream 是 Java8 中处理集合的关键抽象概念,它可以指定你希望对集合进行的操作,可以执行非常复杂的查找、过滤和映射数据等操作。 **使用Stream API 对集合数据进行操作,就类似于使用 SQL 执行的数据库查询。**也可以使用 Stream API 来并行执行操作。简言之,Stream API 提供了一种高效且易于使用的处理数据的方式。 + +### 5.2 为什么要使用Stream API + +实际开发中,项目中多数数据源都来自于MySQL、Oracle等。但现在数据源可以更多了,有MongDB,Radis等,而这些NoSQL的数据就需要Java层面去处理。 + +### 5.3 什么是Stream + +Stream 是数据渠道,用于操作数据源(集合、数组等)所生成的元素序列。 + +Stream 和 Collection 集合的区别:**Collection 是一种静态的内存数据结构,讲的是数据,而 Stream 是有关计算的,讲的是计算。**前者是主要面向内存,存储在内存中,后者主要是面向 CPU,通过 CPU 实现计算。 + +注意: + +①Stream 自己不会存储元素。 + +②Stream 不会改变源对象。相反,他们会返回一个持有结果的新Stream。 + +③Stream 操作是延迟执行的。这意味着他们会等到需要结果的时候才执行。即一旦执行终止操作,就执行中间操作链,并产生结果。 + +④ Stream一旦执行了终止操作,就不能再调用其它中间操作或终止操作了。 + +### 5.4 Stream的操作三个步骤 + +**1- 创建 Stream** +一个数据源(如:集合、数组),获取一个流 + +**2- 中间操作** +每次处理都会返回一个持有结果的新Stream,即中间操作的方法返回值仍然是Stream类型的对象。因此中间操作可以是个`操作链`,可对数据源的数据进行n次处理,但是在终结操作前,并不会真正执行。 + +**3- 终止操作(终端操作)** +终止操作的方法返回值类型就不再是Stream了,因此一旦执行终止操作,就结束整个Stream操作了。一旦执行终止操作,就执行中间操作链,最终产生结果并结束Stream。 + +image-20220514180803311 + +#### 5.4.1 创建Stream实例 + +**方式一:通过集合** + +Java8 中的 Collection 接口被扩展,提供了两个获取流的方法: + +- default Stream stream() : 返回一个顺序流 + +- default Stream parallelStream() : 返回一个并行流 + +```java +@Test +public void test01(){ + List list = Arrays.asList(1,2,3,4,5); + + //JDK1.8中,Collection系列集合增加了方法 + Stream stream = list.stream(); +} +``` + + + +**方式二:通过数组** + +Java8 中的 Arrays 的静态方法 stream() 可以获取数组流: + +- static Stream stream(T[] array): 返回一个流 +- public static IntStream stream(int[] array) +- public static LongStream stream(long[] array) +- public static DoubleStream stream(double[] array) + +```java +@Test +public void test02(){ + String[] arr = {"hello","world"}; + Stream stream = Arrays.stream(arr); +} + +@Test +public void test03(){ + int[] arr = {1,2,3,4,5}; + IntStream stream = Arrays.stream(arr); +} +``` + + + +**方式三:通过Stream的of()** + +可以调用Stream类静态方法 of(), 通过显示值创建一个流。它可以接收任意数量的参数。 + +- public static Stream of(T... values) : 返回一个流 + +```java +@Test +public void test04(){ + Stream stream = Stream.of(1,2,3,4,5); + stream.forEach(System.out::println); +} +``` + + + +**方式四:创建无限流(了解)** + +可以使用静态方法 Stream.iterate() 和 Stream.generate(), 创建无限流。 + +- 迭代 + public static Stream iterate(final T seed, final UnaryOperator f) + +- 生成 + public static Stream generate(Supplier s) + +```java +// 方式四:创建无限流 +@Test +public void test05() { + // 迭代 + // public static Stream iterate(final T seed, final + // UnaryOperator f) + Stream stream = Stream.iterate(0, x -> x + 2); + stream.limit(10).forEach(System.out::println); + + // 生成 + // public static Stream generate(Supplier s) + Stream stream1 = Stream.generate(Math::random); + stream1.limit(10).forEach(System.out::println); +} + +``` + +#### 5.4.2 一系列中间操作 + +多个中间操作可以连接起来形成一个流水线,除非流水线上触发终止操作,否则中间操作不会执行任何的处理!而在终止操作时一次性全部处理,称为“惰性求值”。 + +1-筛选与切片 + +| **方 法** | **描 述** | +| ----------------------- | ------------------------------------------------------------ | +| **filter(Predicatep)** | 接收 Lambda , 从流中排除某些元素 | +| **distinct()** | 筛选,通过流所生成元素的 hashCode() 和 equals() 去除重复元素 | +| **limit(long maxSize)** | 截断流,使其元素不超过给定数量 | +| **skip(long n)** | 跳过元素,返回一个扔掉了前 n 个元素的流。
若流中元素不足 n 个,则返回一个空流。与 limit(n) 互补 | + +2-映 射 + +| **方法** | **描述** | +| ----------------------------------- | ------------------------------------------------------------ | +| **map(Function f)** | 接收一个函数作为参数,该函数会被应用到每个元素上,并将其映射成一个新的元素。 | +| **mapToDouble(ToDoubleFunction f)** | 接收一个函数作为参数,该函数会被应用到每个元素上,产生一个新的 DoubleStream。 | +| **mapToInt(ToIntFunction f)** | 接收一个函数作为参数,该函数会被应用到每个元素上,产生一个新的 IntStream。 | +| **mapToLong(ToLongFunction f)** | 接收一个函数作为参数,该函数会被应用到每个元素上,产生一个新的 LongStream。 | +| **flatMap(Function f)** | 接收一个函数作为参数,将流中的每个值都换成另一个流,然后把所有流连接成一个流 | + +3-排序 + +| **方法** | **描述** | +| ------------------------------ | ---------------------------------- | +| **sorted()** | 产生一个新流,其中按自然顺序排序 | +| **sorted(Comparator** **com)** | 产生一个新流,其中按比较器顺序排序 | + +代码举例: + +```java +package com.atguigu.stream; + +import org.junit.Test; + +import java.util.Arrays; +import java.util.stream.Stream; + +public class StreamMiddleOperate { + @Test + public void test01(){ + //1、创建Stream + Stream stream = Stream.of(1,2,3,4,5,6); + + //2、加工处理 + //过滤:filter(Predicate p) + //把里面的偶数拿出来 + /* + * filter(Predicate p) + * Predicate是函数式接口,抽象方法:boolean test(T t) + */ + stream = stream.filter(t -> t%2==0); + + //3、终结操作:例如:遍历 + stream.forEach(System.out::println); + } + @Test + public void test02(){ + Stream.of(1,2,3,4,5,6) + .filter(t -> t%2==0) + .forEach(System.out::println); + } + @Test + public void test03(){ + Stream.of(1,2,3,4,5,6,2,2,3,3,4,4,5) + .distinct() + .forEach(System.out::println); + } + @Test + public void test04(){ + Stream.of(1,2,3,4,5,6,2,2,3,3,4,4,5) + .limit(3) + .forEach(System.out::println); + } + @Test + public void test05(){ + Stream.of(1,2,2,3,3,4,4,5,2,3,4,5,6,7) + .distinct() //(1,2,3,4,5,6,7) + .filter(t -> t%2!=0) //(1,3,5,7) + .limit(3) + .forEach(System.out::println); + } + @Test + public void test06(){ + Stream.of(1,2,3,4,5,6,2,2,3,3,4,4,5) + .skip(5) + .forEach(System.out::println); + } + @Test + public void test07(){ + Stream.of(1,2,3,4,5,6,2,2,3,3,4,4,5) + .skip(5) + .distinct() + .filter(t -> t%3==0) + .forEach(System.out::println); + } + @Test + public void test08(){ + long count = Stream.of(1,2,3,4,5,6,2,2,3,3,4,4,5) + .distinct() + .peek(System.out::println) //Consumer接口的抽象方法 void accept(T t) + .count(); + System.out.println("count="+count); + } + @Test + public void test09(){ + //希望能够找出前三个最大值,前三名最大的,不重复 + Stream.of(11,2,39,4,54,6,2,22,3,3,4,54,54) + .distinct() + .sorted((t1,t2) -> -Integer.compare(t1, t2))//Comparator接口 int compare(T t1, T t2) + .limit(3) + .forEach(System.out::println); + } + @Test + public void test10(){ + Stream.of(1,2,3,4,5) + .map(t -> t+=1)//Function接口抽象方法 R apply(T t) + .forEach(System.out::println); + } + @Test + public void test11(){ + String[] arr = {"hello","world","java"}; + + Arrays.stream(arr) + .map(t->t.toUpperCase()) + .forEach(System.out::println); + } + @Test + public void test12(){ + String[] arr = {"hello","world","java"}; + Arrays.stream(arr) + .flatMap(t -> Stream.of(t.split("|")))//Function接口抽象方法 R apply(T t) 现在的R是一个Stream + .forEach(System.out::println); + } +} + +``` + +#### 5.4.3 终止操作 + +- 终端操作会从流的流水线生成结果。其结果可以是任何不是流的值,例如:List、Integer,甚至是 void 。 + +- 流进行了终止操作后,不能再次使用。 + +1-匹配与查找 + +| **方法** | **描述** | +| ------------------------------- | ------------------------------------------------------------ | +| **allMatch(Predicate p)** | 检查是否匹配所有元素 | +| **anyMatch(Predicate p) ** | 检查是否至少匹配一个元素 | +| **noneMatch(Predicate** **p)** | 检查是否没有匹配所有元素 | +| **findFirst()** | 返回第一个元素 | +| **findAny()** | 返回当前流中的任意元素 | +| **count()** | 返回流中元素总数 | +| **max(Comparator c)** | 返回流中最大值 | +| **min(Comparator c)** | 返回流中最小值 | +| **forEach(Consumer c)** | 内部迭代(使用 Collection 接口需要用户去做迭代,称为外部迭代。
相反,Stream API 使用内部迭代——它帮你把迭代做了) | + +2-归约 + +| **方法** | **描述** | +| ----------------------------------------- | -------------------------------------------------------- | +| **reduce(T identity, BinaryOperator b)** | 可以将流中元素反复结合起来,得到一个值。返回 T | +| **reduce(BinaryOperator b)** | 可以将流中元素反复结合起来,得到一个值。返回 Optional | + +备注:map 和 reduce 的连接通常称为 map-reduce 模式,因 Google 用它来进行网络搜索而出名。 + +3-收集 + +| **方 法** | **描 述** | +| ------------------------- | ------------------------------------------------------------ | +| **collect(Collector c)** | 将流转换为其他形式。接收一个 Collector接口的实现,
用于给Stream中元素做汇总的方法 | + +Collector 接口中方法的实现决定了如何对流执行收集的操作(如收集到 List、Set、Map)。 + +另外, Collectors 实用类提供了很多静态方法,可以方便地创建常见收集器实例,具体方法与实例如下表: + +| **方法** | **返回类型** | **作用** | +| ---------- | ------------------------ | -------------------- | +| **toList** | Collector> | 把流中元素收集到List | + +```java +List emps= list.stream().collect(Collectors.toList()); +``` + +| **方法** | **返回类型** | **作用** | +| --------- | ----------------------- | ------------------- | +| **toSet** | Collector> | 把流中元素收集到Set | + +```java +Set emps= list.stream().collect(Collectors.toSet()); +``` + +| **方法** | **返回类型** | **作用** | +| ---------------- | ------------------ | -------------------------- | +| **toCollection** | Collector | 把流中元素收集到创建的集合 | + +```java +Collection emps =list.stream().collect(Collectors.toCollection(ArrayList::new)); +``` + +| **方法** | **返回类型** | **作用** | +| ------------ | --------------------- | ------------------ | +| **counting** | Collector | 计算流中元素的个数 | + +```java +long count = list.stream().collect(Collectors.counting()); +``` + +| **方法** | **返回类型** | **作用** | +| -------------- | ------------------------ | ------------------------ | +| **summingInt** | Collector | 对流中元素的整数属性求和 | + +```java +int total=list.stream().collect(Collectors.summingInt(Employee::getSalary)); +``` + +| **方法** | **返回类型** | **作用** | +| ---------------- | ----------------------- | ------------------------------- | +| **averagingInt** | Collector | 计算流中元素Integer属性的平均值 | + +```java +double avg = list.stream().collect(Collectors.averagingInt(Employee::getSalary)); +``` + +| **方法** | **返回类型** | **作用** | +| ------------------ | ------------------------------------- | --------------------------------------- | +| **summarizingInt** | Collector | 收集流中Integer属性的统计值。如:平均值 | + +```java +int SummaryStatisticsiss= list.stream().collect(Collectors.summarizingInt(Employee::getSalary)); +``` + +| **方法** | **返回类型** | **作用** | +| ----------- | ---------------------------------- | ------------------ | +| **joining** | Collector | 连接流中每个字符串 | + +```java +String str= list.stream().map(Employee::getName).collect(Collectors.joining()); +``` + +| **方法** | **返回类型** | **作用** | +| --------- | ---------------------------- | -------------------- | +| **maxBy** | Collector> | 根据比较器选择最大值 | + +```java +Optionalmax= list.stream().collect(Collectors.maxBy(comparingInt(Employee::getSalary))); +``` + +| **方法** | **返回类型** | **作用** | +| --------- | ---------------------------- | -------------------- | +| **minBy** | Collector> | 根据比较器选择最小值 | + +```java +Optional min = list.stream().collect(Collectors.minBy(comparingInt(Employee::getSalary))); +``` + +| **方法** | **返回类型** | **作用** | +| ------------ | ---------------------------- | ------------------------------------------------------------ | +| **reducing** | Collector> | 从一个作为累加器的初始值开始,利用BinaryOperator与流中元素逐个结合,从而归约成单个值 | + +```java +int total=list.stream().collect(Collectors.reducing(0, Employee::getSalar, Integer::sum)); +``` + +| **方法** | **返回类型** | **作用** | +| --------------------- | ----------------- | ---------------------------------- | +| **collectingAndThen** | Collector | 包裹另一个收集器,对其结果转换函数 | + +```java +int how= list.stream().collect(Collectors.collectingAndThen(Collectors.toList(), List::size)); +``` + +| **方法** | **返回类型** | **作用** | +| -------------- | -------------------------------- | -------------------------------------- | +| **groupingBy** | Collector>> | 根据某属性值对流分组,属性为K,结果为V | + +```java +Map> map= list.stream().collect(Collectors.groupingBy(Employee::getStatus)); +``` + +| **方法** | **返回类型** | **作用** | +| ------------------ | -------------------------------------- | ----------------------- | +| **partitioningBy** | Collector>> | 根据true或false进行分区 | + +```java +Map> vd = list.stream().collect(Collectors.partitioningBy(Employee::getManage)); +``` + +举例: + +```java +package com.atguigu.stream; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.Test; + +public class StreamEndding { + @Test + public void test01(){ + Stream.of(1,2,3,4,5) + .forEach(System.out::println); + } + @Test + public void test02(){ + long count = Stream.of(1,2,3,4,5) + .count(); + System.out.println("count = " + count); + } + @Test + public void test03(){ + boolean result = Stream.of(1,3,5,7,9) + .allMatch(t -> t%2!=0); + System.out.println(result); + } + @Test + public void test04(){ + boolean result = Stream.of(1,3,5,7,9) + .anyMatch(t -> t%2==0); + System.out.println(result); + } + @Test + public void test05(){ + Optional opt = Stream.of(1,3,5,7,9).findFirst(); + System.out.println(opt); + } + @Test + public void test06(){ + Optional opt = Stream.of(1,2,3,4,5,7,9) + .filter(t -> t%3==0) + .findFirst(); + System.out.println(opt); + } + @Test + public void test07(){ + Optional opt = Stream.of(1,2,4,5,7,8) + .filter(t -> t%3==0) + .findFirst(); + System.out.println(opt); + } + @Test + public void test08(){ + Optional max = Stream.of(1,2,4,5,7,8) + .max((t1,t2) -> Integer.compare(t1, t2)); + System.out.println(max); + } + @Test + public void test09(){ + Integer reduce = Stream.of(1,2,4,5,7,8) + .reduce(0, (t1,t2) -> t1+t2);//BinaryOperator接口 T apply(T t1, T t2) + System.out.println(reduce); + } + @Test + public void test10(){ + Optional max = Stream.of(1,2,4,5,7,8) + .reduce((t1,t2) -> t1>t2?t1:t2);//BinaryOperator接口 T apply(T t1, T t2) + System.out.println(max); + } + @Test + public void test11(){ + List list = Stream.of(1,2,4,5,7,8) + .filter(t -> t%2==0) + .collect(Collectors.toList()); + + System.out.println(list); + } +} +``` + +### 5.5 Java9新增API + +**新增1:Stream实例化方法** + +ofNullable()的使用: + +Java 8 中 Stream 不能完全为null,否则会报空指针异常。而 Java 9 中的 ofNullable 方法允许我们创建一个单元素 Stream,可以包含一个非空元素,也可以创建一个空 Stream。 + +```java +//报NullPointerException +//Stream stream1 = Stream.of(null); +//System.out.println(stream1.count()); + +//不报异常,允许通过 +Stream stringStream = Stream.of("AA", "BB", null); +System.out.println(stringStream.count());//3 + +//不报异常,允许通过 +List list = new ArrayList<>(); +list.add("AA"); +list.add(null); +System.out.println(list.stream().count());//2 +//ofNullable():允许值为null +Stream stream1 = Stream.ofNullable(null); +System.out.println(stream1.count());//0 + +Stream stream = Stream.ofNullable("hello world"); +System.out.println(stream.count());//1 + +``` + +iterator()重载的使用: + +```java +//原来的控制终止方式: +Stream.iterate(1,i -> i + 1).limit(10).forEach(System.out::println); + +//现在的终止方式: +Stream.iterate(1,i -> i < 100,i -> i + 1).forEach(System.out::println); + +``` + +### 5.6 练习 + +现在有两个 ArrayList 集合存储队伍当中的多个成员姓名,要求使用传统的for循环(或增强for循环)依次进行以 +下若干操作步骤: + +1. 第一个队伍只要名字为3个字的成员姓名;存储到一个新集合中。 +2. 第一个队伍筛选之后只要前3个人;存储到一个新集合中。 +3. 第二个队伍只要姓张的成员姓名;存储到一个新集合中。 +4. 第二个队伍筛选之后不要前2个人;存储到一个新集合中。 +5. 将两个队伍合并为一个队伍;存储到一个新集合中。 +6. 根据姓名创建 Person 对象;存储到一个新集合中。 +7. 打印整个队伍的Person对象信息。 + +Person 类的代码为: + +```java +public class Person { +    private String name; +    public Person() {} +    public Person(String name) { +        this.name = name; +    }     +    public String getName() { +        return name; +    } +    public void setName(String name) { +        this.name = name; +    } +    @Override +    public String toString() { +        return "Person{name='" + name + "'}"; +    } +} +``` + +两个队伍(集合)的代码如下: + +```java +public static void main(String[] args) { +       //第一支队伍 +        ArrayList one = new ArrayList<>(); +        one.add("迪丽热巴"); +        one.add("宋远桥"); +        one.add("苏星河"); +        one.add("石破天"); +        one.add("石中玉"); +        one.add("老子"); +        one.add("庄子"); +        one.add("洪七公"); +        //第二支队伍 +        ArrayList two = new ArrayList<>(); +        two.add("古力娜扎"); +        two.add("张无忌"); +        two.add("赵丽颖"); +        two.add("张三丰"); +        two.add("尼古拉斯赵四"); +        two.add("张天爱"); +        two.add("张二狗"); + + // ....编写代码完成题目要求  +    } +``` + +参考答案: + +```java +public static void main(String[] args) { +       //第一支队伍 +        ArrayList one = new ArrayList<>(); +        one.add("迪丽热巴"); +        one.add("宋远桥"); +        one.add("苏星河"); +        one.add("石破天"); +        one.add("石中玉"); +        one.add("老子"); +        one.add("庄子"); +        one.add("洪七公"); + +        //第二支队伍 +        ArrayList two = new ArrayList<>(); +        two.add("古力娜扎"); +        two.add("张无忌"); +        two.add("赵丽颖"); +        two.add("张三丰"); +        two.add("尼古拉斯赵四"); +        two.add("张天爱"); +        two.add("张二狗"); +         + // 第一个队伍只要名字为3个字的成员姓名; +        // 第一个队伍筛选之后只要前3个人; +        Stream streamOne = one.stream().filter(s ‐> s.length() == 3).limit(3); + +        // 第二个队伍只要姓张的成员姓名; +        // 第二个队伍筛选之后不要前2个人; +        Stream streamTwo = two.stream().filter(s ‐> s.startsWith("张")).skip(2); + +        // 将两个队伍合并为一个队伍; +        // 根据姓名创建Person对象; +        // 打印整个队伍的Person对象信息。 +        Stream.concat(streamOne, streamTwo).map(Person::new).forEach(System.out::println); +         +} +``` diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25418\347\253\240_JDK8-17\346\226\260\347\211\271\346\200\247/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25418\347\253\240_JDK8-17\346\226\260\347\211\271\346\200\247\357\274\210\344\270\213\357\274\211.md" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25418\347\253\240_JDK8-17\346\226\260\347\211\271\346\200\247/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25418\347\253\240_JDK8-17\346\226\260\347\211\271\346\200\247\357\274\210\344\270\213\357\274\211.md" new file mode 100644 index 0000000000000000000000000000000000000000..1fbf10dd31f97794de2d9dd7d20750dec8ca8235 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/01_\350\257\276\344\273\266\344\270\216\347\224\265\345\255\220\346\225\231\346\235\220/\345\260\232\347\241\205\350\260\267_\347\254\25418\347\253\240_JDK8-17\346\226\260\347\211\271\346\200\247/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\347\254\25418\347\253\240_JDK8-17\346\226\260\347\211\271\346\200\247\357\274\210\344\270\213\357\274\211.md" @@ -0,0 +1,1525 @@ +# 第18章_JDK8-17新特性(下) + +讲师:尚硅谷-宋红康(江湖人称:康师傅) + +官网:[http://www.atguigu.com](http://www.atguigu.com/) + +*** + +## 6. 新语法结构 + +新的语法结构,为我们勾勒出了 Java 语法进化的一个趋势,将开发者从`复杂、繁琐`的低层次抽象中逐渐解放出来,以更高层次、更优雅的抽象,既`降低代码量`,又避免意外编程错误的出现,进而提高代码质量和开发效率。 + +### 6.1 Java的REPL工具: jShell命令 + +**JDK9的新特性** + +Java 终于拥有了像Python 和 Scala 之类语言的REPL工具(交互式编程环境,read - evaluate - print - loop):`jShell`。以交互式的方式对语句和表达式进行求值。`即写即得`、`快速运行`。 + +利用jShell在没有创建类的情况下,在命令行里直接声明变量,计算表达式,执行语句。无需跟人解释”public static void main(String[] args)”这句"废话"。 + +**使用举例** + +- 调出jShell + + + ![image-20220527205410620](images/image-20220527205410620.png) + +- 获取帮助 + + + ![image-20220527205418073](images/image-20220527205418073.png) + +- 基本使用 + + + ![image-20220527205429720](images/image-20220527205429720.png) + +- 导入指定的包 + + + ![image-20220527205440068](images/image-20220527205440068.png) + +- 默认已经导入如下的所有包:(包含java.lang包) + + + ![image-20220527205445267](images/image-20220527205445267.png) + +- 只需按下 Tab 键,就能自动补全代码 + + + ![image-20220527205451352](images/image-20220527205451352.png) + +- 列出当前 session 里所有有效的代码片段 + + + ![image-20220527205458774](images/image-20220527205458774.png) + +- 查看当前 session 下所有创建过的变量 + + + ![image-20220527205506632](images/image-20220527205506632.png) + +- 查看当前 session 下所有创建过的方法 + + + ![image-20220527205513459](images/image-20220527205513459.png) + +> Tips:我们还可以重新定义相同方法名和参数列表的方法,即对现有方法的修改(或覆盖)。 + +- 使用外部代码编辑器来编写 Java 代码 + + + ![image-20220527205519915](images/image-20220527205519915.png) + +从外部文件加载源代码【HelloWorld.java】 + +```java +/** + * Created by songhongkang + */ +public void printHello() { + System.out.println("马上2023年了,尚硅谷祝所有的谷粉元旦快乐!"); +} +printHello(); + +``` + +- 使用/open命令调用 + + + ![image-20220527205827712](images/image-20220527205827712.png) + +- 退出jShell + + + ![image-20220527205904000](images/image-20220527205904000.png) + +### 6.2 异常处理之try-catch资源关闭 + +在JDK7 之前,我们这样处理资源的关闭: + +```java +@Test +public void test01() { + FileWriter fw = null; + BufferedWriter bw = null; + try { + fw = new FileWriter("d:/1.txt"); + bw = new BufferedWriter(fw); + + bw.write("hello"); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (bw != null) { + bw.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + try { + if (fw != null) { + fw.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + } +} +``` + +**JDK7的新特性** + +在try的后面可以增加一个(),在括号中可以声明流对象并初始化。try中的代码执行完毕,会自动把流对象释放,就不用写finally了。 + +格式: + +```java +try(资源对象的声明和初始化){ + 业务逻辑代码,可能会产生异常 +}catch(异常类型1 e){ + 处理异常代码 +}catch(异常类型2 e){ + 处理异常代码 +} +``` + +说明: + +1、在try()中声明的资源,无论是否发生异常,无论是否处理异常,都会自动关闭资源对象,不用手动关闭了。 + +2、这些资源实现类必须实现AutoCloseable或Closeable接口,实现其中的close()方法。Closeable是AutoCloseable的子接口。Java7几乎把所有的“资源类”(包括文件IO的各种类、JDBC编程的Connection、Statement等接口…)都进行了改写,改写后资源类都实现了AutoCloseable或Closeable接口,并实现了close()方法。 + +3、写到try()中的资源类的变量默认是final声明的,不能修改。 + +举例: + +```java +//举例1 +@Test +public void test02() { + try ( + FileWriter fw = new FileWriter("d:/1.txt"); + BufferedWriter bw = new BufferedWriter(fw); + ) { + bw.write("hello"); + } catch (IOException e) { + e.printStackTrace(); + } +} + +//举例2 +@Test +public void test03() { + //从d:/1.txt(utf-8)文件中,读取内容,写到项目根目录下1.txt(gbk)文件中 + try ( + FileInputStream fis = new FileInputStream("d:/1.txt"); + InputStreamReader isr = new InputStreamReader(fis, "utf-8"); + BufferedReader br = new BufferedReader(isr); + + FileOutputStream fos = new FileOutputStream("1.txt"); + OutputStreamWriter osw = new OutputStreamWriter(fos, "gbk"); + BufferedWriter bw = new BufferedWriter(osw); + ) { + String str; + while ((str = br.readLine()) != null) { + bw.write(str); + bw.newLine(); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } +} +``` + +**JDK9的新特性** + +try的前面可以定义流对象,try后面的()中可以直接引用流对象的名称。在try代码执行完毕后,流对象也可以释放掉,也不用写finally了。 + +格式: + +```java +A a = new A(); +B b = new B(); +try(a;b){ + 可能产生的异常代码 +}catch(异常类名 变量名){ + 异常处理的逻辑 +} +``` + +举例: + +```java +@Test +public void test04() { + InputStreamReader reader = new InputStreamReader(System.in); + OutputStreamWriter writer = new OutputStreamWriter(System.out); + try (reader; writer) { + //reader是final的,不可再被赋值 + // reader = null; + + } catch (IOException e) { + e.printStackTrace(); + } +} +``` + +### 6.3 局部变量类型推断 + +**JDK 10的新特性** + +局部变量的显示类型声明,常常被认为是不必须的,给一个好听的名字反而可以很清楚的表达出下面应该怎样继续。本新特性允许开发人员省略通常不必要的局部变量类型声明,以增强Java语言的体验性、可读性。 + +- 使用举例 + + +```java +//1.局部变量的实例化 +var list = new ArrayList(); + +var set = new LinkedHashSet(); + +//2.增强for循环中的索引 +for (var v : list) { + System.out.println(v); +} + +//3.传统for循环中 +for (var i = 0; i < 100; i++) { + System.out.println(i); +} + +//4. 返回值类型含复杂泛型结构 +var iterator = set.iterator(); +//Iterator> iterator = set.iterator(); + +``` + +- 不适用场景 + - 声明一个成员变量 + - 声明一个数组变量,并为数组静态初始化(省略new的情况下) + - 方法的返回值类型 + - 方法的参数类型 + - 没有初始化的方法内的局部变量声明 + - 作为catch块中异常类型 + - Lambda表达式中函数式接口的类型 + - 方法引用中函数式接口的类型 + +代码举例: + +声明一个成员变量,并初始化值为null + + ![image-20220528155628337](images/image-20220528155628337.png) + +声明一个数组变量,并为数组静态初始化(省略new的情况下) + + ![image-20220528155436304](images/image-20220528155436304.png) + +没有初始化的方法内的局部变量声明 + + ![image-20220528155525774](images/image-20220528155525774.png) + +方法的返回值类型 + + ![image-20220528155537713](images/image-20220528155537713.png) + +方法的参数类型 + + ![image-20220528155549303](images/image-20220528155549303.png) + +构造器的参数类型 + + ![image-20220528155614708](images/image-20220528155614708.png) + +作为catch块中异常类型 + + ![image-20220528155640498](images/image-20220528155640498.png) + +Lambda表达式中函数式接口的类型 + + ![image-20220528155423180](images/image-20220528155423180.png) + +方法引用中函数式接口的类型 + + ![image-20220528155429055](images/image-20220528155429055.png) + +**注意:** + +- var不是一个关键字,而是一个类型名,将它作为变量的类型。不能使用var作为类名。 + +- 这不是JavaScript。var并不会改变 Java是一门静态类型语言的事实。编译器负责推断出类型,并把结果写入字节码文件,就好像是开发人员自己敲入类型一样。 + +### 6.4 instanceof的模式匹配 + +**JDK14中预览特性:** + +instanceof 模式匹配通过提供更为简便的语法,来提高生产力。有了该功能,可以减少Java程序中显式强制转换的数量,实现更精确、简洁的类型安全的代码。 + +Java 14之前旧写法: + +```java +if(obj instanceof String){ + String str = (String)obj; //需要强转 + .. str.contains(..).. +}else{ + ... +} +``` + +Java 14新特性写法: + +```java +if(obj instanceof String str){ + .. str.contains(..).. +}else{ + ... +} +``` + +举例: + +```java +/** + * instanceof的模式匹配(预览) + * + * @author shkstart + * @create 上午 11:32 + */ +public class Feature01 { + @Test + public void test1(){ + + Object obj = new String("hello,Java14"); + obj = null;//在使用null 匹配instanceof 时,返回都是false. + if(obj instanceof String){ + String str = (String) obj; + System.out.println(str.contains("Java")); + }else{ + System.out.println("非String类型"); + } + + //举例1: + if(obj instanceof String str){ //新特性:省去了强制类型转换的过程 + System.out.println(str.contains("Java")); + }else{ + System.out.println("非String类型"); + } + } +} + +// 举例2 +class InstanceOf{ + + String str = "abc"; + + public void test(Object obj){ + + if(obj instanceof String str){//此时的str的作用域仅限于if结构内。 + System.out.println(str.toUpperCase()); + }else{ + System.out.println(str.toLowerCase()); + } + + } + +} + +//举例3: +class Monitor{ + private String model; + private double price; + +// public boolean equals(Object o){ +// if(o instanceof Monitor other){ +// if(model.equals(other.model) && price == other.price){ +// return true; +// } +// } +// return false; +// } + + + public boolean equals(Object o){ + return o instanceof Monitor other && model.equals(other.model) && price == other.price; + } + +} +``` + +**JDK15中第二次预览:** + +没有任何更改。 + +**JDK16中转正特性:** + +在Java16中转正。 + +### 6.5 switch表达式 + +传统switch声明语句的弊端: + +- 匹配是自上而下的,如果忘记写break,后面的case语句不论匹配与否都会执行; --->case穿透 +- 所有的case语句共用一个块范围,在不同的case语句定义的变量名不能重复; +- 不能在一个case里写多个执行结果一致的条件; +- 整个switch不能作为表达式返回值; + +```java +//常见错误实现 +switch(month){ + case 3|4|5://3|4|5 用了位运算符,11 | 100 | 101结果是 111是7 + System.out.println("春季"); + break; + case 6|7|8://6|7|8用了位运算符,110 | 111 | 1000结果是1111是15 + System.out.println("夏季"); + break; + case 9|10|11://9|10|11用了位运算符,1001 | 1010 | 1011结果是1011是11 + System.out.println("秋季"); + break; + case 12|1|2://12|1|2 用了位运算符,1100 | 1 | 10 结果是1111,是15 + System.out.println("冬季"); + break; + default: + System.out.println("输入有误"); +} +``` + +**JDK12中预览特性:** + +- Java 12将会对switch声明语句进行扩展,使用`case L ->`来替代以前的`break;`,省去了 break 语句,避免了因少写 break 而出错。 + +- 同时将多个 case 合并到一行,显得简洁、清晰,也更加优雅的表达逻辑分支。 + +- 为了保持兼容性,case 条件语句中依然可以使用字符` :` ,但是同一个 switch 结构里不能混用` ->` 和` :` ,否则编译错误。 + + +举例: + +Java 12之前 + +```java +/** + * @author shkstart + * @create 下午 4:47 + */ +public class SwitchTest { + public static void main(String[] args) { + int numberOfLetters; + Fruit fruit = Fruit.APPLE; + switch (fruit) { + case PEAR: + numberOfLetters = 4; + break; + case APPLE: + case GRAPE: + case MANGO: + numberOfLetters = 5; + break; + case ORANGE: + case PAPAYA: + numberOfLetters = 6; + break; + default: + throw new IllegalStateException("No Such Fruit:" + fruit); + } + System.out.println(numberOfLetters); + + } +} +enum Fruit { + PEAR, APPLE, GRAPE, MANGO, ORANGE, PAPAYA; +} +``` + +switch 语句如果漏写了一个 break,那么逻辑往往就跑偏了,这种方式既繁琐,又容易出错。 + +Java 12中: + +```java +/** + * @author shkstart + * @create 下午 10:38 + */ +public class SwitchTest1 { + public static void main(String[] args) { + Fruit fruit = Fruit.GRAPE; + switch(fruit){ + case PEAR -> System.out.println(4); + case APPLE,MANGO,GRAPE -> System.out.println(5); + case ORANGE,PAPAYA -> System.out.println(6); + default -> throw new IllegalStateException("No Such Fruit:" + fruit); + }; + } +} +``` + +更进一步: + +```java +/** + * @author shkstart + * @create 2019 下午 10:44 + */ +public class SwitchTest2 { + public static void main(String[] args) { + Fruit fruit = Fruit.GRAPE; + int numberOfLetters = switch(fruit){ + case PEAR -> 4; + case APPLE,MANGO,GRAPE -> 5; + case ORANGE,PAPAYA -> 6; + default -> throw new IllegalStateException("No Such Fruit:" + fruit); + }; + System.out.println(numberOfLetters); + } +} +``` + +**JDK13中二次预览特性:** + +JDK13中引入了yield语句,用于返回值。这意味着,switch表达式(返回值)应该使用yield,switch语句(不返回值)应该使用break。 + +yield和return的区别在于:return会直接跳出当前循环或者方法,而yield只会跳出当前switch块。 + +在以前: + +```java +@Test +public void testSwitch1(){ + String x = "3"; + int i; + switch (x) { + case "1": + i=1; + break; + case "2": + i=2; + break; + default: + i = x.length(); + break; + } + System.out.println(i); +} +``` + +在JDK13中: + +```java +@Test +public void testSwitch2(){ + String x = "3"; + int i = switch (x) { + case "1" -> 1; + case "2" -> 2; + default -> { + yield 3; + } + }; + System.out.println(i); +} +``` + +或者 + +```java +@Test +public void testSwitch3() { + String x = "3"; + int i = switch (x) { + case "1": + yield 1; + case "2": + yield 2; + default: + yield 3; + }; + System.out.println(i); +} +``` + +**JDK14中转正特性:** + +这是JDK 12和JDK 13中的预览特性,现在是正式特性了。 + +**JDK17的预览特性:switch的模式匹配** + +旧写法: + +```java +static String formatter(Object o) { + String formatted = "unknown"; + if (o instanceof Integer i) { + formatted = String.format("int %d", i); + } else if (o instanceof Long l) { + formatted = String.format("long %d", l); + } else if (o instanceof Double d) { + formatted = String.format("double %f", d); + } else if (o instanceof String s) { + formatted = String.format("String %s", s); + } + return formatted; +} +``` + +模式匹配新写法: + +```java +static String formatterPatternSwitch(Object o) { + return switch (o) { + case Integer i -> String.format("int %d", i); + case Long l -> String.format("long %d", l); + case Double d -> String.format("double %f", d); + case String s -> String.format("String %s", s); + default -> o.toString(); + }; +} +``` + +直接在 switch 上支持 Object 类型,这就等于同时支持多种类型,使用模式匹配得到具体类型,大大简化了语法量,这个功能很实用。 + +### 6.6 文本块 + +现实问题: + +在Java中,通常需要使用String类型表达HTML,XML,SQL或JSON等格式的字符串,在进行字符串赋值时需要进行转义和连接操作,然后才能编译该代码,这种表达方式难以阅读并且难以维护。 + +**JDK13的新特性** + +使用"""作为文本块的开始符和结束符,在其中就可以放置多行的字符串,不需要进行任何转义。因此,文本块将提高Java程序的可读性和可写性。 + +基本使用: + +```java +""" +line1 +line2 +line3 +""" +``` + +相当于: + +```java +"line1\nline2\nline3\n" +``` + +或者一个连接的字符串: + +```java +"line1\n" + +"line2\n" + +"line3\n" +``` + +如果字符串末尾不需要行终止符,则结束分隔符可以放在最后一行内容上。例如: + +```java +""" +line1 +line2 +line3""" +``` + +相当于 + +```java +"line1\nline2\nline3" +``` + +文本块可以表示空字符串,但不建议这样做,因为它需要两行源代码: + +```java +String empty = """ +"""; +``` + +举例1:普通文本 + +原有写法: + +```java + String text1 = "The Sound of silence\n" + + "Hello darkness, my old friend\n" + + "I've come to talk with you again\n" + + "Because a vision softly creeping\n" + + "Left its seeds while I was sleeping\n" + + "And the vision that was planted in my brain\n" + + "Still remains\n" + + "Within the sound of silence"; + +System.out.println(text1); +``` + +使用新特性: + +```java +String text2 = """ + The Sound of silence + Hello darkness, my old friend + I've come to talk with you again + Because a vision softly creeping + Left its seeds while I was sleeping + And the vision that was planted in my brain + Still remains + Within the sound of silence + """; +System.out.println(text2); +``` + +举例2:HTML语句 + +```html + + +

Hello, 尚硅谷

+ + +``` + +将其复制到Java的字符串中,会展示成以下内容: + +```java +"\n" + +" \n" + +"

Hello, 尚硅谷

\n" + +" \n" + +"\n"; +``` + +即被自动进行了转义,这样的字符串看起来不是很直观,在JDK 13中: + +```java +""" + + +

Hello, world

+ + +"""; +``` + +举例3:SQL语句 + +```sql +select employee_id,last_name,salary,department_id +from employees +where department_id in (40,50,60) +order by department_id asc +``` + +原有方式: + +```java +String sql = "SELECT id,NAME,email\n" + + "FROM customers\n" + + "WHERE id > 4\n" + + "ORDER BY email DESC"; +``` + +使用新特性: + +```java +String sql1 = """ + SELECT id,NAME,email + FROM customers + WHERE id > 4 + ORDER BY email DESC + """; +``` + +举例4:JSON字符串 + +原有方式: + +```java +String myJson = "{\n" + + " \"name\":\"Song Hongkang\",\n" + + " \"address\":\"www.atguigu.com\",\n" + + " \"email\":\"shkstart@126.com\"\n" + + "}"; +System.out.println(myJson); +``` + +使用新特性: + +```java +String myJson1 = """ + { + "name":"Song Hongkang", + "address":"www.atguigu.com", + "email":"shkstart@126.com" + }"""; +System.out.println(myJson1); +``` + +**JDK14中二次预览特性** + +JDK14的版本主要增加了两个escape sequences,分别是` \ `与`\s escape sequence`。 + +举例: + +```java +/** + * @author shkstart + * @create 下午 7:13 + */ +public class Feature05 { + //jdk14新特性 + @Test + public void test5(){ + String sql1 = """ + SELECT id,NAME,email + FROM customers + WHERE id > 4 + ORDER BY email DESC + """; + System.out.println(sql1); + + // \:取消换行操作 + // \s:表示一个空格 + String sql2 = """ + SELECT id,NAME,email \ + FROM customers\s\ + WHERE id > 4 \ + ORDER BY email DESC + """; + System.out.println(sql2); + } +} +``` + +**JDK15中功能转正** + +### 6.7 Record + +`背景` + +早在2019年2月份,Java 语言架构师 Brian Goetz,曾写文抱怨“`Java太啰嗦`”或有太多的“繁文缛节”。他提到:开发人员想要创建纯数据载体类(plain data carriers)通常都必须编写大量低价值、重复的、容易出错的代码。如:构造函数、getter/setter、equals()、hashCode()以及toString()等。 + +以至于很多人选择使用IDE的功能来自动生成这些代码。还有一些开发会选择使用一些第三方类库,如Lombok等来生成这些方法。 + +**JDK14中预览特性:神说要用record,于是就有了。**实现一个简单的数据载体类,为了避免编写:构造函数,访问器,equals(),hashCode () ,toString ()等,Java 14推出record。 + +`record` 是一种全新的类型,它本质上是一个 `final` 类,同时所有的属性都是 `final` 修饰,它会自动编译出 `public get` 、`hashcode` 、`equals`、`toString`、构造器等结构,减少了代码编写量。 + +具体来说:当你用`record` 声明一个类时,该类将自动拥有以下功能: +- 获取成员变量的简单方法,比如例题中的 name() 和 partner() 。注意区别于我们平常getter()的写法。 +- 一个 equals 方法的实现,执行比较时会比较该类的所有成员属性。 +- 重写 hashCode() 方法。 +- 一个可以打印该类所有成员属性的 toString() 方法。 +- 只有一个构造方法。 + +此外: + +- 还可以在record声明的类中定义静态字段、静态方法、构造器或实例方法。 + +- 不能在record声明的类中定义实例字段;类不能声明为abstract;不能声明显式的父类等。 + + +举例1(旧写法): + +```java +class Point { + private final int x; + private final int y; + + Point(int x, int y) { + this.x = x; + this.y = y; + } + + int x() { + return x; + } + + int y() { + return y; + } + + public boolean equals(Object o) { + if (!(o instanceof Point)) return false; + Point other = (Point) o; + return other.x == x && other.y == y; + } + + public int hashCode() { + return Objects.hash(x, y); + } + + @Override + public String toString() { + return "Point{" + + "x=" + x + + ", y=" + y + + '}'; + } +} +``` + +举例1(新写法): + +```java +record Point(int x, int y) { } +``` + +举例1: + +```java +public record Dog(String name, Integer age) { +} +``` + +```java +public class Java14Record { + + public static void main(String[] args) { + Dog dog1 = new Dog("牧羊犬", 1); + Dog dog2 = new Dog("田园犬", 2); + Dog dog3 = new Dog("哈士奇", 3); + System.out.println(dog1); + System.out.println(dog2); + System.out.println(dog3); + } +} +``` + +举例2: + +```java +/** + * Record类型的演示 + * + * @author shkstart + * @create 下午 6:13 + */ +public class Feature07 { + @Test + public void test1(){ + //测试构造器 + Person p1 = new Person("罗密欧",new Person("zhuliye",null)); + //测试toString() + System.out.println(p1); + //测试equals(): + Person p2 = new Person("罗密欧",new Person("zhuliye",null)); + System.out.println(p1.equals(p2)); + + //测试hashCode()和equals() + HashSet set = new HashSet<>(); + set.add(p1); + set.add(p2); + + for (Person person : set) { + System.out.println(person); + } + + //测试name()和partner():类似于getName()和getPartner() + System.out.println(p1.name()); + System.out.println(p1.partner()); + + } + + @Test + public void test2(){ + Person p1 = new Person("zhuyingtai"); + + System.out.println(p1.getNameInUpperCase()); + + Person.nation = "CHN"; + System.out.println(Person.showNation()); + + } +} +``` + +```java +/** + * @author shkstart + * @create 下午 6:20 + */ +public record Person(String name,Person partner) { + + //还可以声明静态的属性、静态的方法、构造器、实例方法 + + public static String nation; + + public static String showNation(){ + return nation; + } + + public Person(String name){ + this(name,null); + } + + public String getNameInUpperCase(){ + return name.toUpperCase(); + } + //不可以声明非静态的属性 +// private int id;//报错 +} + +//不可以将record定义的类声明为abstract的 +//abstract record Order(){ +// +//} + +//不可以给record定义的类声明显式的父类(非Record类) +//record Order() extends Thread{ +// +//} +``` + +**JDK15中第二次预览特性** + +**JDK16中转正特性** + +最终到JDK16中转正。 + +`记录不适合哪些场景` + +record的设计目标是提供一种将数据建模为数据的好方法。它也不是 JavaBeans 的直接替代品,因为record的方法不符合 JavaBeans 的 get 标准。另外 JavaBeans 通常是可变的,而记录是不可变的。尽管它们的用途有点像,但记录并不会以某种方式取代 JavaBean。 + +### 6.8 密封类 + +背景: + +在 Java 中如果想让一个类不能被继承和修改,这时我们应该使用 `final` 关键字对类进行修饰。不过这种要么可以继承,要么不能继承的机制不够灵活,有些时候我们可能想让某个类可以被某些类型继承,但是又不能随意继承,是做不到的。Java 15 尝试解决这个问题,引入了 `sealed` 类,被 `sealed` 修饰的类可以指定子类。这样这个类就只能被指定的类继承。 + +**JDK15的预览特性:** + +通过密封的类和接口来限制超类的使用,密封的类和接口限制其它可能继承或实现它们的其它类或接口。 + +具体使用: + +- 使用修饰符`sealed`,可以将一个类声明为密封类。密封的类使用保留关键字`permits`列出可以直接扩展(即extends)它的类。 + + +- `sealed` 修饰的类的机制具有传递性,它的子类必须使用指定的关键字进行修饰,且只能是 `final`、`sealed`、`non-sealed` 三者之一。 + + +举例: + +```java +package com.atguigu.java; +public abstract sealed class Shape permits Circle, Rectangle, Square {...} + +public final class Circle extends Shape {...} //final表示Circle不能再被继承了 + +public sealed class Rectangle extends Shape permits TransparentRectangle, FilledRectangle {...} + +public final class TransparentRectangle extends Rectangle {...} + +public final class FilledRectangle extends Rectangle {...} + +public non-sealed class Square extends Shape {...} //non-sealed表示可以允许任何类继承 +``` + +**JDK16二次预览特性** + +**JDK17中转正特性** + +## 7. API的变化 + +### 7.1 Optional类 + +**JDK8的新特性** + +到目前为止,臭名昭著的空指针异常是导致Java应用程序失败的最常见原因。以前,为了解决空指针异常,Google在著名的Guava项目引入了Optional类,通过检查空值的方式避免空指针异常。受到Google的启发,Optional类已经成为Java 8类库的一部分。 + +`Optional` 类(java.util.Optional) 是一个容器类,它可以保存类型T的值,代表这个值存在。或者仅仅保存null,表示这个值不存在。如果值存在,则isPresent()方法会返回true,调用get()方法会返回该对象。 + +Optional提供很多有用的方法,这样我们就不用显式进行空值检测。 + +- `创建Optional类对象的方法:` +- static Optional empty() :用来创建一个空的Optional实例 + - static Optional of(T value) :用来创建一个Optional实例,value必须非空 + - `static Optional ofNullable(T value)` :用来创建一个Optional实例,value可能是空,也可能非空 + +- `判断Optional容器中是否包含对象:` + + - boolean isPresent() : 判断Optional容器中的值是否存在 + - void ifPresent(Consumer consumer) :判断Optional容器中的值是否存在,如果存在,就对它进行Consumer指定的操作,如果不存在就不做 + +- `获取Optional容器的对象:` +- T get(): 如果调用对象包含值,返回该值。否则抛异常。T get()与of(T value)配合使用 + +- `T orElse(T other) `:orElse(T other) 与ofNullable(T value)配合使用,如果Optional容器中非空,就返回所包装值,如果为空,就用orElse(T other)other指定的默认值(备胎)代替 + +- T orElseGet(Supplier other) :如果Optional容器中非空,就返回所包装值,如果为空,就用Supplier接口的Lambda表达式提供的值代替 + +- T orElseThrow(Supplier exceptionSupplier) :如果Optional容器中非空,就返回所包装值,如果为空,就抛出你指定的异常类型代替原来的NoSuchElementException + +举例: + +```java +package com.atguigu.optional; + +import java.util.Optional; + +import org.junit.Test; + +public class TestOptional { + @Test + public void test1(){ + String str = "hello"; + Optional opt = Optional.of(str); + System.out.println(opt); + } + @Test + public void test2(){ + Optional opt = Optional.empty(); + System.out.println(opt); + } + @Test + public void test3(){ + String str = null; + Optional opt = Optional.ofNullable(str); + System.out.println(opt); + } + @Test + public void test4(){ + String str = "hello"; + Optional opt = Optional.of(str); + + String string = opt.get(); + System.out.println(string); + } + @Test + public void test5(){ + String str = null; + Optional opt = Optional.ofNullable(str); +// System.out.println(opt.get());//java.util.NoSuchElementException: No value present + } + @Test + public void test6(){ + String str = "hello"; + Optional opt = Optional.ofNullable(str); + String string = opt.orElse("atguigu"); + System.out.println(string); + } + @Test + public void test7(){ + String str = null; + Optional opt = Optional.ofNullable(str); + String string = opt.orElseGet(String::new); + System.out.println(string); + } + @Test + public void test8(){ + String str = null; + Optional opt = Optional.ofNullable(str); + String string = opt.orElseThrow(()->new RuntimeException("值不存在")); + System.out.println(string); + } + @Test + public void test9(){ + String str = "Hello1"; + Optional opt = Optional.ofNullable(str); + //判断是否是纯字母单词,如果是,转为大写,否则保持不变 + String result = opt.filter(s->s.matches("[a-zA-Z]+")) + .map(s -> s.toUpperCase()).orElse(str); + System.out.println(result); + } +} + +``` + +**这是JDK9-11的新特性** + +| **新增方法** | **描述** | **新增的版本** | +| ------------------------------------------------------------ | ------------------------------------------------------------ | -------------- | +| boolean isEmpty() | 判断value是否为空 | JDK 11 | +| ifPresentOrElse(Consumer action, Runnable emptyAction) | value非空,执行参数1功能;如果value为空,执行参数2功能 | JDK 9 | +| Optional or(Supplier> supplier) | value非空,返回对应的Optional;value为空,返回形参封装的Optional | JDK 9 | +| Stream stream() | value非空,返回仅包含此value的Stream;否则,返回一个空的Stream | JDK 9 | +| T orElseThrow() | value非空,返回value;否则抛异常NoSuchElementException | JDK 10 | + +### 7.2 String存储结构和API变更 + +**这是JDK9的新特性。** + +产生背景: + +> Motivation +> The current implementation of the String class stores characters in a char array, using two bytes (sixteen bits) for each character. Data gathered from many different applications indicates that strings are a major component of heap usage and, moreover, that most String objects contain only Latin-1 characters. Such characters require only one byte of storage, hence half of the space in the internal char arrays of such String objects is going unused. + +使用说明: + +> ## Description +> +> We propose to change the internal representation of the String class from a UTF-16 char array to a byte array plus an encoding-flag field. The new String class will store characters encoded either as ISO-8859-1/Latin-1 (one byte per character), or as UTF-16 (two bytes per character), based upon the contents of the string. The encoding flag will indicate which encoding is used. + +结论:String 再也不用 char[] 来存储啦,改成了 byte[] 加上编码标记,节约了一些空间。 + +```java +public final class String + implements java.io.Serializable, Comparable, CharSequence { + @Stable + private final byte[] value; + ... +} +``` + +拓展:StringBuffer 与 StringBuilder + +那StringBuffer 和 StringBuilder 是否仍无动于衷呢? + +> String-related classes such as AbstractStringBuilder, StringBuilder, and StringBuffer will be updated to use the same representation, as will the HotSpot VM's intrinsic string operations. + +**JDK11新特性:新增了一系列字符串处理方法** + +| **描述** | **举例** | +| -------------------- | ----------------------------------------------- | +| 判断字符串是否为空白 | " ".isBlank(); // true | +| 去除首尾空白 | " Javastack ".strip(); // "Javastack" | +| 去除尾部空格 | " Javastack ".stripTrailing(); // " Javastack" | +| 去除首部空格 | " Javastack ".stripLeading(); // "Javastack " | +| 复制字符串 | "Java".repeat(3);// "JavaJavaJava" | +| 行数统计 | "A\nB\nC".lines().count(); // 3 | + +**JDK12新特性:String 实现了 Constable 接口** + +String源码: + +```java +public final class String implements java.io.Serializable, Comparable, CharSequence,Constable, ConstantDesc { +``` + +java.lang.constant.Constable接口定义了抽象方法: + +```java +public interface Constable { + Optional describeConstable(); +} +``` + +Java 12 String 的实现源码: + +```java +/** + * Returns an {@link Optional} containing the nominal descriptor for this + * instance, which is the instance itself. + * + * @return an {@link Optional} describing the {@linkplain String} instance + * @since 12 + */ +@Override +public Optional describeConstable() { + return Optional.of(this); +} +``` + +很简单,其实就是调用 Optional.of 方法返回一个 Optional 类型。 + +举例: + +```java +private static void testDescribeConstable() { + String name = "尚硅谷Java高级工程师"; + Optional optional = name.describeConstable(); + System.out.println(optional.get()); +} +``` + +结果输出: + +``` +尚硅谷Java高级工程师 +``` + +**JDK12新特性:String新增方法** + +String的transform(Function) + +```java +var result = "foo".transform(input -> input + " bar"); +System.out.println(result); //foo bar +``` + +或者 + +```java +var result = "foo".transform(input -> input + " bar").transform(String::toUpperCase) +System.out.println(result); //FOO BAR +``` + +对应的源码: + +```java +/** +* This method allows the application of a function to {@code this} +* string. The function should expect a single String argument +* and produce an {@code R} result. +* @since 12 +*/ +public R transform(Function f) { + return f.apply(this); +} +``` + +在某种情况下,该方法应该被称为map()。 + +举例: + +```java +private static void testTransform() { + System.out.println("======test java 12 transform======"); + List list1 = List.of("Java", " Python", " C++ "); + List list2 = new ArrayList<>(); + list1.forEach(element -> list2.add(element.transform(String::strip) + .transform(String::toUpperCase) + .transform((e) -> "Hi," + e)) + ); + list2.forEach(System.out::println); +} +``` + +结果输出: + +```java +======test java 12 transform====== +Hi,JAVA +Hi,PYTHON +Hi,C++ +``` + +如果使用Java 8的Stream特性,可以如下实现: + +```java +private static void testTransform1() { + System.out.println("======test before java 12 ======"); + List list1 = List.of("Java ", " Python", " C++ "); + + Stream stringStream = list1.stream().map(element -> element.strip()).map(String::toUpperCase).map(element -> "Hello," + element); + List list2 = stringStream.collect(Collectors.toList()); + list2.forEach(System.out::println); + } +``` + +### 7.3 JDK17:标记删除Applet API + +Applet API 提供了一种将 Java AWT/Swing 控件嵌入到浏览器网页中的方法。不过,目前 Applet 已经被淘汰。大部分人可能压根就没有用过 Applet。 + +Applet API 实际上是无用的,因为所有 Web 浏览器供应商都已删除或透露计划放弃对 Java 浏览器插件的支持。Java 9 的时候,Applet API 已经被标记为过时,Java 17 的时候终于标记为删除了。 + +具体如下: + +```java +java.applet.Applet +java.applet.AppletStub +java.applet.AppletContext +java.applet.AudioClip +javax.swing.JApplet +java.beans.AppletInitializer +``` + +## 8. 其它结构变化 + +### 8.1 JDK9:UnderScore(下划线)使用的限制 + +在java 8 中,标识符可以独立使用“_”来命名: + +```java +String _ = "hello"; +System.out.println(_); +``` + +但是,在java 9 中规定“_”不再可以单独命名标识符了,如果使用,会报错: + +![image-20220527233322495](images/image-20220527233322495.png) + + + +### 8.2 JDK11:更简化的编译运行程序 + +看下面的代码。 + +```java +// 编译 +javac JavaStack.java + +// 运行 +java JavaStack +``` + +我们的认知里,要运行一个 Java 源代码必须先编译,再运行。而在 Java 11 版本中,通过一个 java 命令就直接搞定了,如下所示: + +``` +java JavaStack.java +``` + +注意点: + +- 执行源文件中的第一个类,第一个类必须包含主方法。 + + +### 8.3 GC方面新特性 + +GC是Java主要优势之一。 然而,当GC停顿太长,就会开始影响应用的响应时间。随着现代系统中内存不断增长,用户和程序员希望JVM能够以高效的方式充分利用这些内存, 并且无需长时间的GC暂停时间。 + +#### 8.3.1 G1 GC + +JDK9以后默认的垃圾回收器是G1GC。 + +**JDK10 : 为G1提供并行的Full GC** + +G1最大的亮点就是可以尽量的避免full gc。但毕竟是“尽量”,在有些情况下,G1就要进行full gc了,比如如果它无法足够快的回收内存的时候,它就会强制停止所有的应用线程然后清理。 + +在Java10之前,一个单线程版的标记-清除-压缩算法被用于full gc。为了尽量减少full gc带来的影响,在Java10中,就把之前的那个单线程版的标记-清除-压缩的full gc算法改成了支持多个线程同时full gc。这样也算是减少了full gc所带来的停顿,从而提高性能。 + +你可以通过`-XX:ParallelGCThreads`参数来指定用于并行GC的线程数。 + +**JDK12:可中断的 G1 Mixed GC** + +**JDK12:增强G1,自动返回未用堆内存给操作系统** + +#### 8.3.2 Shenandoah GC + +**JDK12:Shenandoah GC:低停顿时间的GC** + +![image-20220528212254705](images/image-20220528212254705.png) + +Shenandoah 垃圾回收器是 Red Hat 在 2014 年宣布进行的一项垃圾收集器研究项目 Pauseless GC 的实现,旨在**针对 JVM 上的内存收回实现低停顿的需求**。 + +据 Red Hat 研发 Shenandoah 团队对外宣称,Shenandoah 垃圾回收器的暂停时间与堆大小无关,这意味着无论将堆设置为 200 MB 还是 200 GB,都将拥有一致的系统暂停时间,不过实际使用性能将取决于实际工作堆的大小和工作负载。 + +Shenandoah GC 主要目标是 99.9% 的暂停小于 10ms,暂停与堆大小无关等。 + +这是一个实验性功能,不包含在默认(Oracle)的OpenJDK版本中。 + +Shenandoah开发团队在实际应用中的测试数据: + +![image-20220528212323729](images/image-20220528212323729.png) + +**JDK15:Shenandoah垃圾回收算法转正** + +Shenandoah垃圾回收算法终于从实验特性转变为产品特性,这是一个从 JDK 12 引入的回收算法,该算法通过与正在运行的 Java 线程同时进行疏散工作来减少 GC 暂停时间。Shenandoah 的暂停时间与堆大小无关,无论堆栈是 200 MB 还是 200 GB,都具有相同的一致暂停时间。 + +Shenandoah在JDK12被作为experimental引入,在JDK15变为Production;之前需要通过`-XX:+UnlockExperimentalVMOptions` `-XX:+UseShenandoahGC`来启用,现在只需要`-XX:+UseShenandoahGC`即可启用 + +#### 8.3.3 革命性的 ZGC + +**JDK11:引入革命性的 ZGC** + +ZGC,这应该是JDK11最为瞩目的特性,没有之一。 + +ZGC是一个并发、基于region、压缩型的垃圾收集器。 + +ZGC的设计目标是:支持TB级内存容量,暂停时间低(<10ms),对整个程序吞吐量的影响小于15%。 将来还可以扩展实现机制,以支持不少令人兴奋的功能,例如多层堆(即热对象置于DRAM和冷对象置于NVMe闪存),或压缩堆。 + +**JDK13:ZGC:将未使用的堆内存归还给操作系统** + +**JDK14:ZGC on macOS和windows** + +- JDK14之前,ZGC仅Linux才支持。现在mac或Windows上也能使用ZGC了,示例如下: + + ``` + -XX:+UnlockExperimentalVMOptions -XX:+UseZGC + ``` + +- ZGC与Shenandoah目标高度相似,在尽可能对吞吐量影响不大的前提下,实现在任意堆内存大小下都可以把垃圾收集的停顿时间限制在`十毫秒以内`的低延迟。 + + +![image-20220528212414676](images/image-20220528212414676.png) + +![image-20220528212421319](images/image-20220528212421319.png) + +**JDK15:ZGC 功能转正** + +ZGC是Java 11引入的新的垃圾收集器,经过了多个实验阶段,自此终于成为正式特性。 + +但是这并不是替换默认的GC,默认的GC仍然还是G1;之前需要通过`-XX:+UnlockExperimentalVMOptions`、` -XX:+UseZGC`来启用ZGC,现在只需要`-XX:+UseZGC`就可以。相信不久的将来它必将成为默认的垃圾回收器。 + +> ZGC的性能已经相当亮眼,用“令人震惊、革命性”来形容,不为过。未来将成为服务端、大内存、低延迟应用的首选垃圾收集器。 + +怎么形容Shenandoah和ZGC的关系呢?异同点大概如下: + +- 相同点:性能几乎可认为是相同的 +- 不同点:ZGC是Oracle JDK的,根正苗红。而Shenandoah只存在于OpenJDK中,因此使用时需注意你的JDK版本 + +**JDK16:ZGC 并发线程处理** + +在线程的堆栈处理过程中,总有一个制约因素就是safepoints。在safepoints这个点,Java的线程是要暂停执行的,从而限制了GC的效率。 + +> 回顾: +> +> 我们都知道,在之前,需要 GC 的时候,为了进行垃圾回收,需要所有的线程都暂停下来,这个暂停的时间我们称为 **Stop The World**。 +> +> 而为了实现 STW 这个操作, JVM 需要为每个线程选择一个点停止运行,这个点就叫做**安全点(Safepoints)**。 + +而ZGC的并发线程堆栈处理可以保证Java线程可以在GC safepoints的同时可以并发执行。它有助于提高所开发的Java软件应用程序的性能和效率。 + +## 9. 小结与展望 + +随着云计算和 AI 等技术浪潮,当前的计算模式和场景正在发生翻天覆地的变化,不仅对 Java 的发展速度提出了更高要求,也深刻影响着 Java 技术的发展方向。**传统的大型企业或互联网应用,正在被云端、容器化应用、模块化的微服务甚至是函数(FaaS, Function-as-a-Service)所替代。** + +**Java 需要在新的计算场景下,改进开发效率。**比如,Java 代码虽然进行了一些类型推断等改进,更易用的集合 API 等,但仍然给开发者留下了过于刻板、形式主义的印象,这是一个长期的改进方向。 + +Java虽然标榜面向对象编程,却毫不顾忌的加入`面向接口编程思想`,又扯出`匿名对象`的概念,每增加一个新的东西,对Java的根本(面向对象思想)的一次冲击。 + +> 士,不可不弘毅,任重而道远。 + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/02_\345\255\246\344\271\240\350\267\257\347\272\277\345\233\276.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/02_\345\255\246\344\271\240\350\267\257\347\272\277\345\233\276.zip" new file mode 100644 index 0000000000000000000000000000000000000000..fc198071541dbf23113622a6d13f2e9fff9aa782 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/02_\345\255\246\344\271\240\350\267\257\347\272\277\345\233\276.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6cb784529d5b8219a4e0d208d5b7643503ebb378a975e9811a3c35ebd48d5029 +size 9786190 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/03_\345\244\215\344\271\240\344\270\216\344\274\201\344\270\232\347\234\237\351\242\230.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/03_\345\244\215\344\271\240\344\270\216\344\274\201\344\270\232\347\234\237\351\242\230.zip" new file mode 100644 index 0000000000000000000000000000000000000000..c98c4b82da13c7fe14420e9379a522164a833069 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/03_\345\244\215\344\271\240\344\270\216\344\274\201\344\270\232\347\234\237\351\242\230.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c84012f8fd7cb87638134c8630491ef7a6d0b5bebdfcb5eef6776a501f9543b +size 463967 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/04_\346\213\223\345\261\225\347\273\203\344\271\240.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/04_\346\213\223\345\261\225\347\273\203\344\271\240.zip" new file mode 100644 index 0000000000000000000000000000000000000000..7a487b0a6b466a32fb497bcf7ecfc2c10ccd3d64 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/04_\346\213\223\345\261\225\347\273\203\344\271\240.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5fe874a05a0587dd4174514fe7714ebfc597aca467f9a74f73c2f97dd7bccd1 +size 7513233 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256.zip" new file mode 100644 index 0000000000000000000000000000000000000000..f2550832a5e27996c66f10f27a261dbfba73ab75 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53a0be585e5ca6dc77d5cd93fceb1ddf23e2da7bf097a4fb838f7b5df63f0fa5 +size 8259780 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project1\357\274\210\350\260\267\347\262\222\350\256\260\350\264\246\350\275\257\344\273\266\357\274\211/Project1\357\274\210\350\260\267\347\262\222\350\256\260\350\264\246\350\275\257\344\273\266\357\274\211.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project1\357\274\210\350\260\267\347\262\222\350\256\260\350\264\246\350\275\257\344\273\266\357\274\211/Project1\357\274\210\350\260\267\347\262\222\350\256\260\350\264\246\350\275\257\344\273\266\357\274\211.zip" new file mode 100644 index 0000000000000000000000000000000000000000..4b6620ba9a0b5b53d8f4c4e2604248ca448ef458 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project1\357\274\210\350\260\267\347\262\222\350\256\260\350\264\246\350\275\257\344\273\266\357\274\211/Project1\357\274\210\350\260\267\347\262\222\350\256\260\350\264\246\350\275\257\344\273\266\357\274\211.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3a1cfb32442ff46b17447ce89f041ee0a621e089e7133a2ce79dffb710775328 +size 749594 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project2\357\274\210\346\213\274\347\224\265\345\225\206\345\256\242\346\210\267\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211/Project2\357\274\210\346\213\274\347\224\265\345\225\206\345\256\242\346\210\267\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project2\357\274\210\346\213\274\347\224\265\345\225\206\345\256\242\346\210\267\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211/Project2\357\274\210\346\213\274\347\224\265\345\225\206\345\256\242\346\210\267\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211.zip" new file mode 100644 index 0000000000000000000000000000000000000000..54844491700bb87ee97468215829b66b48f74788 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project2\357\274\210\346\213\274\347\224\265\345\225\206\345\256\242\346\210\267\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211/Project2\357\274\210\346\213\274\347\224\265\345\225\206\345\256\242\346\210\267\347\256\241\347\220\206\347\263\273\347\273\237\357\274\211.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3203898a7356f3a16d118f44fbb97b7aa2a9896ad420df60ebe43e3718c9b42 +size 999642 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project3\357\274\210\344\274\230\345\260\232\345\274\200\345\217\221\345\233\242\351\230\237\344\272\272\345\221\230\350\260\203\345\272\246\347\263\273\347\273\237\357\274\211/Project3\357\274\210\344\274\230\345\260\232\345\274\200\345\217\221\345\233\242\351\230\237\344\272\272\345\221\230\350\260\203\345\272\246\347\263\273\347\273\237\357\274\211.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project3\357\274\210\344\274\230\345\260\232\345\274\200\345\217\221\345\233\242\351\230\237\344\272\272\345\221\230\350\260\203\345\272\246\347\263\273\347\273\237\357\274\211/Project3\357\274\210\344\274\230\345\260\232\345\274\200\345\217\221\345\233\242\351\230\237\344\272\272\345\221\230\350\260\203\345\272\246\347\263\273\347\273\237\357\274\211.zip" new file mode 100644 index 0000000000000000000000000000000000000000..d2669aad70bbf7d021686c81289ec4fed2eda53e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/01-\346\216\210\350\257\276\351\241\271\347\233\256/Project3\357\274\210\344\274\230\345\260\232\345\274\200\345\217\221\345\233\242\351\230\237\344\272\272\345\221\230\350\260\203\345\272\246\347\263\273\347\273\237\357\274\211/Project3\357\274\210\344\274\230\345\260\232\345\274\200\345\217\221\345\233\242\351\230\237\344\272\272\345\221\230\350\260\203\345\272\246\347\263\273\347\273\237\357\274\211.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c235a5f3051d547b6dce9b74e651afe83cb6bfd5a91f49722c9a82611bce5462 +size 806895 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/01-\347\241\205\350\260\267\351\223\266\350\241\214\344\270\232\345\212\241\347\256\241\347\220\206\347\263\273\347\273\237/01-\347\241\205\350\260\267\351\223\266\350\241\214\344\270\232\345\212\241\347\256\241\347\220\206\347\263\273\347\273\237.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/01-\347\241\205\350\260\267\351\223\266\350\241\214\344\270\232\345\212\241\347\256\241\347\220\206\347\263\273\347\273\237/01-\347\241\205\350\260\267\351\223\266\350\241\214\344\270\232\345\212\241\347\256\241\347\220\206\347\263\273\347\273\237.zip" new file mode 100644 index 0000000000000000000000000000000000000000..a6e6a9a2040bcea33cc44d6f267c0da80155563d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/01-\347\241\205\350\260\267\351\223\266\350\241\214\344\270\232\345\212\241\347\256\241\347\220\206\347\263\273\347\273\237/01-\347\241\205\350\260\267\351\223\266\350\241\214\344\270\232\345\212\241\347\256\241\347\220\206\347\263\273\347\273\237.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17888d7cba6928f3377f57288839de7ad1b796413104bce77c95a611ee49a7fe +size 2671306 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/02-\346\240\241\345\233\255\351\200\232\345\234\250\347\272\277\350\200\203\350\257\225\347\263\273\347\273\237/02-\346\240\241\345\233\255\351\200\232\345\234\250\347\272\277\350\200\203\350\257\225\347\263\273\347\273\237.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/02-\346\240\241\345\233\255\351\200\232\345\234\250\347\272\277\350\200\203\350\257\225\347\263\273\347\273\237/02-\346\240\241\345\233\255\351\200\232\345\234\250\347\272\277\350\200\203\350\257\225\347\263\273\347\273\237.zip" new file mode 100644 index 0000000000000000000000000000000000000000..2f5d382902a937eb58efb8b4b1eaf41b287437cd --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/02-\346\240\241\345\233\255\351\200\232\345\234\250\347\272\277\350\200\203\350\257\225\347\263\273\347\273\237/02-\346\240\241\345\233\255\351\200\232\345\234\250\347\272\277\350\200\203\350\257\225\347\263\273\347\273\237.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:baa579584aee9c7a999481c5c8bb3e6e8ef1fc56b013485f1cd6d4fe35913444 +size 697621 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/03-\350\264\252\345\220\203\350\233\207/03-\350\264\252\345\220\203\350\233\207.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/03-\350\264\252\345\220\203\350\233\207/03-\350\264\252\345\220\203\350\233\207.zip" new file mode 100644 index 0000000000000000000000000000000000000000..36a696eb306825667586285b4a08bb4867efbb9b --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/03-\350\264\252\345\220\203\350\233\207/03-\350\264\252\345\220\203\350\233\207.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3d2568179888b25dd6aefaa875b196831fc8808c6136f39019f9a9b82b1ffce +size 191436 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227.zip" new file mode 100644 index 0000000000000000000000000000000000000000..f5323e91c876205604256741f9a88d4bf166bb62 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6fa1df99757c8a8a084b3196ed99bbb62a51419038889741bae442a861852531 +size 1281525 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/Tetris.iml" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/Tetris.iml" new file mode 100644 index 0000000000000000000000000000000000000000..9465dd864f0bbf5233af344982a638534a50275d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/Tetris.iml" @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/GamePanel.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/GamePanel.java" new file mode 100644 index 0000000000000000000000000000000000000000..b8277842750e6bae6899734aa09f23cf22624c55 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/GamePanel.java" @@ -0,0 +1,375 @@ +package com.atguigu.tetris; + + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.help.Help; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.Arrays; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; + +/** + * 俄罗斯方块游戏面板 + * + */ +public class GamePanel extends JPanel { + /** 正在下落方块 */ + private Tetromino tetromino; + /** 下一个下落方块 */ + private Tetromino nextOne; + /** 行数 */ + public static final int ROWS = 20; + /** 列数 */ + public static final int COLS = 10; + /** 墙,整个游戏画布是10*20的大小 宽是10 高是20 主要用来绘制落下的俄罗斯方块组成的图形,如果某个元素为null,表示该行没有填充完整,即不能消除该行*/ + private Square[][] wall = new Square[ROWS][COLS]; + JFrame frame; + public static final int CELL_SIZE = 26; + + public GamePanel(JFrame frame) { + this.frame = frame; + } + public void action(){ + startAction(); + repaint(); + KeyAdapter l = new KeyAdapter() { + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + //按键盘F1显示帮助 + if(key == KeyEvent.VK_F1){ + Help.showDialog(frame); + } + //按键盘Q退出游戏 + if(key == KeyEvent.VK_Q){ + System.exit(0);//退出当前的Java进程 + } + //如果游戏结束,按S重新开始 + if(gameOver){ + if(key==KeyEvent.VK_S){ + startAction(); + } + return; + } + //如果暂停并且按键是[C]就继续动作 + if(pause){//pause = false + if(key==KeyEvent.VK_C){ continueAction(); } + return; + } + //否则处理其它按键 + switch(key){ + case KeyEvent.VK_RIGHT: moveRightAction(); break; + case KeyEvent.VK_LEFT: moveLeftAction(); break; + case KeyEvent.VK_DOWN: quickDown() ; break; + case KeyEvent.VK_UP: rotateAction() ; break; + case KeyEvent.VK_P: pauseAction() ; break; + } + repaint(); + } + }; + this.requestFocus(); + this.addKeyListener(l); + } + private Timer timer; + /** 分数 */ + private int score; + /** 消掉的行数 */ + private int lines; + private boolean pause; + private boolean gameOver; + /** Tetris 类中添加的方法, 用于启动游戏 */ + public void startAction(){ + //每次启动游戏都清空 + clearWall(); + //随机生成方块 + tetromino = Tetromino.randomTetromino(); + //随机生成下一个方块 + nextOne = Tetromino.randomTetromino(); + //行数 + lines = 0; + //分数 + score = 0; + //暂停键 默认是false,表示不暂停 + pause=false; + //游戏是否结束,默认不结束 + gameOver=false; + //计时器 + timer = new Timer(); + //定时任务,延迟500毫秒后,执行第一次task,然后每隔500毫秒执行一次task + timer.schedule(new TimerTask(){ + public void run() { + slowDropAction(); + repaint(); + } + }, 500, 500); + } + private void clearWall(){ + //将墙的每一行的每个格子清理为null + for(int row=0; row squares = tetromino.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square c = squares.get(i); + int x = c.getCol() * CELL_SIZE-1; + int y = c.getRow() * CELL_SIZE-1; + g.drawImage(c.getImage(), x, y, null); + } + } + + //绘制落下的俄罗斯方块组成的图形 + private void paintWall(Graphics g){ + for(int row=0; row squares = nextOne.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square c = squares.get(i); + int x = (c.getCol()+10) * CELL_SIZE-1; + int y = (c.getRow()+1) * CELL_SIZE-1; + g.drawImage(c.getImage(), x, y, null); + } + } + public static final int FONT_COLOR = 0x667799; + public static final int FONT_SIZE = 0x20; + + /** + * 绘制分数 + * @param g + */ + private void paintScore(Graphics g) { + Font f = getFont();//获取当前的 面板默认字体 + Font font = new Font( + f.getName(), Font.BOLD, FONT_SIZE); + int x = 290; + int y = 162; + g.setColor(new Color(FONT_COLOR)); + g.setFont(font); + String str = "SCORE:"+this.score; + g.drawString(str, x, y); + y+=56; + str = "LINES:"+this.lines; + g.drawString(str, x, y); + y+=56; + str = "[P]Pause"; + if(pause){str = "[C]Continue";} + if(gameOver){ str = "[S]Start!";} + g.drawString(str, x, y); + } + + public void moveRightAction(){ + tetromino.moveRight(); + if(outOfBound() || coincide()){ + tetromino.moveLeft(); + } + } + public void moveLeftAction(){ + tetromino.moveLeft(); + if(outOfBound() || coincide()){ + tetromino.moveRight(); + } + } + + /** + * 检查方块是否出届 + * @return + */ + private boolean outOfBound(){ + List squares = tetromino.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square square = squares.get(i); + int col = square.getCol(); + if(col<0 || col>=COLS){ + return true;//出界了 + } + } + return false; + } + + private boolean coincide(){ + List squares = tetromino.getSquares(); + //for each 循环、迭代,简化了"数组迭代书写" + for(Square square : squares){//增强版for循环 + int row = square.getRow(); + int col = square.getCol(); + if(row<0 || row>=ROWS || col<0 || col>=COLS || + wall[row][col]!=null){ + return true; //墙上有格子对象,发生重合 + } + } + return false; + } + /** 旋转动作 */ + public void rotateAction(){ + tetromino.rotate(); + if(outOfBound() || coincide()){ + tetromino.rotateLeft(); + } + } + /** + * 缓慢下落 + * 完成功能:如果能够下落就下落,否则就落地即可, + * 新的方块出现并开始落下。 + */ + public void slowDropAction(){ + //如果可以下落,则继续下落 + if(tetrominoCanDrop()){ + tetromino.slowDrop(); + return; + } + //不能下落的时候表示到底部或者碰到了已经存在的方块了,需要把当前的方块也放到wall数组中去。 + tetrominoLandToWall(); + //消除当前已经满的行 + destroyLines();//消除满的行 + //判断游戏是否结束 + isGameOver(); + //把下一个俄罗斯方块置为当前的方块 + tetromino = nextOne; + //随机生成下一个方块 + nextOne = Tetromino.randomTetromino(); + } + /** 检查当前的4格方块能否继续下落 */ + public boolean tetrominoCanDrop(){ + List squares = tetromino.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square square = squares.get(i); + int row = square.getRow(); int col = square.getCol(); + //第一个条件判断是否触底 + // 第二个条件判断,是否正下方的第一个方格是否已经存在数组wall中 + // 若存在,表示已经有方块了,则不能继续下落 + if(row == ROWS-1 || wall[row+1][col] != null){ + return false; + } + } + return true; + } + /** 4格方块着陆到墙上,此时存储到二维数组wall中 */ + public void tetrominoLandToWall(){ + List squares = tetromino.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square square = squares.get(i); + int row = square.getRow(); + int col = square.getCol(); + wall[row][col] = square; + } + } + public void deleteRow(int row){ + for(int i=row; i>=1; i--){ + //复制 [i-1] -> [i] + System.arraycopy(wall[i-1], 0, wall[i], 0, COLS); + } + Arrays.fill(wall[0], null); + } + private static final int[] SCORE_TABLE={0,1,10,30,200}; + /** 销毁已经满的行,并且计分 + * 1)迭代每一行 + * 2)如果(检查)某行满是格子了 就销毁这行 + **/ + public void destroyLines(){ + int lines = 0; + for(int row = 0; row键盘方向←:向左移动;" + + "
键盘方向→:向右移动;" + + "
键盘方向↑:方块旋转;" + + "
键盘方向↓:加速下落" + + "
P:暂停" + + "
Q:退出"); + JDialog jDialog = new JDialog(frame); + jDialog.setSize(200,200); + jDialog.add(label); + jDialog.setVisible(true); + //jDialog相对放在jframe的中间 + jDialog.setLocationRelativeTo(frame); + } + +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/I.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/I.png" new file mode 100644 index 0000000000000000000000000000000000000000..ee48d7b6b2d6142b5e66418b0d85e1d4e99f8b3a Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/I.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/J.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/J.png" new file mode 100644 index 0000000000000000000000000000000000000000..618818fc7afb55bb47913012a4082261d27e9408 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/J.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/L.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/L.png" new file mode 100644 index 0000000000000000000000000000000000000000..84c9348f832a101fc140007d2b3452382cbc2f4b Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/L.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/O.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/O.png" new file mode 100644 index 0000000000000000000000000000000000000000..f32e3b58f4d5a52380b2596d4e7130da400e5846 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/O.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/S.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/S.png" new file mode 100644 index 0000000000000000000000000000000000000000..29fedfe0958167e961b7eafa9ebc3afebb9126f5 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/S.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/T.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/T.png" new file mode 100644 index 0000000000000000000000000000000000000000..5055d70bf05716a9ff0b787f1bf42ff77cb2ff1d Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/T.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/Z.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/Z.png" new file mode 100644 index 0000000000000000000000000000000000000000..e9d7fa3aeac3f980984e3f4a6c3fc9832669a01b Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/Z.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/rotatState.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/rotatState.png" new file mode 100644 index 0000000000000000000000000000000000000000..329ea86a612065f91dbd4423c35da3fbf9380a59 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/rotatState.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/tetris.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/tetris.png" new file mode 100644 index 0000000000000000000000000000000000000000..f13be842ce2e82d35986f2d9ea631e506e03bef4 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/image/tetris.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/Coordinate.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/Coordinate.java" new file mode 100644 index 0000000000000000000000000000000000000000..911945d1d2acb909f844546b6ea8f1602965c758 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/Coordinate.java" @@ -0,0 +1,85 @@ +package com.atguigu.tetris.shape; + +/** + * 俄罗斯方块的坐标,每个形状都由4个小方块组成,所以共有8个坐标 + */ +public class Coordinate { + private int row0,col0,row1,col1,row2,col2,row3,col3; + + public Coordinate(int row0, int col0, int row1, int col1, + int row2, int col2, + int row3, int col3) { + this.row0 = row0; + this.col0 = col0; + this.row1 = row1; + this.col1 = col1; + this.row2 = row2; + this.col2 = col2; + this.row3 = row3; + this.col3 = col3; + } + + public int getRow0() { + return row0; + } + + public void setRow0(int row0) { + this.row0 = row0; + } + + public int getCol0() { + return col0; + } + + public void setCol0(int col0) { + this.col0 = col0; + } + + public int getRow1() { + return row1; + } + + public void setRow1(int row1) { + this.row1 = row1; + } + + public int getCol1() { + return col1; + } + + public void setCol1(int col1) { + this.col1 = col1; + } + + public int getRow2() { + return row2; + } + + public void setRow2(int row2) { + this.row2 = row2; + } + + public int getCol2() { + return col2; + } + + public void setCol2(int col2) { + this.col2 = col2; + } + + public int getRow3() { + return row3; + } + + public void setRow3(int row3) { + this.row3 = row3; + } + + public int getCol3() { + return col3; + } + + public void setCol3(int col3) { + this.col3 = col3; + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/I.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/I.java" new file mode 100644 index 0000000000000000000000000000000000000000..f9330f9bf9f7e49e4b0d4ca49f001ce511bcbf68 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/I.java" @@ -0,0 +1,17 @@ +package com.atguigu.tetris.shape; + + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +public class I extends Tetromino { + public I() { + squares.add(new Square(0, 4, Data.I)); + squares.add(new Square(0, 3, Data.I)); + squares.add(new Square(0, 5, Data.I)); + squares.add(new Square(0, 6, Data.I)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, 0,-2)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0,2,0)); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/J.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/J.java" new file mode 100644 index 0000000000000000000000000000000000000000..5aa585de106f091093629352ad70dc832ea9b903 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/J.java" @@ -0,0 +1,20 @@ +package com.atguigu.tetris.shape; + + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +public class J extends Tetromino { + public J() { + squares.add(new Square(0, 4, Data.J)); + squares.add(new Square(0, 3, Data.J)); + squares.add(new Square(0, 5, Data.J)); + squares.add(new Square(0, 5, Data.J)); + coordinateList.add(new Coordinate(0,0, 0,-1, 0,1, 1,1)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0, 1,-1)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, -1,-1)); + coordinateList.add(new Coordinate(0,0, 1,0, -1,0, -1,1 )); + + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/L.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/L.java" new file mode 100644 index 0000000000000000000000000000000000000000..6567dc1b62afaab6e5774627162b052986d8213e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/L.java" @@ -0,0 +1,20 @@ +package com.atguigu.tetris.shape; + + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +public class L extends Tetromino { + public L() { + squares.add(new Square(0, 4, Data.L)); + squares.add(new Square(0, 3, Data.L)); + squares.add(new Square(0, 5, Data.L)); + squares.add(new Square(1, 3, Data.L)); + coordinateList.add(new Coordinate(0,0, 0,-1, 0,1, 1,-1 )); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0, -1,-1)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, -1,1)); + coordinateList.add(new Coordinate(0,0, 1,0, -1,0, 1,1)); + + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/O.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/O.java" new file mode 100644 index 0000000000000000000000000000000000000000..d489e9a7c2421eb69cdf69ae1fb798c8f4606890 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/O.java" @@ -0,0 +1,16 @@ +package com.atguigu.tetris.shape; + + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +public class O extends Tetromino { + public O() { + squares.add(new Square(0, 4, Data.O)); + squares.add(new Square(0, 5, Data.O)); + squares.add(new Square(1, 4, Data.O)); + squares.add(new Square(1, 5, Data.O)); + coordinateList.add(new Coordinate(0,0, 0,1, 1,0, 1,1 )); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/S.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/S.java" new file mode 100644 index 0000000000000000000000000000000000000000..a51b414bc6525d9e1dbfc7b8dbd9ee38a4cca649 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/S.java" @@ -0,0 +1,18 @@ +package com.atguigu.tetris.shape; + + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +public class S extends Tetromino { + + public S() { + squares.add(new Square(0, 4, Data.S)); + squares.add(new Square(0, 5, Data.S)); + squares.add(new Square(1, 3, Data.S)); + squares.add(new Square(1, 4, Data.S)); + coordinateList.add( new Coordinate(0,0, 0,1, 1,-1, 1,0 )); + coordinateList.add( new Coordinate(0,0, -1,0, 1,1, 0,1 )); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/T.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/T.java" new file mode 100644 index 0000000000000000000000000000000000000000..2a77035bd0f059d9d63464cd6ff36e67d17ba131 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/T.java" @@ -0,0 +1,19 @@ +package com.atguigu.tetris.shape; + + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +public class T extends Tetromino { + public T() { + squares.add(new Square(0, 4, Data.T)); + squares.add(new Square(0, 3, Data.T)); + squares.add(new Square(0, 5, Data.T)); + squares.add(new Square(1, 4, Data.T)); + coordinateList.add(new Coordinate(0,0, 0,-1, 0,1, 1, 0)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0, 0,-1)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, -1,0)); + coordinateList.add( new Coordinate(0,0, 1,0, -1,0, 0,1)); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/Z.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/Z.java" new file mode 100644 index 0000000000000000000000000000000000000000..9e305e37721ab2009c2970048098ab557c4d2d06 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/shape/Z.java" @@ -0,0 +1,16 @@ +package com.atguigu.tetris.shape; + +import com.atguigu.tetris.data.Data; +import com.atguigu.tetris.square.Square; +import com.atguigu.tetris.square.Tetromino; + +public class Z extends Tetromino { + public Z() { + squares.add(new Square(1, 4, Data.Z)); + squares.add(new Square(0, 3, Data.Z)); + squares.add(new Square(0, 4, Data.Z)); + squares.add(new Square(1, 5, Data.Z)); + coordinateList.add( new Coordinate(0,0, -1,-1, -1,0, 0,1 )); + coordinateList.add(new Coordinate(0,0, -1,1, 0,1, 1,0 )); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/square/Square.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/square/Square.java" new file mode 100644 index 0000000000000000000000000000000000000000..c19d57e27a6bd5b0a752cbcdc672846af337b43d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/square/Square.java" @@ -0,0 +1,75 @@ +package com.atguigu.tetris.square; + +import java.awt.*; + +/** + * 格子 + * 每一个小方块,就有所在的行 列 和图片 + */ +public class Square { + //方格当前所在行 + private int row; + //方格当前所在列 + private int col; + //格子图片颜色 + private Image image; + + public Square() { + } + + public Square(int row, int col, Image image) { + super(); + this.row = row; + this.col = col; + this.image = image; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getCol() { + return col; + } + + public void setCol(int col) { + this.col = col; + } + + + public Image getImage() { + return image; + } + + public void setImage(Image image) { + this.image = image; + } + /** + * 方格向右移动 + */ + public void moveRight(){ + col++; + } + + /** + * 方格向左移动 + */ + public void moveLeft(){ + col--; + } + /** + * 方格向下移动 + */ + public void moveDown(){ + row++; + } + + @Override + public String toString() { + return "["+row+","+col+"]"; + } +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/square/Tetromino.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/square/Tetromino.java" new file mode 100644 index 0000000000000000000000000000000000000000..712b1be20dac8de8185be5dbf4942115fe3f4a1a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/Tetris/src/com/atguigu/tetris/square/Tetromino.java" @@ -0,0 +1,109 @@ +package com.atguigu.tetris.square; + + + +import com.atguigu.tetris.shape.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * 产生不同形状的方块 + * "O"形是四个方块组成的一个小正方形,每一是一个对称的图形,可以放在左右两边的位置是最合的。代表的颜色是黄色。 + * "I"形是四个小方块排成一竖排组成的。是所有的7种方块中是最长的一种,只有两种可以改变的形式,就是横过来。代表的颜色是蓝色 + * “S”形是四个小方格两两横着相结合,最再将上面的左侧的那个和底下的右侧的那个上下对齐,有四种可以改变的形式。代表的颜色是红色 + * “Z”形和"S"形一样,都是上面两个和下面两个正方形,不同的是是上面的右侧正方形和下侧左侧的正方形对齐,和“S”形是镜面对称的,代表的颜色是绿色。 + * “L”形是左侧的三个三个小方块竖着摞起来,然后右侧最下面和左侧的对齐,形成的形状特别像英语字母的L。代表的颜色是橙色。 + * “J”形和“L”形的形成方式差不多是一样的,也是三个小正方形竖着叠在一起,不过第四个需要加上的小正方形被放到了左边,和“L”也是一个镜面的对称关系。代表颜色是粉色。 + * “T”形也是一个轴对称图形,是三个小正方形横着排,并且在中间的那个小正方形下面加了一个小方块组成的。因为组成的形状类似字母“T”。代表的颜色是紫色。 + * + */ +public class Tetromino { + protected List squares = new ArrayList<>(); + //保存旋转的相对于轴位置状态 + protected List coordinateList = new ArrayList<>(); + /** 随机生成 4格方块, 使用简单工厂方法模式! + * randomTetromino 随机生成一个四格方块 + * 这个方面的返回值是多态的! + * */ + public static Tetromino randomTetromino(){ + Random r = new Random(); + //随机产生7以内的数字,选择不同的方块形状 + int type = r.nextInt(7); + switch(type){ + case 0: return new T(); + case 1: return new I(); + case 2: return new J(); + case 3: return new L(); + case 4: return new O(); + case 5: return new S(); + case 6: return new Z(); + } + return null; + } + + public List getSquares() { + return squares; + } + + /** 下落 */ + public void slowDrop(){ + for(int i = 0; i< squares.size(); i++){ + squares.get(i).moveDown(); + } + } + + /** + * 右移 + */ + public void moveRight(){ + for(int i = 0; i< squares.size(); i++){ + this.squares.get(i).moveRight(); + } + } + + /** + * 左移 + */ + public void moveLeft(){ + for(int i = 0; i< squares.size(); i++){ + squares.get(i).moveLeft(); + } + } + private int index = 4; + /** 在 Tetromino 上添加方法 */ + public void rotate() { + index++; + reLocation(); + } + + /** + * 重新定位坐标 + */ + private void reLocation() { + // index % states.length = 5 % 4 = 1 + Coordinate coordinate = coordinateList.get(index % coordinateList.size()); + // [0] + s1 = [1] + Square o = squares.get(0);//获取当前的轴 + //轴与相对位置的和作为旋转以后的格子位置 + squares.get(1).setRow(o.getRow() + coordinate.getRow1()); + squares.get(1).setCol(o.getCol() + coordinate.getCol1()); + squares.get(2).setRow(o.getRow() + coordinate.getRow2()); + squares.get(2).setCol(o.getCol() + coordinate.getCol2()); + squares.get(3).setRow(o.getRow() + coordinate.getRow3()); + squares.get(3).setCol(o.getCol() + coordinate.getCol3()); + } + public void rotateLeft() { + index--; + Coordinate coordinate = coordinateList.get(index%coordinateList.size()); + Square o = squares.get(0);//获取当前的轴 + squares.get(1).setRow(o.getRow() + coordinate.getRow1()); + squares.get(1).setCol(o.getCol() + coordinate.getCol1()); + squares.get(2).setRow(o.getRow() + coordinate.getRow2()); + squares.get(2).setCol(o.getCol() + coordinate.getCol2()); + squares.get(3).setRow(o.getRow() + coordinate.getRow3()); + squares.get(3).setCol(o.getCol() + coordinate.getCol3()); + } + +} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0cdb2f0e1799e92a2d7f1ff5e1fec314f0c5a01c-20220307142259976.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0cdb2f0e1799e92a2d7f1ff5e1fec314f0c5a01c-20220307142259976.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..17207c68ec081c08d4d927b1878f8417141b0905 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0cdb2f0e1799e92a2d7f1ff5e1fec314f0c5a01c-20220307142259976.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0cdb2f0e1799e92a2d7f1ff5e1fec314f0c5a01c.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0cdb2f0e1799e92a2d7f1ff5e1fec314f0c5a01c.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..17207c68ec081c08d4d927b1878f8417141b0905 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0cdb2f0e1799e92a2d7f1ff5e1fec314f0c5a01c.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0da37be7340f647890e4e30cfd3e21c2bad6b51c-20220307142036270.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0da37be7340f647890e4e30cfd3e21c2bad6b51c-20220307142036270.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..d0d17a13e1d7c0c1cfef48cdc4bb9b848256f37c Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/0da37be7340f647890e4e30cfd3e21c2bad6b51c-20220307142036270.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/76b6860e5f204371f51c6b95323acd8921c58f1c.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/76b6860e5f204371f51c6b95323acd8921c58f1c.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..bc2d19709a1e03ab4e56678b0fb53847d19e4984 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/76b6860e5f204371f51c6b95323acd8921c58f1c.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/890dfb4a2f27e7efecc136b419dd3340b7f3f51c.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/890dfb4a2f27e7efecc136b419dd3340b7f3f51c.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..87df6989f5a1117077375e1d256abed8341d2065 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/890dfb4a2f27e7efecc136b419dd3340b7f3f51c.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/89402670d5413a8c1ecff8ba1ffc508c9ace811c.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/89402670d5413a8c1ecff8ba1ffc508c9ace811c.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..be25205993c359bb7945c6abf7b603948447e4ca Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/89402670d5413a8c1ecff8ba1ffc508c9ace811c.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/94af5fc1b727ac53a64fcc992ecadce89148991c.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/94af5fc1b727ac53a64fcc992ecadce89148991c.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..915126722c0555f08eb1c0fb1973cb9455b26795 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/94af5fc1b727ac53a64fcc992ecadce89148991c.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/9b2098254193cee83fc309ae5a0ff2260c9aa81c.jpg" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/9b2098254193cee83fc309ae5a0ff2260c9aa81c.jpg" new file mode 100644 index 0000000000000000000000000000000000000000..32701c8b11f70da07a2993956714431655350ab6 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/9b2098254193cee83fc309ae5a0ff2260c9aa81c.jpg" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/down-7267609.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/down-7267609.png" new file mode 100644 index 0000000000000000000000000000000000000000..41728f77e80b4707e43fd018023de2eab0e810b9 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/down-7267609.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/down.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/down.png" new file mode 100644 index 0000000000000000000000000000000000000000..41728f77e80b4707e43fd018023de2eab0e810b9 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/down.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220309184953949.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220309184953949.png" new file mode 100644 index 0000000000000000000000000000000000000000..dbd7af62a2ae579502763a84642e82b46489b479 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220309184953949.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315103927360.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315103927360.png" new file mode 100644 index 0000000000000000000000000000000000000000..aa440c37e302f148d348ae8c80b80b9688ad6f59 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315103927360.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315104721073.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315104721073.png" new file mode 100644 index 0000000000000000000000000000000000000000..70f3f6c1ff98bdae7412dc861ac30258dad79afb --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315104721073.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c89df34e7bc89f4bdf87a344237a0254ee926b2dc21bdeadc0723bb3e0e60f9 +size 180435 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315111937736.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315111937736.png" new file mode 100644 index 0000000000000000000000000000000000000000..0815ff1e35b5321df326db113886ef179ec16d7e Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315111937736.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315135325707.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315135325707.png" new file mode 100644 index 0000000000000000000000000000000000000000..9f9d7c6f894c8ee03b783d482f50f5c7a70bc597 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315135325707.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315135552174.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315135552174.png" new file mode 100644 index 0000000000000000000000000000000000000000..a4f3d63b1f938986943f5463a1e3304e8f571b6f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315135552174.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315151136840.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315151136840.png" new file mode 100644 index 0000000000000000000000000000000000000000..768df195271b8e0b286ee341669df49a5a2c7956 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315151136840.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315151710493.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315151710493.png" new file mode 100644 index 0000000000000000000000000000000000000000..9f0cbe02d41c4276880aeea1ffb2cb01dbd0edeb Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315151710493.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315152738036.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315152738036.png" new file mode 100644 index 0000000000000000000000000000000000000000..2c5ef24c671146544c153f996155c035ffba385f Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315152738036.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315152801806.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315152801806.png" new file mode 100644 index 0000000000000000000000000000000000000000..317b520ecd3107d6ad5d60977d9d04011ecdf033 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315152801806.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315155429145.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315155429145.png" new file mode 100644 index 0000000000000000000000000000000000000000..77aafa1c4b6a2fe9b5063dbc0046074e613c4829 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315155429145.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315155442245.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315155442245.png" new file mode 100644 index 0000000000000000000000000000000000000000..88c80673f275803ffde44a973033738e038e2dbd Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315155442245.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315160006610.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315160006610.png" new file mode 100644 index 0000000000000000000000000000000000000000..f78f6d6b5c7412a6e695d2b07479dd3a9216bd10 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315160006610.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315164531501.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315164531501.png" new file mode 100644 index 0000000000000000000000000000000000000000..2c9de8ec8324ebadc69fcd138e1049ca92342aec --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315164531501.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be00d7309db5f6bff92da2f7e01cb5d4311adadb72b76ba88f61b113ca7bf421 +size 154540 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315165329674.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315165329674.png" new file mode 100644 index 0000000000000000000000000000000000000000..51f1c435baabcfce5a271ca05f3b7259eb4eab73 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315165329674.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8296621c5015c9d6efa8750b7a9367ab93493c5a30d57e311f6f5b49022edb87 +size 170104 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315170516971.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315170516971.png" new file mode 100644 index 0000000000000000000000000000000000000000..2387377742f776f027f5cfce2cf915397012f75a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315170516971.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ec741e83d6500273b34f901c49debde1de171dc8b9c4dc6164bdba350c0ede1 +size 169342 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315172359303.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315172359303.png" new file mode 100644 index 0000000000000000000000000000000000000000..c4f55b95791216102f081787a32042a1e61789bb --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/image-20220315172359303.png" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3049d539c8befc719a4b87f3da72e7d493870ca81e5d9730a6c486c3f0cf37e9 +size 167861 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/up.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/up.png" new file mode 100644 index 0000000000000000000000000000000000000000..8cf74c1b5d741c086e123873971bbb9db1b11996 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/images/up.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227.md" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227.md" new file mode 100644 index 0000000000000000000000000000000000000000..1596689be267cff970cfbb75e37856a6cb1ea09f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/04-\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227/\344\277\204\347\275\227\346\226\257\346\226\271\345\235\227.md" @@ -0,0 +1,1149 @@ +# 俄罗斯方块 + +author:尚硅谷 + +*** + +## 1、基础知识 + +​ 俄罗斯方块原名是俄语Тетрис(英语是Tetris),这个名字来源于希腊语tetra,意思是**“四”**。而游戏的作者最喜欢网球(tennis)。于是,他把两个词tetra和tennis合而为一,命名为Tetris,这也就是俄罗斯方块名字的由来。1984年6月,在俄罗斯科学院计算机中心工作的数学家帕基特诺夫利用空闲时间编出一个游戏程序,用来测试当时一种计算机的性能。帕基特诺夫爱玩拼图,从拼图游戏里得到灵感,设计出了俄罗斯方块。 + +​ 俄罗斯方块是一种常见的休闲类游戏,只要将方块在一行填满就可以消除方块并且获得加分。但是方块就主要7种,其他的都是由着七种方块变化出来的。下面就给大家分别介绍一下这几种方块。 + +​ 1. "O"形方块是又四个方块组成的一个小正方形,每一是一个对称的图形,可以放在左右两边的位置是最合的。代表的颜色是黄色。 + +![俄罗斯方块的七种类型](images/0da37be7340f647890e4e30cfd3e21c2bad6b51c-20220307142036270.jpg) + +2. "I"形是四个小方块排成一竖排组成的。是所有的7种方块中是最长的一种,只有两种可以改变的形式,就是横过来。代表的颜色是蓝色 + + ![俄罗斯方块的七种类型](images/9b2098254193cee83fc309ae5a0ff2260c9aa81c.jpg) + +3. “S”形是四个小方格两两横着相结合,最再将上面的左侧的那个和底下的右侧的那个上下对齐,有四种可以改变的形式。代表的颜色是红色 + + ![俄罗斯方块的七种类型](images/0cdb2f0e1799e92a2d7f1ff5e1fec314f0c5a01c-20220307142259976.jpg) + +4. “Z”形和"S"形一样,都是上面两个和下面两个正方形,不同的是是上面的右侧正方形和下侧左侧的正方形对齐,和“S”形是镜面对称的,代表的颜色是绿色。 + + ![俄罗斯方块的七种类型](images/94af5fc1b727ac53a64fcc992ecadce89148991c.jpg) + +5. “L”形是左侧的三个三个小方块竖着摞起来,然后右侧最下面和左侧的对齐,形成的形状特别像英语字母的L。代表的颜色是橙色。 + + ![俄罗斯方块的七种类型](images/76b6860e5f204371f51c6b95323acd8921c58f1c.jpg) + +6. “J”形和“L”形的形成方式差不多是一样的,也是三个小正方形竖着叠在一起,不过第四个需要加上的小正方形被放到了左边,和“L”也是一个镜面的对称关系。代表颜色是粉色。 + + ![俄罗斯方块的七种类型](images/89402670d5413a8c1ecff8ba1ffc508c9ace811c.jpg) + +7. “T”形也是一个轴对称图形,是三个小正方形横着排,并且在中间的那个小正方形下面加了一个小方块组成的。因为组成的形状类似字母“T”。代表的颜色是紫色。 + + ![俄罗斯方块的七种类型](images/890dfb4a2f27e7efecc136b419dd3340b7f3f51c.jpg) + + + +## 2、写一个界面 + +创建一个525*600大小的游戏界面,这里使用JFrame类实现,窗口设置居中。实现代码如下: + +```java +package com.atguigu; + + +import javax.swing.*; + +public class StartGame extends JFrame { + + public static void main(String[] args) { + JFrame frame = new JFrame(); + frame.setSize(525, 600); + frame.setUndecorated(false);//true去掉窗口框! + frame.setTitle("俄罗斯方块"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + //Location 位置 RelativeTo相对于 + frame.setLocationRelativeTo(null);//使当前窗口居中 + frame.setVisible(true); + } +} +``` + +运行结果如下: + +image-20220315103927360 + +### 2.1 游戏帮助 + +帮助按钮,可以查看游戏的规则,如下所示 + +```java +package com.atguigu.help; +import javax.swing.*; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; +public class Help extends JDialog { + //点击帮助按钮显示对话框 + public void showHelp(JFrame frame, JMenu menuFile) { + menuFile.addMenuListener(new MenuListener() { + @Override + public void menuSelected(MenuEvent e) { + showDialog(frame); + } + @Override + public void menuDeselected(MenuEvent e) { + } + @Override + public void menuCanceled(MenuEvent e) { + } + }); + } + public static void showDialog(JFrame frame) { + JLabel label = new JLabel(); + label.setText("键盘方向←:向左移动;" + + "
键盘方向->:向右移动;" + + "
键盘方向↑:方块旋转;" + + "
键盘方向↓:加速下落" + + "
P:暂停" + + "
Q:退出"); + JDialog jDialog = new JDialog(frame); + jDialog.setSize(200,200); + jDialog.add(label); + jDialog.setVisible(true); + //jDialog相对放在jframe的中间 + jDialog.setLocationRelativeTo(frame); + } +} +``` + +在游戏界面main方法中加入帮助按钮,代码如下 + +```java +//创建并添加菜单栏 + JMenuBar menuBar = new JMenuBar(); + frame.setJMenuBar(menuBar); + JMenu menuFile = new JMenu("Help(F1)"); + menuBar.add(menuFile); + //点击帮助按钮显示游戏帮助 + Help help = new Help(); + help.showHelp(frame, menuFile); +``` + +运行结果如下所示 + +image-20220315104721073 + +3、 + +## 3、定义方块类 + +如上面的T形图片,由四个一样的小方块组合起来,所以根据面向对象的思想只需要创建一个格子类即可,如下所示 + +![image-20220309184953949](images/image-20220309184953949.png) + +其他形状同理。 + +### 3.1创建方块类 + +方块类需要有三个属性,分别是所在横坐标,纵坐标以及所用的图片,如果方块向下移动,则列坐标进行加1操作,向左移动,行坐标进行减1操作,向右移动,行坐标进行加1操作, + +```java +package com.atguigu.square; + +import java.awt.*; + +/** + * 格子 + * 每一个小方块,就有所在的行 列 和图片 + */ +public class Square { + //方格当前所在行 + private int row; + //方格当前所在列 + private int col; + //格子图片颜色 + private Image image; + + public Square() { + } + + public Square(int row, int col, Image image) { + super(); + this.row = row; + this.col = col; + this.image = image; + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getCol() { + return col; + } + + public void setCol(int col) { + this.col = col; + } + + + public Image getImage() { + return image; + } + + public void setImage(Image image) { + this.image = image; + } + /** + * 方格向右移动 + */ + public void moveRight(){ + col++; + } + + /** + * 方格向左移动 + */ + public void moveLeft(){ + col--; + } + /** + * 方格向下移动 + */ + public void moveDown(){ + row++; + } + + @Override + public String toString() { + return "["+row+","+col+"]"; + } +} +``` + +## 4、加载静态资源 + +前面图片已经定义好了,需要加载到内存中使用,定义一个静态资源类,如下所示 + +```java +package com.atguigu.data; + +import javax.imageio.ImageIO; +import java.awt.*; + +public class Data { + private static Image background;//背景图片 + public static Image I; + public static Image J; + public static Image L; + public static Image S; + public static Image Z; + public static Image O; + public static Image T; + static{ + try{ + background = ImageIO.read( + Data.class.getResource("image/tetris.png")); + T=ImageIO.read(Data.class.getResource("image/T.png")); + I=ImageIO.read(Data.class.getResource("image/I.png")); + S=ImageIO.read(Data.class.getResource("image/S.png")); + Z=ImageIO.read(Data.class.getResource("image/Z.png")); + L=ImageIO.read(Data.class.getResource("image/L.png")); + J=ImageIO.read(Data.class.getResource("image/J.png")); + O=ImageIO.read(Data.class.getResource("image/O.png")); + }catch(Exception e){ + e.printStackTrace(); + } + } +} +``` + +## 5、创建对应的不同形状的类 + +第3步和第4步已经定义好了每个方块的形状和颜色,接下来需要创建出不同的形状类 + +### 5.1 创建坐标类 + +每种不同形状的俄罗斯方块都由4个小方块组成,所以共有8个坐标,坐标类定义如下所示。 + +```java +package com.atguigu.shape; +/** + * 俄罗斯方块的坐标,每个形状都由4个小方块组成,所以共有8个坐标 + */ +public class Coordinate { + private int row0,col0,row1,col1,row2,col2,row3,col3; + + public Coordinate(int row0, int col0, int row1, int col1, + int row2, int col2, + int row3, int col3) { + this.row0 = row0; + this.col0 = col0; + this.row1 = row1; + this.col1 = col1; + this.row2 = row2; + this.col2 = col2; + this.row3 = row3; + this.col3 = col3; + } + + public int getRow0() { + return row0; + } + + public void setRow0(int row0) { + this.row0 = row0; + } + + public int getCol0() { + return col0; + } + + public void setCol0(int col0) { + this.col0 = col0; + } + + public int getRow1() { + return row1; + } + + public void setRow1(int row1) { + this.row1 = row1; + } + + public int getCol1() { + return col1; + } + + public void setCol1(int col1) { + this.col1 = col1; + } + + public int getRow2() { + return row2; + } + + public void setRow2(int row2) { + this.row2 = row2; + } + + public int getCol2() { + return col2; + } + + public void setCol2(int col2) { + this.col2 = col2; + } + + public int getRow3() { + return row3; + } + + public void setRow3(int row3) { + this.row3 = row3; + } + + public int getCol3() { + return col3; + } + + public void setCol3(int col3) { + this.col3 = col3; + } +} +``` + +接下来创建不同的形状的类,类名使用俄罗斯方块的形状命名 + +### 5.2 创建“I”形类 + +类中定义了两个List,第一个squares用来存储俄罗斯方块的初始化坐标,假如游戏面板定义为10*20的坐标系,那么初始化位置如下所示 + +image-20220315111937736 + +第二个coordinateList用来存储多个形状的相对坐标,寻找其中的某一个方块为定点,以该定点为坐标原点进行图形的旋转,注意此时不能再以10*20为坐标系了, + +假如我们以上图中的[0,4]为新的坐标原点,坐标变为(0,0),其他三个坐标分别是(-1,0),(1,0),(2,0),I形的所有形状总共有2种,分别是竖形和横形,所以应该有2个Coordinate对象,画图如下所示。注意[0,3]是按照行和列来描述的,[-1,0]是按照坐标系来描述的 + +![image-20220315155442245](images/image-20220315155442245.png) + +另一种图形如下所示 + +![image-20220315155429145](images/image-20220315155429145.png) + +可以发现其运算规则为 + +【-1,4】 = 【0,4】+【-1,0】 + +【0,4】=【0,4】+【0,0】 + +【1,4】=【0,4】+【1,0】 + +【2,4】=【0,4】+【2,0】 + +正好是squares集合中的坐标原点的行列加上coordinateList集合中的另一个形状的坐标位置,这里很重要,后面旋转图形的时候需要用到。 + +```java +package com.atguigu.shape; +import com.atguigu.data.Data; +import com.atguigu.square.Square; +import java.util.ArrayList; +import java.util.List; +public class I { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public I() { + squares.add(new Square(0, 4, Data.I)); + squares.add(new Square(0, 3, Data.I)); + squares.add(new Square(0, 5, Data.I)); + squares.add(new Square(0, 6, Data.I)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, 0,-2)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0,2,0)); + } +} +``` + +下面图形的创建也是同理 + +### 5.3 创建“J”形类 + +```java +package com.atguigu.shape; +import com.atguigu.data.Data; +import com.atguigu.square.Square; +import java.util.ArrayList; +import java.util.List; + +public class J { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public J() { + squares.add(new Square(0, 4, Data.J)); + squares.add(new Square(0, 3, Data.J)); + squares.add(new Square(0, 5, Data.J)); + squares.add(new Square(0, 5, Data.J)); + coordinateList.add(new Coordinate(0,0, 0,-1, 0,1, 1,1)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0, 1,-1)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, -1,-1)); + coordinateList.add(new Coordinate(0,0, 1,0, -1,0, -1,1 )); + + } +} +``` + +### 5.4 创建“Z”形类 + +```java +package com.atguigu.shape; + +import com.atguigu.data.Data; +import com.atguigu.square.Square; + +import java.util.ArrayList; +import java.util.List; + + +public class Z { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public Z() { + squares.add(new Square(1, 4, Data.Z)); + squares.add(new Square(0, 3, Data.Z)); + squares.add(new Square(0, 4, Data.Z)); + squares.add(new Square(1, 5, Data.Z)); + coordinateList.add( new Coordinate(0,0, -1,-1, -1,0, 0,1 )); + coordinateList.add(new Coordinate(0,0, -1,1, 0,1, 1,0 )); + + } +} + +``` + +### 5.5 创建“L”形类 + +```java +package com.atguigu.shape; + +import com.atguigu.data.Data; +import com.atguigu.square.Square; +import java.util.ArrayList; +import java.util.List; + + +public class L { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public L() { + squares.add(new Square(0, 4, Data.L)); + squares.add(new Square(0, 3, Data.L)); + squares.add(new Square(0, 5, Data.L)); + squares.add(new Square(1, 3, Data.L)); + coordinateList.add(new Coordinate(0,0, 0,-1, 0,1, 1,-1 )); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0, -1,-1)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, -1,1)); + coordinateList.add(new Coordinate(0,0, 1,0, -1,0, 1,1)); + + } +} +``` + +### 5.6 创建“O”形类 + +```java +package com.atguigu.shape; + +import com.atguigu.data.Data; +import com.atguigu.square.Square; +import java.util.ArrayList; +import java.util.List; + + +public class O { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public O() { + squares.add(new Square(0, 4, Data.O)); + squares.add(new Square(0, 5, Data.O)); + squares.add(new Square(1, 4, Data.O)); + squares.add(new Square(1, 5, Data.O)); + coordinateList.add(new Coordinate(0,0, 0,1, 1,0, 1,1 )); + } +} +``` + +### 5.7 创建“S”形类 + +```java +package com.atguigu.shape; + +import com.atguigu.data.Data; +import com.atguigu.square.Square; +import java.util.ArrayList; +import java.util.List; + + +public class S { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public S() { + squares.add(new Square(0, 4, Data.S)); + squares.add(new Square(0, 5, Data.S)); + squares.add(new Square(1, 3, Data.S)); + squares.add(new Square(1, 4, Data.S)); + coordinateList.add( new Coordinate(0,0, 0,1, 1,-1, 1,0 )); + coordinateList.add( new Coordinate(0,0, -1,0, 1,1, 0,1 )); + } +} +``` + +### 5.8 创建“T”形类 + +```java +package com.atguigu.shape; + +import com.atguigu.data.Data; +import com.atguigu.square.Square; +import java.util.ArrayList; +import java.util.List; +public class T { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public T() { + squares.add(new Square(0, 4, Data.T)); + squares.add(new Square(0, 3, Data.T)); + squares.add(new Square(0, 5, Data.T)); + squares.add(new Square(1, 4, Data.T)); + coordinateList.add(new Coordinate(0,0, 0,-1, 0,1, 1, 0)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0, 0,-1)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, -1,0)); + coordinateList.add( new Coordinate(0,0, 1,0, -1,0, 0,1)); + } +} +``` + +### 5.9 俄罗斯方块的各种行为类 + +该类包含了俄罗斯方块的旋转,移动等方法以及随机生成不同形状的俄罗斯方块方法。因为这里需要返回不同的形状,所以需要让不同形状的类继承该行为类,创建行为类如下 + +```java +public class Tetromino { + public static Tetromino randomTetromino(){ + Random r = new Random(); + //随机产生7以内的数字,选择不同的方块形状 + int type = r.nextInt(7); + switch(type){ + case 0: return new T(); + case 1: return new I(); + case 2: return new J(); + case 3: return new L(); + case 4: return new O(); + case 5: return new S(); + case 6: return new Z(); + } + return null; + } +} +``` + +修改“I”形类如下,其他形状的类同理。 + +```java +public class I extends Tetromino { + private List squares = new ArrayList(); + private List coordinateList = new ArrayList(); + public I() { + squares.add(new Square(0, 4, Data.I)); + squares.add(new Square(0, 3, Data.I)); + squares.add(new Square(0, 5, Data.I)); + squares.add(new Square(0, 6, Data.I)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, 0,-2)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0,2,0)); + } +} +``` + +可以看到每个类当中都有两个list集合,可以直接放到行为类Tetromino中,修改Tetromino类和“I”形类如下所示。 + +```java +public class Tetromino { + protected List squares = new ArrayList<>(); + //保存旋转的相对于轴位置状态 + protected List coordinateList = new ArrayList<>(); + public static Tetromino randomTetromino(){ + Random r = new Random(); + //随机产生7以内的数字,选择不同的方块形状 + int type = r.nextInt(7); + switch(type){ + case 0: return new T(); + case 1: return new I(); + case 2: return new J(); + case 3: return new L(); + case 4: return new O(); + case 5: return new S(); + case 6: return new Z(); + } + return null; + } +} +``` + +“I”形类如下,其他形状类同理 + +```java +public class I extends Tetromino { + public I() { + squares.add(new Square(0, 4, Data.I)); + squares.add(new Square(0, 3, Data.I)); + squares.add(new Square(0, 5, Data.I)); + squares.add(new Square(0, 6, Data.I)); + coordinateList.add(new Coordinate(0,0, 0,1, 0,-1, 0,-2)); + coordinateList.add(new Coordinate(0,0, -1,0, 1,0,2,0)); + } +} +``` + +因为在square类中定义了每个小方块的移动方法,这里需要重新定义一个整体的俄罗斯方块的移动方法,在Tetromino类中添加如下方法 + +```java + /** 下落 */ + public void slowDrop(){ + for(int i = 0; i< squares.size(); i++){ + squares.get(i).moveDown(); + } + } + + /** + * 右移 + */ + public void moveRight(){ + for(int i = 0; i< squares.size(); i++){ + this.squares.get(i).moveRight(); + } + } + + /** + * 左移 + */ + public void moveLeft(){ + for(int i = 0; i< squares.size(); i++){ + squares.get(i).moveLeft(); + } + } +``` + +除了左右移动之外,俄罗斯方块还需要旋转变化不同的形状,其实只需要在coordinateList列表中获取某一个元素即可,其中T形图形最多有4种形态,所以定义一个变量index,每次旋转对index进行加1操作,然后对coordinateList的长度进行取余运算,之后设置squares集合中的第一个元素为坐标原点,获取其本来的行和列,用来计算旋转之后的图形中的各个小方块的行和列,具体的运算规则前面我们已经讲过了,代码实现如下所示 + +```java +private int index = 4; + /** 在 Tetromino 上添加方法 */ + public void rotate() { + index++; + reLocation(); + } + /** + * 重新定位坐标 + */ + private void reLocation() { + // index % states.length = 5 % 4 = 1 + Coordinate coordinate = coordinateList.get(index % coordinateList.size()); + // [0] + s1 = [1] + Square o = squares.get(0);//获取当前的轴 + //轴与相对位置的和作为旋转以后的格子位置 + squares.get(1).setRow(o.getRow() + coordinate.getRow1()); + squares.get(1).setCol(o.getCol() + coordinate.getCol1()); + squares.get(2).setRow(o.getRow() + coordinate.getRow2()); + squares.get(2).setCol(o.getCol() + coordinate.getCol2()); + squares.get(3).setRow(o.getRow() + coordinate.getRow3()); + squares.get(3).setCol(o.getCol() + coordinate.getCol3()); + } +``` + +这里还需要考虑到一种情形就是,当方块到边界的时候,是不可以翻转的,比如T形图在边界如果正好是下图这样 + +image-20220315160006610 + +此时是不可以旋转的,这时候就需要先翻转,然后再翻转回来,其实只需要对index值进行减1操作,再重新设置行和列就可以,在程序计算的时候就好像没有翻转一样,方法如下 + +```java +public void rotateLeft() { + index--; + Coordinate coordinate = coordinateList.get(index%coordinateList.size()); + Square o = squares.get(0);//获取当前的轴 + squares.get(1).setRow(o.getRow() + coordinate.getRow1()); + squares.get(1).setCol(o.getCol() + coordinate.getCol1()); + squares.get(2).setRow(o.getRow() + coordinate.getRow2()); + squares.get(2).setCol(o.getCol() + coordinate.getCol2()); + squares.get(3).setRow(o.getRow() + coordinate.getRow3()); + squares.get(3).setCol(o.getCol() + coordinate.getCol3()); + } +``` + +## 6. 游戏主面板类 + +前面根据面向对象的思想已经整合了很多类,下面最主要的就是创建游戏面板了,游戏面板中,包含如下功能 + +1、绘制当前的俄罗斯方块图形,准备下一个俄罗斯方块图形 + +2、积分展示,消除的行数展示,功能按钮,比如暂停游戏,继续游戏,退出游戏 + +3、根据键盘方向键控制俄罗斯方块的移动以及翻转,边界翻转的判断 + +4、当某行被方块填充无空缺时,消除该行 + +5、手动按F1显示游戏帮助 + +6、游戏结束提示按钮 + +下面开始实现上面的功能 + +### 1、游戏面板 + +首先创建一个游戏面板继承JPanel类,为了添加到frame类中,定义构造方法如下 + +```java +public class GamePanel extends JPanel { + JFrame frame; + public GamePanel(JFrame frame) { + this.frame = frame; + } +} +``` + +### 2、绘制游戏面板和俄罗斯方块 + +paint方法由系统自动调用,绘制一个10*20的网格, + +```java +/** 正在下落方块 */ + private Tetromino tetromino; + /** 下一个下落方块 */ + private Tetromino nextOne; + /** 行数 */ + public static final int ROWS = 20; + /** 列数 */ + public static final int COLS = 10; + /** 墙,整个游戏画布是10*20的大小 宽是10 高是20 主要用来绘制落下的俄罗斯方块组成的图形,如果某个元素为null,表示该行没有填充完整,即不能消除该行*/ + private Square[][] wall = new Square[ROWS][COLS]; + public void action(){ + startAction(); + repaint(); + this.requestFocus(); + } + /** Tetris 类中添加的方法, 用于启动游戏 */ + public void startAction(){ + //每次启动游戏都清空 + clearWall(); + //随机生成方块 + tetromino = Tetromino.randomTetromino(); + //随机生成下一个方块 + nextOne = Tetromino.randomTetromino(); + } + private void clearWall(){ + //将墙的每一行的每个格子清理为null + for(int row=0; row squares = tetromino.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square c = squares.get(i); + int x = c.getCol() * CELL_SIZE-1; + int y = c.getRow() * CELL_SIZE-1; + g.drawImage(c.getImage(), x, y, null); + } + } + //绘制下一个俄罗斯方块 + private void paintNextOne(Graphics g) { + List squares = nextOne.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square c = squares.get(i); + int x = (c.getCol()+10) * CELL_SIZE-1; + int y = (c.getRow()+1) * CELL_SIZE-1; + g.drawImage(c.getImage(), x, y, null); + } + } + } +``` + +在Tetromino类中需要加入以下方法,绘制图形的时候需要俄罗斯方块中的所有小方块的行和列的位置 + +```java +public List getSquares() { + return squares; + } +``` + +通过在游戏入口StartGame类中修改main方法来创建游戏面板,代码如下 + +```java +public static void main(String[] args) { + JFrame frame = new JFrame(); + frame.setSize(525, 600); + frame.setUndecorated(false);//true去掉窗口框! + frame.setTitle("俄罗斯方块"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + //Location 位置 RelativeTo相对于 + frame.setLocationRelativeTo(null);//使当前窗口居中 + //创建并添加菜单栏 + JMenuBar menuBar = new JMenuBar(); + frame.setJMenuBar(menuBar); + JMenu menuFile = new JMenu("Help(F1)"); + menuBar.add(menuFile); + //点击帮助按钮显示游戏帮助 + Help help = new Help(); + help.showHelp(frame, menuFile); + //添加游戏主界面 + GamePanel gamePanel = new GamePanel(frame); + frame.add(gamePanel); + frame.setSize(525, 600); + frame.setUndecorated(false);//true去掉窗口框! + frame.setTitle("俄罗斯方块"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + gamePanel.action(); + } +``` + + 运行结果如下 + +image-20220315164531501 + +### 3、绘制消除的行数和积分文字展示 + +代码如下所示 + +```java +public static final int FONT_COLOR = 0x667799; + public static final int FONT_SIZE = 0x20; + /** 分数 */ + private int score; + /** 消掉的行数 */ + private int lines; + private boolean pause; + private boolean gameOver; + /** + * 绘制分数 + * @param g + */ + private void paintScore(Graphics g) { + Font f = getFont();//获取当前的 面板默认字体 + Font font = new Font( + f.getName(), Font.BOLD, FONT_SIZE); + int x = 290; + int y = 162; + g.setColor(new Color(FONT_COLOR)); + g.setFont(font); + String str = "SCORE:"+this.score; + g.drawString(str, x, y); + y+=56; + str = "LINES:"+this.lines; + g.drawString(str, x, y); + y+=56; + str = "[P]Pause"; + if(pause){str = "[C]Continue";} + if(gameOver){ str = "[S]Start!";} + g.drawString(str, x, y); + } +``` + +在pait方法中调用该方法,如下所示 + +```java +@Override + public void paint(Graphics g){ + g.drawImage(background, 0, 0, null); + g.translate(15, 15);//平移绘图坐标系 + paintTetromino(g);//绘制正在下落的方块 + paintWall(g);//画墙 + paintNextOne(g); + paintScore(g); + } +``` + +运行结果如下。 + +image-20220315165329674 + +### 4、让俄罗斯方块可以动起来 + +包括左右移动,缓慢下落和快速下落 + +首先创建事件监听,修改action()方法如下 + +```java +public void action(){ + startAction(); + repaint(); + KeyAdapter l = new KeyAdapter() { + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + //按键盘F1显示帮助 + if(key == KeyEvent.VK_F1){ + Help.showDialog(frame); + } + //按键盘Q退出游戏 + if(key == KeyEvent.VK_Q){ + System.exit(0);//退出当前的Java进程 + } + //如果游戏结束,按S重新开始 + if(gameOver){ + if(key==KeyEvent.VK_S){ + startAction(); + } + return; + } + //如果暂停并且按键是[C]就继续动作 + if(pause){//pause = false + if(key==KeyEvent.VK_C){ continueAction(); } + return; + } + //否则处理其它按键 + switch(key){ + case KeyEvent.VK_RIGHT: moveRightAction(); break; + case KeyEvent.VK_LEFT: moveLeftAction(); break; + case KeyEvent.VK_DOWN: quickDown() ; break; + case KeyEvent.VK_UP: rotateAction() ; break; + case KeyEvent.VK_P: pauseAction() ; break; + } + repaint(); + } + }; + this.requestFocus(); + this.addKeyListener(l); + } +``` + +此时项目会报错,只需要把对应的方法创建出来即可后面填充该功能 + +```java +/** + * 继续游戏 + */ + public void continueAction(){ + + } + /** + * 快速下落 + */ + public void quickDown(){ + + } + /** + * 暂停游戏 + */ + public void pauseAction(){ + + } +``` + +此时俄罗斯方块已经可以左右移动了,如下所示 + +image-20220315170516971 + +### 5、俄罗斯方块下落 + +接下来需要让俄罗斯方块自动缓慢下落,需要用到一个定时器Timer类,当手动按向下的方向键时快速下落 + +下落的时候需要判断是否还可以继续下落,如果碰到底部或者接触到已经下落的方块时则不能继续下落,代码如下 + +```java +/** + * 缓慢下落 + * 完成功能:如果能够下落就下落,否则就落地即可, + * 新的方块出现并开始落下。 + */ + public void slowDropAction(){ + //如果可以下落,则继续下落 + if(tetrominoCanDrop()){ + tetromino.slowDrop(); + return; + } + //不能下落的时候表示到底部或者碰到了已经存在的方块了,需要把当前的方块也放到wall数组中去。 + tetrominoLandToWall(); + //消除当前已经满的行 + destroyLines();//消除满的行 + //判断游戏是否结束 + isGameOver(); + //把下一个俄罗斯方块置为当前的方块 + tetromino = nextOne; + //随机生成下一个方块 + nextOne = Tetromino.randomTetromino(); + } +``` + +使用定时器自动调用该方法,startAction方法修改如下 + +```java +public void startAction(){ + //每次启动游戏都清空 + clearWall(); + //随机生成方块 + tetromino = Tetromino.randomTetromino(); + //随机生成下一个方块 + nextOne = Tetromino.randomTetromino(); + //行数 + lines = 0; + //分数 + score = 0; + //暂停键 默认是false,表示不暂停 + pause=false; + //游戏是否结束,默认不结束 + gameOver=false; + //计时器 + timer = new Timer(); + //定时任务,延迟500毫秒后,执行第一次task,然后每隔500毫秒执行一次task + timer.schedule(new TimerTask(){ + public void run() { + slowDropAction(); + repaint(); + } + }, 500, 500); + } +``` + +tetrominoCanDrop()方法用来判断是否可以继续下落,实现如下 + +```java +/** 检查当前的4格方块能否继续下落 */ + public boolean tetrominoCanDrop(){ + List squares = tetromino.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square square = squares.get(i); + int row = square.getRow(); int col = square.getCol(); + //第一个条件判断是否触底 + // 第二个条件判断,是否正下方的第一个方格是否已经存在数组wall中 + // 若存在,表示已经有方块了,则不能继续下落 + if(row == ROWS-1 || wall[row+1][col] != null){ + return false; + } + } + return true; + } +``` + +tetrominoLandToWall()方法实现如下,用来把下落的方块放到wall数组中 + +```java +public void tetrominoLandToWall(){ + List squares = tetromino.getSquares(); + for(int i = 0; i< squares.size(); i++){ + Square square = squares.get(i); + int row = square.getRow(); + int col = square.getCol(); + wall[row][col] = square; + } + } +``` + +paintWall方法用来绘制下落的方块组成的图形,俄罗斯方块下落后也要组成新的图形 + +```java +//绘制落下的俄罗斯方块组成的图形 + private void paintWall(Graphics g){ + for(int row=0; row=1; i--){ + //复制 [i-1] -> [i] + System.arraycopy(wall[i-1], 0, wall[i], 0, COLS); + } + Arrays.fill(wall[0], null); + } + +``` + +到此游戏结束 + +image-20220315172359303 \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/05-\347\241\205\350\260\267\346\227\245\345\216\206/05-\347\241\205\350\260\267\346\227\245\345\216\206.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/05-\347\241\205\350\260\267\346\227\245\345\216\206/05-\347\241\205\350\260\267\346\227\245\345\216\206.zip" new file mode 100644 index 0000000000000000000000000000000000000000..eed5c6c811fc97977006a096ddcffa886fdf09fb Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/05-\347\241\205\350\260\267\346\227\245\345\216\206/05-\347\241\205\350\260\267\346\227\245\345\216\206.zip" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/06-\347\227\205\346\257\222\344\274\240\346\222\255\346\250\241\346\213\237/06-\347\227\205\346\257\222\344\274\240\346\222\255\346\250\241\346\213\237.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/06-\347\227\205\346\257\222\344\274\240\346\222\255\346\250\241\346\213\237/06-\347\227\205\346\257\222\344\274\240\346\222\255\346\250\241\346\213\237.zip" new file mode 100644 index 0000000000000000000000000000000000000000..ef3bbec7cd25a24153870cb5a180dde4c8890c3d Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/02-\346\213\223\345\261\225\351\241\271\347\233\256/06-\347\227\205\346\257\222\344\274\240\346\222\255\346\250\241\346\213\237/06-\347\227\205\346\257\222\344\274\240\346\222\255\346\250\241\346\213\237.zip" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\351\241\271\347\233\256\345\274\200\345\217\221\346\265\201\347\250\213\344\270\216\350\247\222\350\211\262.pptx" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\351\241\271\347\233\256\345\274\200\345\217\221\346\265\201\347\250\213\344\270\216\350\247\222\350\211\262.pptx" new file mode 100644 index 0000000000000000000000000000000000000000..05ee87ca16a3ff131435dae87452f54502fcb2e7 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\345\260\232\347\241\205\350\260\267_\345\256\213\347\272\242\345\272\267_\351\241\271\347\233\256\345\274\200\345\217\221\346\265\201\347\250\213\344\270\216\350\247\222\350\211\262.pptx" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a4d7c3fa2cbcc3ded0096c3bcb6eb2a417c8f049d41c4c5d89786f0829e11892 +size 2277237 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\351\241\271\347\233\256\350\246\201\346\261\202.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\351\241\271\347\233\256\350\246\201\346\261\202.txt" new file mode 100644 index 0000000000000000000000000000000000000000..71bae491e0fa9a1b481b305fadadd34d4df6c34a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\351\241\271\347\233\256\350\246\201\346\261\202.txt" @@ -0,0 +1,9 @@ +1.ÖÁÉٶÀÁ¢Íê³Éһ±éÒÔÉϵÄÏîĿ´úÂë + +2.»ýÀÛÍê³ÉÏîĿµĹý³ÌÖг£¼ûµÄbugµĵ÷ÊÔ + +3.ÞÛ˳˼·£¬ǿ»¯Â߼­ + +4.×ñÊرàÂëµĹ淶£¬±êʶ·ûµÄÃüÃû¹淶µÈ + +5.ÔÚÀàǰ¡¢·½·¨ǰ¡¢·½·¨ÄھßÌåÂ߼­µÄʵÏֲ½ÖèµÈÌí¼ӱØҪµÄעÊÍ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\351\241\271\347\233\256\351\230\266\346\256\265\347\232\204\346\200\235\350\200\203.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\351\241\271\347\233\256\351\230\266\346\256\265\347\232\204\346\200\235\350\200\203.txt" new file mode 100644 index 0000000000000000000000000000000000000000..8a77c2e6d4228eb61f8bf3b0d16dea87766c80a2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/05_\345\256\236\346\210\230\351\241\271\347\233\256/\351\241\271\347\233\256\351\230\266\346\256\265\347\232\204\346\200\235\350\200\203.txt" @@ -0,0 +1,18 @@ +1. Ϊʲô֪ʶÌýµö®£¬µ½ÏîĿʱ¾ÍÌý²»¶®ÁË? +> ½²֪ʶʱ£¬É漰µ½µĴúÂëÁ¿É١£ +> ÏîĿ£¬´úÂëÁ¿´ó£¡Â߼­¸´ÔÓ + + +2. ΪʲôÏîĿÌýµö®£¬дµÄʱºò¾Ͳ»֪µÀ´ӺÎÈëÊÖÁË? +> ³ÁÏÂÐÄÀ´£¬ÞÛÞ۾ßÌåÂ߼­¡£ +> ´úÂëһ¶¨ÊÇһµãµãд³öÀ´µģ¡ + + +3. Èç¹ûʱ¼ä½ôÕÅ,ÏîĿûÓÐÁ·ϰÍê,ѧϰºóÃæ֪ʶ»᲻»áÓÐӰÏì? +> ²»»ᣡ + + +4. ÈçºβÅÄÜʹµÃÏîĿÕÆÎյıȽϺÃ? +> Çã¡£¡ + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231.zip" new file mode 100644 index 0000000000000000000000000000000000000000..197972a3cc76ab529f7e8150cb2ae37d6ebafe9e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:449ecfe8a0593bfce46f2198e9d3d4355496de5ed6c395ee06cb95f4ccad6bd3 +size 1949746747 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/._jdk-17.0.2_windows-x64_bin.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/._jdk-17.0.2_windows-x64_bin.exe" new file mode 100644 index 0000000000000000000000000000000000000000..8c0485edf58043d8db928f706e304e743d0fee45 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/._jdk-17.0.2_windows-x64_bin.exe" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/._jdk-8u271-windows-x64.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/._jdk-8u271-windows-x64.exe" new file mode 100644 index 0000000000000000000000000000000000000000..888a204623b737efffbb23d1f48f1490b5a29934 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/._jdk-8u271-windows-x64.exe" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/._jdk-7u7-windows-x64.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/._jdk-7u7-windows-x64.exe" new file mode 100644 index 0000000000000000000000000000000000000000..25a3b0daca861f78812871f9145a2736bc35bf27 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/._jdk-7u7-windows-x64.exe" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/._\344\270\213\350\275\275\351\223\276\346\216\245.docx" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/._\344\270\213\350\275\275\351\223\276\346\216\245.docx" new file mode 100644 index 0000000000000000000000000000000000000000..888a204623b737efffbb23d1f48f1490b5a29934 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/._\344\270\213\350\275\275\351\223\276\346\216\245.docx" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/jdk-7u7-windows-x64.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/jdk-7u7-windows-x64.exe" new file mode 100644 index 0000000000000000000000000000000000000000..62ddd277a1f29858ba2617cb4a9476960882f77a --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/jdk-7u7-windows-x64.exe" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e03b3e20fa5f6c6a319bcb2d2e86730a18598a30171d446322200e98e7446dfb +size 94372320 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/\344\270\213\350\275\275\351\223\276\346\216\245.docx" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/\344\270\213\350\275\275\351\223\276\346\216\245.docx" new file mode 100644 index 0000000000000000000000000000000000000000..75ddc1c7424053fb6c3a4f890b8cb389e5d8dec2 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/JDK\345\205\266\345\256\203\345\220\204\347\211\210\346\234\254\344\270\213\350\275\275\351\223\276\346\216\245/\344\270\213\350\275\275\351\223\276\346\216\245.docx" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e9ec05c1be3a3b47be50b8c0d5d8c44d536af6b67d0c6923692262daad5204a3 +size 420304 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/jdk-17.0.2_windows-x64_bin.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/jdk-17.0.2_windows-x64_bin.exe" new file mode 100644 index 0000000000000000000000000000000000000000..8da4e2573809bc64a91ae65047a0d7cd04e3412f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/jdk-17.0.2_windows-x64_bin.exe" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7e59a195b77f99934732c8d75171c538ab8426da5acef1690448c85e962314e8 +size 159834328 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/jdk-8u271-windows-x64.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/jdk-8u271-windows-x64.exe" new file mode 100644 index 0000000000000000000000000000000000000000..42ca7967712024fa760063bf4620eb947246cf8f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/01-Java\345\274\200\345\217\221\347\216\257\345\242\203-JDK/jdk-8u271-windows-x64.exe" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f172576cb69c42b41fbec63e792ebca9905bea751eaab264828770b57799ada +size 174888584 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213.zip" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213.zip" new file mode 100644 index 0000000000000000000000000000000000000000..40707484c3318416a7691125ab46c102c6531e30 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213.zip" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:28e0c290477863f245e2c8e4a68f9449d2739b2f0b630584ae13549793b38860 +size 294654048 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Java jdk/jdk-8u121-windows-i586.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Java jdk/jdk-8u121-windows-i586.exe" new file mode 100644 index 0000000000000000000000000000000000000000..ac0203852d4a53ad38c3899f2046b5275ae22b7c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Java jdk/jdk-8u121-windows-i586.exe" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b57abcfbcdd42d15626775fb214811328f614a9a9e623d4904bbfd6bb2aac79f +size 198556216 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/java. api/jdk api 1.8_google.CHM" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/java. api/jdk api 1.8_google.CHM" new file mode 100644 index 0000000000000000000000000000000000000000..012504864d940543efdcfd333a0c36a88dfb7811 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/java. api/jdk api 1.8_google.CHM" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ddf90033af5b197d0797f8646e3a80ada465ea554872316cd63a2ff5998a7d67 +size 42871382 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\345\277\253\346\215\267\351\224\256\351\205\215\347\275\256\346\226\271\346\263\225/\345\277\253\351\200\237\347\247\273\345\212\250.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\345\277\253\346\215\267\351\224\256\351\205\215\347\275\256\346\226\271\346\263\225/\345\277\253\351\200\237\347\247\273\345\212\250.txt" new file mode 100644 index 0000000000000000000000000000000000000000..524b1c5e7598c5a25362e0bf76857ca6272bc8a4 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\345\277\253\346\215\267\351\224\256\351\205\215\347\275\256\346\226\271\346\263\225/\345\277\253\351\200\237\347\247\273\345\212\250.txt" @@ -0,0 +1,58 @@ +Ê×ÏÈ×óÊÖʳָºÍÓÒÊÖʳָ,Ãþ×ÅF J °´¼ü,ÉúÎïѧ¿ìËÙÒƶ¯,¿ªÆôµ¶¹⽣Ӱ +¹â±ê×éºÏʵÏÖÉÏÏÂ×óÓҿìËÙÒƶ¯: + +×óAlt+i ¹â±êÉÏÒÆ + +×óAlt+k ¹â±êÏÂÒÆ + +×óAlt+j ¹â±ê×óÒÆ + +×óAlt+L ¹â±êÓÒÒƶ¯ + +»­Ãæ¹ö¶¯¿ì½ݼü: + +ÓÒAlt+E »­ÃæÏòÉϹö¶¯ + +ÓÒAlt+D »­ÃæÏòϹö¶¯ + +ÓÒAlt+S »­ÃæÏò×ó¹ö¶¯ + +ÓÒAlt+F »­ÃæÏòÓҹö¶¯ + +¹â±ê¿ìËÙѡÖпì¼ü¼ü: + +×óCtrl + I ÏòÉÏѡÖÐһÐÐ + +×óCtrl + K ÏòÏÂѡÖÐһÐÐ + +×óCtrl + J Ïò×óѡÖÐһ¸ö×ַû + +×óCtrl + L ÏòÓÒѡÖÐһ¸ö×ַû + +¿ìËÙעÊÍָ¶¨Ðз½·¨: +Ê×ÏÈѡÖÐÐèҪעÊ͵ÄÐÐ +Ȼºó,Ctrl+\ + +ȡÏûעÊͷ½·¨һÑù: +ѡÖÐÐèҪȡÏûעÊ͵ÄÐÐ,ȻºóAlt+\ + +ÔËÐз½·¨: +python +Ïȱ£´æÎļþ ctrl+s,ºó׺ÊÇ.py,ÀýÈç: Hello.py +Ȼºó +ctrl+1 +һ²½ÔËÐÐ + +java +Ïȱ£´æÎļþ ctrl+s,ºó׺ÊÇ.java,ÀýÈç: Hello.java +Ȼºó·ֱð°´×éºϼü +ctrl+1 +ctrl+2 +Á½²½ÔËÐÐ + + +ͨÓÿì½ݼü: +Ctrl+z ³·ÏúÉÏһ²½²Ù×÷ +Ctrl+A ȫѡ +Ctrl+S ±£´æÄÚÈÝ + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\226\271\346\263\225/\351\205\215\347\275\256Java\347\216\257\345\242\203\345\217\230\351\207\217\346\226\271\346\263\225.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\226\271\346\263\225/\351\205\215\347\275\256Java\347\216\257\345\242\203\345\217\230\351\207\217\346\226\271\346\263\225.txt" new file mode 100644 index 0000000000000000000000000000000000000000..6bf4d750b51721cf38ee2697b3bf762da9a8f106 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\216\257\345\242\203\345\217\230\351\207\217\351\205\215\347\275\256\346\226\271\346\263\225/\351\205\215\347\275\256Java\347\216\257\345\242\203\345\217\230\351\207\217\346\226\271\346\263\225.txt" @@ -0,0 +1,44 @@ +二.配置环境变量 + 1. 打开 环境变量窗口:通过 右键我的电脑->属性->高级系统设置->环境变量 进入以下界 +(或者可以通过搜索框直接搜索打开编辑系统环境变量) + + + + + 2.在下方系统变量处点击新建添加一个JAVA_HOME 变量,变量名为“JAVA_HONE”,变量值为安装JDK时的路径,之后点击确定,新建成功。 + + + + + 3.同理,新建/修改一个 CLASSPATH 变量.,这个变量比较特殊,变量名和变量值是固定的。 + +变量名为:ClassPath +变量值为:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; +//变量值前方有一个 “.;” ,后方有一个“ ;”。 +4.修改path变量,在系统变量里通过滚轮找到Path变量,双击进入path变量的编辑后新建两个名为“%JAVA_HOME%\bin”和“%JAVA_HOME%\jre\bin”的环境变量。 + + + + + + + 5.全部点击确定,自此,Java环境变量配置完成 + + + +三.检查Java运行环境是否配置成功: + 1.通过运行命令进行验证:敲击键盘的Windows + R 按键,打开运行提示框,输入cmd + + +2.点击确认进入如下界面: + + + + +3.输入 java -version ,然后回车,若出现以下代码(Java的程序版本),说明配置成功。 +注意事项:"java -version"在Java后面有一个空格,然后是一杠“-”,很多同学因为漏了一个空格然后显示不出结果。 + + + + + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\200\346\255\245/EditPlus5.3.0.2542.7z" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\200\346\255\245/EditPlus5.3.0.2542.7z" new file mode 100644 index 0000000000000000000000000000000000000000..6921ad237d1ad0482c0af9ad473725002e22625d --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\200\346\255\245/EditPlus5.3.0.2542.7z" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8cda7d03c05c9a4b625b882edb284ecfd9c51a250635cc22c32b6fde8cedf4cd +size 2401078 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215.7z" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215.7z" new file mode 100644 index 0000000000000000000000000000000000000000..4a90674039d394be84cadc04a50239944d5b2fc8 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215.7z" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2b6f6c6c9756fbf4ece9c18865aa9f6275d392bad36fc7b5f04026a5f12cab0 +size 1024162 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215/EditPlus.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215/EditPlus.exe" new file mode 100644 index 0000000000000000000000000000000000000000..c99e6da2dac2a6cf273597399a356cd7aa572096 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215/EditPlus.exe" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:361897bc09ca2fb16b873412ce90b949552dbc9d9644f82c6b94f8e1c5f29228 +size 3377864 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215/codepage.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215/codepage.txt" new file mode 100644 index 0000000000000000000000000000000000000000..89f763bbb874979e5f5230a705803565974dab17 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\270\211\346\255\245\346\261\211\345\214\226/EditPlus.4.1.850.64\344\275\215/codepage.txt" @@ -0,0 +1,154 @@ +37 IBM EBCDIC (美国-加拿大) +437 美国 (DOS) +500 IBM EBCDIC (International) +708 Arabic (ASMO 708) +709 Arabic (ASMO 449+, BCON V4) +710 Arabic (Transparent Arabic) +720 Arabic (DOS) +737 Greek (DOS) +775 Baltic (DOS) +850 西欧 (DOS) +852 中欧 (DOS) +855 Cyrillic (DOS) +857 Turkish (DOS) +858 Multilingual Latin I (DOS) +860 Portuguese (DOS) +861 Icelandic (DOS) +862 Hebrew (DOS) +863 French Canadian (DOS) +864 Arabic (864) +865 Nordic (DOS) +866 Cyrillic (DOS) +869 Greek, Modern (DOS) +870 IBM EBCDIC (Multilingual Latin-2) +874 Thai (Windows) +875 IBM EBCDIC (Greek Modern) +932 日文 (Shift-JIS) +936 简体中文 (GB2312) +949 韩文 +950 繁体中文 (Big5) +1026 IBM EBCDIC (Turkish Latin-5) +1047 IBM Latin-1 +1140 IBM EBCDIC (美国-加拿大-欧洲) +1141 IBM EBCDIC (Germany-Euro) +1142 IBM EBCDIC (Denmark-Norway-Euro) +1143 IBM EBCDIC (Finland-Sweden-Euro) +1144 IBM EBCDIC (Italy-Euro) +1145 IBM EBCDIC (Spain-Euro) +1146 IBM EBCDIC (英国-欧洲) +1147 IBM EBCDIC (France-Euro) +1148 IBM EBCDIC (International-Euro) +1149 IBM EBCDIC (Icelandic-Euro) +1200 统一码 +1201 统一码 (大端序) +1250 中欧 (Windows) +1251 Cyrillic (Windows) +1252 西欧 (Windows) +1253 Greek (Windows) +1254 Turkish (Windows) +1255 Hebrew (Windows) +1256 Arabic (Windows) +1257 Baltic (Windows) +1258 Vietnamese (Windows) +1361 韩文 (Johab) +10000 西欧 (Mac) +10001 日文 (Mac) +10002 繁体中文 (Mac) +10003 韩文 (Mac) +10004 Arabic (Mac) +10005 Hebrew (Mac) +10006 Greek (Mac) +10007 Cyrillic (Mac) +10008 简体中文 (Mac) +10010 Romanian (Mac) +10017 Ukrainian (Mac) +10021 Thai (Mac) +10029 中欧 (Mac) +10079 Icelandic (Mac) +10081 Turkish (Mac) +10082 Croatian (Mac) +12000 统一码 UCS-4 小端序 +12001 统一码 UCS-4 大端序 +20000 繁体中文 (CNS) +20001 TCA Taiwan +20002 繁体中文 (倚天) +20003 IBM5550 Taiwan +20004 TeleText Taiwan +20005 Wang Taiwan +20105 西欧 (IA5) +20106 German (IA5) +20107 Swedish (IA5) +20108 Norwegian (IA5) +20127 美国-ASCII +20261 T.61 +20269 ISO-6937 +20273 IBM EBCDIC (Germany) +20277 IBM EBCDIC (Denmark-Norway) +20278 IBM EBCDIC (Finland-Sweden) +20280 IBM EBCDIC (Italy) +20284 IBM EBCDIC (Spain) +20285 IBM EBCDIC (英国) +20290 IBM EBCDIC (日文片假名) +20297 IBM EBCDIC (France) +20420 IBM EBCDIC (Arabic) +20423 IBM EBCDIC (Greek) +20424 IBM EBCDIC (Hebrew) +20833 IBM EBCDIC (韩文扩展) +20838 IBM EBCDIC (Thai) +20866 Cyrillic (KOI8-R) +20871 IBM EBCDIC (Icelandic) +20880 IBM EBCDIC (Cyrillic Russian) +20905 IBM EBCDIC (Turkish) +20924 IBM Latin-1 +20932 日文 (EUC-JP, JIS 0208-1990 和 0212-1990) +20936 简体中文 (GB2312-80) +20949 韩文 Wansung +21025 IBM EBCDIC (Cyrillic Serbian-Bulgarian) +21027 (deprecated) +21866 Cyrillic (KOI8-U) +28591 西欧 (iso-8859-1) +28592 中欧 (iso-8859-2) +28593 Latin 3 (iso-8859-3) +28594 Baltic (iso-8859-4) +28595 Cyrillic (iso-8859-5) +28596 Arabic (iso-8859-6) +28597 Greek (iso-8859-7) +28598 Hebrew (iso-8859-8) +28599 Turkish (iso-8859-9) +28603 Estonian (iso-8859-13) +28605 Latin 9 (iso-8859-15) +29001 Europa +38598 Hebrew (iso-8859-8-i) +50220 日文 (JIS) +50221 日文 (JIS-允许单字节假名) +50222 日文 (JIS-允许单字节假名 - SO/SI) +50225 韩文 (iso-2022-kr) +50227 简体中文 (ISO-2022) +50229 繁体中文 (ISO 2022) +50930 日文 (片假名) 扩展 +50931 US/Canada and 日文 +50933 韩文及扩展 +50935 简体中文及扩展 +50936 简体中文 +50937 US/Canada and 繁体中文 +50939 日文 (Latin) 及扩展 +51932 日文 (EUC) +51936 简体中文 (EUC) +51949 韩文 (EUC) +51950 繁体中文 (EUC) +52936 简体中文 (HZ) +54936 简体中文 (GB18030) +57002 ISCII Devanagari +57003 ISCII Bengali +57004 ISCII Tamil +57005 ISCII Telugu +57006 ISCII Assamese +57007 ISCII Oriya +57008 ISCII Kannada +57009 ISCII Malayalam +57010 ISCII Gujarati +57011 ISCII Punjabi +65000 统一码 (UTF-7) +65001 统一码 (UTF-8) +65005 统一码 (UTF-32) +65006 统一码 (UTF-32 大端序) diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\272\214\346\255\245\350\241\245\344\270\201/epp410p0917_0914_64bit.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\272\214\346\255\245\350\241\245\344\270\201/epp410p0917_0914_64bit.exe" new file mode 100644 index 0000000000000000000000000000000000000000..fe813789af6cd5f1192d24020ee14dffd387176c --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\347\254\254\344\272\214\346\255\245\350\241\245\344\270\201/epp410p0917_0914_64bit.exe" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:237a47d9f2a53fc36c2ad2649e674185de22c33599482563ad16d4e61570af28 +size 2331528 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\350\277\220\350\241\214c++/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\350\277\220\350\241\214c++/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z" new file mode 100644 index 0000000000000000000000000000000000000000..c00becd0ae14beef5a19503ec58be2ffeab4f29e --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\350\277\220\350\241\214c++/x86_64-8.1.0-release-win32-seh-rt_v6-rev0.7z" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:73797b9a1d0b007dbdd6f010e6064dc0aa4df835b042f6947f73a3bf9cc348c5 +size 49403054 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\350\277\220\350\241\214c++/\350\277\220\350\241\214c++\351\205\215\347\275\256.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\350\277\220\350\241\214c++/\350\277\220\350\241\214c++\351\205\215\347\275\256.txt" new file mode 100644 index 0000000000000000000000000000000000000000..cac90ff00d35a004751fc68a672c5cdb114c5340 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\350\277\220\350\241\214c++/\350\277\220\350\241\214c++\351\205\215\347\275\256.txt" @@ -0,0 +1,27 @@ + +g++编译 + +命令: +找到ming64的bin目录下的g++ + +参数: +$(FileName) -o $(FileNameNoExt) -Wall + +起始目录: +$(FileDir) + +动作: 捕获控制台输出 + + +g++运行 +命令: +$(FileNameNoExt) + +参数: +啥也不填 + +起始目录: +$(FileDir) + +动作: +无 \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/template.java" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/template.java" new file mode 100644 index 0000000000000000000000000000000000000000..981fdf3ff4eec4161f9ead909dd8ed1e22084474 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/template.java" @@ -0,0 +1,5 @@ +class template { + public static void main(String[] args) { + System.out.println("ÎÒÊÇɵ±Æ!"); + } +} diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/\346\263\250\345\206\214\347\240\201.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/\346\263\250\345\206\214\347\240\201.txt" new file mode 100644 index 0000000000000000000000000000000000000000..4c67ab54b14647b1f0f5010eb2215287571924a1 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/\346\263\250\345\206\214\347\240\201.txt" @@ -0,0 +1,19 @@ +参考网站: +https://www.jb51.net/ +注册码: +EditPlus4注册码 + +注册名:host1991 +序列号:14F50-CD5C8-E13DA-51100-BAFE6 + +注册名:360xw +注册码:93A52-85B80-A3308-BF130-40412 + +注册名:kariryo +注册码:5387D-12450-BCZ8B-D6W0B-85TE1 + +注册名:crsky +注册码:7879E-5BF58-7DR23-DAOB2-7DR30 + +注册名:zzidc +注册码:11276-E9720-D59E6-BD0E0-2965C \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/\350\277\220\350\241\214java\351\205\215\347\275\256.txt" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/\350\277\220\350\241\214java\351\205\215\347\275\256.txt" new file mode 100644 index 0000000000000000000000000000000000000000..d180a75a4a6a200aa08787ebdcec71d15aec4fa0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/Editplus\344\277\235\345\247\206\347\272\247\346\225\231\347\250\213/\351\205\215\347\275\256/\350\277\220\350\241\214java\351\205\215\347\275\256.txt" @@ -0,0 +1,15 @@ +编译 +$(FileName) + +$(FileDir) + +动作:捕获控制台输出 + +运行 + +$(FileNameNoExt) + +$(FileDir) + +动作:无 + diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/editplus430_64bit.exe" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/editplus430_64bit.exe" new file mode 100644 index 0000000000000000000000000000000000000000..00fa8cd869bd37c25e7737376fd92de52b0ea8a4 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/editplus430_64bit.exe" @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:406b5d91187e2b49df6322e542414f5989bdd703477f09bbccdec15acbd30abd +size 2290952 diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/._EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/._EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201.html" new file mode 100644 index 0000000000000000000000000000000000000000..6755826da1167be928a065e70d7e09133ca2293b Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/._EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201.html" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201.html" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201.html" new file mode 100644 index 0000000000000000000000000000000000000000..11efddc01bc32d4bbdfbf51f94925db35229807f --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201.html" @@ -0,0 +1,808 @@ + + + + + + + + + + + EditPlus各个版本的注册码 - robertyao - 博客园 + + + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+ +
+ + +
+

 

+
+
+
原文链接:https://www.cnblogs.com/shihaiming/p/6422441.html
+

EditPlus4注册码

+

 注册名:host1991
    序列号:14F50-CD5C8-E13DA-51100-BAFE6
 
    注册名:360xw
    注册码:93A52-85B80-A3308-BF130-40412
 
    注册名:kariryo
    注册码:5387D-12450-BCZ8B-D6W0B-85TE1
 
    注册名:crsky
    注册码:7879E-5BF58-7DR23-DAOB2-7DR30
 
    注册名:zzidc
    注册码:11276-E9720-D59E6-BD0E0-2965C

+

EditPlus5.0注册码

+

注册名 Vovan

+

注册码 3AG46-JJ48E-CEACC-8E6EW-ECUAW

+

EditPlus3.x注册码

+

EditPlus注册码生成器链接

+

http://www.jb51.net/tools/editplus/

+

    注册名:gainet
    注册码:74E92-05B20-3D39C-90E5F-A55E8
 
    注册名:kuaiyun
    注册码:9152C-84978-1A3E3-64290-992FD
    授人以鱼不如授人以渔-    editplus 注册码生成链接:
 
    http://www.jb51.net/tools/editplus/

+ +
+ +
+
+
+
+
+ + +
+ +
+ +
+
+ +
+
+
+ 0 +
+
+ 0 +
+
+
+
+
+ +
+
+
+ + « 上一篇: 免费的 PSD、图形和矢量文件 - 365PSD.com +
+ » 下一篇: WPF x:Array的使用 + +
+
+
posted on +2019-10-12 08:39  +robertyao  +阅读(1125)  +评论(0)  +编辑  +收藏
+
+ + + + + +
+ + +
+ +
+ +
+
+ +
+ + + +
+
+ +
+
+
+历史上的今天: +
+ +2017-10-12 WPF 之 TreeView节点重命名 +
+
+ +
+ + + +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+ < + 2020年4月 + > +
+
日一二三四五六
293031 + 1 + + 2 + + 3 + + 4 +
+ 5 + + 6 + + 7 + + 8 + + 9 + + 10 + + 11 +
+ 12 + + 13 + + 14 + + 15 + + 16 + + 17 + + 18 +
+ 19 + + 20 + + 21 + + 22 + + 23 + + 24 + + 25 +
+ 26 + + 27 + + 28 + + 29 + + 30 + + 1 + + 2 +
+ 3 + + 4 + + 5 + + 6 + + 7 + + 8 + + 9 +
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+
+
+ + + + + \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/analytics.js.\344\270\213\350\275\275" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/analytics.js.\344\270\213\350\275\275" new file mode 100644 index 0000000000000000000000000000000000000000..cb2c08b32bdb759947face04f5bac41359aa7b75 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/analytics.js.\344\270\213\350\275\275" @@ -0,0 +1,83 @@ +(function(){/* + + Copyright The Closure Library Authors. + SPDX-License-Identifier: Apache-2.0 +*/ +var m=this||self,n=function(a,b){a=a.split(".");var c=m;a[0]in c||"undefined"==typeof c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c=c[d]&&c[d]!==Object.prototype[d]?c[d]:c[d]={}:c[d]=b};var p=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])},q=function(a){for(var b in a)if(a.hasOwnProperty(b))return!0;return!1};var r=window,t=document,u=function(a,b){t.addEventListener?t.addEventListener(a,b,!1):t.attachEvent&&t.attachEvent("on"+a,b)};var v=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i;var w={},x=function(){w.TAGGING=w.TAGGING||[];w.TAGGING[1]=!0};var y=/:[0-9]+$/,A=function(a,b){b&&(b=String(b).toLowerCase());if("protocol"===b||"port"===b)a.protocol=z(a.protocol)||z(r.location.protocol);"port"===b?a.port=String(Number(a.hostname?a.port:r.location.port)||("http"==a.protocol?80:"https"==a.protocol?443:"")):"host"===b&&(a.hostname=(a.hostname||r.location.hostname).replace(y,"").toLowerCase());var c=z(a.protocol);b&&(b=String(b).toLowerCase());switch(b){case "url_no_fragment":b="";a&&a.href&&(b=a.href.indexOf("#"),b=0>b?a.href:a.href.substr(0, +b));a=b;break;case "protocol":a=c;break;case "host":a=a.hostname.replace(y,"").toLowerCase();break;case "port":a=String(Number(a.port)||("http"==c?80:"https"==c?443:""));break;case "path":a.pathname||a.hostname||x();a="/"==a.pathname.substr(0,1)?a.pathname:"/"+a.pathname;a=a.split("/");a:if(b=a[a.length-1],c=[],Array.prototype.indexOf)b=c.indexOf(b),b="number"==typeof b?b:-1;else{for(var d=0;d>2;e=(e&3)<<4|g>>4;g=(g&15)<<2|h>>6;h&=63;f||(h=64,d||(g=64));b.push(D[k],D[e],D[g],D[h])}return b.join("")} +function H(a){function b(k){for(;d>4);64!=g&&(c+=String.fromCharCode(e<<4&240|g>>2),64!=h&&(c+=String.fromCharCode(g<<6&192|h)))}};var I;var N=function(){var a=J,b=K,c=L(),d=function(g){a(g.target||g.srcElement||{})},f=function(g){b(g.target||g.srcElement||{})};if(!c.init){u("mousedown",d);u("keyup",d);u("submit",f);var e=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){b(this);e.call(this)};c.init=!0}},O=function(a,b,c){for(var d=L().decorators,f={},e=0;ec;c++){for(var d=c,f=0;8>f;f++)d=d&1?d>>>1^ +3988292384:d>>>1;b[c]=d}}I=b;b=4294967295;for(c=0;c>>8^I[(b^a.charCodeAt(c))&255];return((b^-1)>>>0).toString(36)},ca=function(a){return function(b){var c=B(r.location.href),d=c.search.replace("?","");a:{var f=d.split("&");for(var e=0;ec;++c){var d=P.exec(a);if(d){var f=d;break a}a=decodeURIComponent(a)}f=void 0}if(f&&"1"===f[1]){var e=f[2],g=f[3];a:{for(f=0;f>21:b}return b};/* + + Copyright The Closure Library Authors. + SPDX-License-Identifier: Apache-2.0 +*/ +var $c=function(a){this.w=a||[]};$c.prototype.set=function(a){this.w[a]=!0};$c.prototype.encode=function(){for(var a=[],b=0;b=b.length)wc(a,b,c);else if(8192>=b.length)x(a,b,c)||wd(a,b,c)||wc(a,b,c);else throw ge("len",b.length),new Da(b.length);},pe=function(a,b,c,d){d=d||ua;wd(a+"?"+b,"",d,c)},wc=function(a,b,c){var d=ta(a+"?"+b);d.onload=d.onerror=function(){d.onload=null;d.onerror=null;c()}},wd=function(a,b,c, +d){var e=O.XMLHttpRequest;if(!e)return!1;var g=new e;if(!("withCredentials"in g))return!1;a=a.replace(/^http:/,"https:");g.open("POST",a,!0);g.withCredentials=!0;g.setRequestHeader("Content-Type","text/plain");g.onreadystatechange=function(){if(4==g.readyState){if(d)try{var ca=g.responseText;if(1>ca.length)ge("xhr","ver","0"),c();else if("1"!=ca.charAt(0))ge("xhr","ver",String(ca.length)),c();else if(3=100*R(a,Ka))throw"abort";}function Ma(a){if(G(P(a,Na)))throw"abort";}function Oa(){var a=M.location.protocol;if("http:"!=a&&"https:"!=a)throw"abort";} +function Pa(a){try{O.navigator.sendBeacon?J(42):O.XMLHttpRequest&&"withCredentials"in new O.XMLHttpRequest&&J(40)}catch(c){}a.set(ld,Td(a),!0);a.set(Ac,R(a,Ac)+1);var b=[];ue.map(function(c,d){d.F&&(c=a.get(c),void 0!=c&&c!=d.defaultValue&&("boolean"==typeof c&&(c*=1),b.push(d.F+"="+K(""+c))))});!1===a.get(xe)&&b.push("npa=1");b.push("z="+Bd());a.set(Ra,b.join("&"),!0)} +function Sa(a){var b=P(a,fa);!b&&a.get(Vd)&&(b="beacon");var c=P(a,gd),d=P(a,oe),e=c||(d?d+"/3":bd(!1)+"/collect");switch(P(a,ad)){case "d":e=c||(d?d+"/32":bd(!1)+"/j/collect");b=a.get(qe)||void 0;pe(e,P(a,Ra),b,a.Z(Ia));break;case "b":e=c||(d?d+"/31":bd(!1)+"/r/collect");default:b?(c=P(a,Ra),d=(d=a.Z(Ia))||ua,"image"==b?wc(e,c,d):"xhr"==b&&wd(e,c,d)||"beacon"==b&&x(e,c,d)||ba(e,c,d)):ba(e,P(a,Ra),a.Z(Ia))}e=P(a,Na);e=h(e);b=e.hitcount;e.hitcount=b?b+1:1;e=P(a,Na);delete h(e).pending_experiments; +a.set(Ia,ua,!0)}function Hc(a){qc().expId&&a.set(Nc,qc().expId);qc().expVar&&a.set(Oc,qc().expVar);var b=P(a,Na);if(b=h(b).pending_experiments){var c=[];for(d in b)b.hasOwnProperty(d)&&b[d]&&c.push(encodeURIComponent(d)+"."+encodeURIComponent(b[d]));var d=c.join("!")}else d=void 0;d&&a.set(m,d,!0)}function cd(){if(O.navigator&&"preview"==O.navigator.loadPurpose)throw"abort";}function yd(a){var b=O.gaDevIds;ka(b)&&0!=b.length&&a.set("&did",b.join(","),!0)} +function vb(a){if(!a.get(Na))throw"abort";};var hd=function(){return Math.round(2147483647*Math.random())},Bd=function(){try{var a=new Uint32Array(1);O.crypto.getRandomValues(a);return a[0]&2147483647}catch(b){return hd()}};function Ta(a){var b=R(a,Ua);500<=b&&J(15);var c=P(a,Va);if("transaction"!=c&&"item"!=c){c=R(a,Wa);var d=(new Date).getTime(),e=R(a,Xa);0==e&&a.set(Xa,d);e=Math.round(2*(d-e)/1E3);0=c)throw"abort";a.set(Wa,--c)}a.set(Ua,++b)};var Ya=function(){this.data=new ee};Ya.prototype.get=function(a){var b=$a(a),c=this.data.get(a);b&&void 0==c&&(c=ea(b.defaultValue)?b.defaultValue():b.defaultValue);return b&&b.Z?b.Z(this,a,c):c};var P=function(a,b){a=a.get(b);return void 0==a?"":""+a},R=function(a,b){a=a.get(b);return void 0==a||""===a?0:Number(a)};Ya.prototype.Z=function(a){return(a=this.get(a))&&ea(a)?a:ua}; +Ya.prototype.set=function(a,b,c){if(a)if("object"==typeof a)for(var d in a)a.hasOwnProperty(d)&&ab(this,d,a[d],c);else ab(this,a,b,c)};var ab=function(a,b,c,d){if(void 0!=c)switch(b){case Na:wb.test(c)}var e=$a(b);e&&e.o?e.o(a,b,c,d):a.data.set(b,c,d)};var ue=new ee,ve=[],bb=function(a,b,c,d,e){this.name=a;this.F=b;this.Z=d;this.o=e;this.defaultValue=c},$a=function(a){var b=ue.get(a);if(!b)for(var c=0;c=b?!1:!0},gc=function(a){var b={};if(Ec(b)||Fc(b)){var c=b[Eb];void 0==c||Infinity==c||isNaN(c)||(0c)a[b]=void 0},Fd=function(a){return function(b){if("pageview"==b.get(Va)&&!a.I){a.I=!0;var c=aa(b),d=0a.length)J(12);else{for(var d=[],e=0;e=a&&d.push({hash:ca[0],R:e[g],O:ca})}if(0!=d.length)return 1==d.length?d[0]:Zc(b,d)||Zc(c,d)||Zc(null,d)||d[0]}function Zc(a,b){if(null==a)var c=a=1;else c=La(a),a=La(D(a,".")?a.substring(1):"."+a);for(var d=0;d=ca[0]||0>=ca[1]?"":ca.join("x");a.set(rb,c);a.set(tb,fc());a.set(ob,M.characterSet||M.charset);a.set(sb,b&&"function"===typeof b.javaEnabled&&b.javaEnabled()||!1);a.set(nb,(b&&(b.language||b.browserLanguage)||"").toLowerCase());a.data.set(ce,be("gclid",!0));a.data.set(ie,be("gclsrc",!0));a.data.set(fe, +Math.round((new Date).getTime()/1E3));if(d&&a.get(cc)&&(b=M.location.hash)){b=b.split(/[?&#]+/);d=[];for(c=0;carguments.length)){if("string"===typeof arguments[0]){var b=arguments[0];var c=[].slice.call(arguments,1)}else b=arguments[0]&&arguments[0][Va],c=arguments;b&&(c=za(me[b]||[],c),c[Va]=b,this.b.set(c,void 0,!0),this.filters.D(this.b),this.b.data.m={})}};pc.prototype.ma=function(a,b){var c=this;u(a,c,b)||(v(a,function(){u(a,c,b)}),y(String(c.get(V)),a,void 0,b,!0))};var rc=function(a){if("prerender"==M.visibilityState)return!1;a();return!0},z=function(a){if(!rc(a)){J(16);var b=!1,c=function(){if(!b&&rc(a)){b=!0;var d=c,e=M;e.removeEventListener?e.removeEventListener("visibilitychange",d,!1):e.detachEvent&&e.detachEvent("onvisibilitychange",d)}};L(M,"visibilitychange",c)}};var te=/^(?:(\w+)\.)?(?:(\w+):)?(\w+)$/,sc=function(a){if(ea(a[0]))this.u=a[0];else{var b=te.exec(a[0]);null!=b&&4==b.length&&(this.c=b[1]||"t0",this.K=b[2]||"",this.methodName=b[3],this.a=[].slice.call(a,1),this.K||(this.A="create"==this.methodName,this.i="require"==this.methodName,this.g="provide"==this.methodName,this.ba="remove"==this.methodName),this.i&&(3<=this.a.length?(this.X=this.a[1],this.W=this.a[2]):this.a[1]&&(qa(this.a[1])?this.X=this.a[1]:this.W=this.a[1])));b=a[1];a=a[2];if(!this.methodName)throw"abort"; +if(this.i&&(!qa(b)||""==b))throw"abort";if(this.g&&(!qa(b)||""==b||!ea(a)))throw"abort";if(ud(this.c)||ud(this.K))throw"abort";if(this.g&&"t0"!=this.c)throw"abort";}};function ud(a){return 0<=a.indexOf(".")||0<=a.indexOf(":")};var Yd,Zd,$d,A;Yd=new ee;$d=new ee;A=new ee;Zd={ec:45,ecommerce:46,linkid:47}; +var u=function(a,b,c){b==N||b.get(V);var d=Yd.get(a);if(!ea(d))return!1;b.plugins_=b.plugins_||new ee;if(b.plugins_.get(a))return!0;b.plugins_.set(a,new d(b,c||{}));return!0},y=function(a,b,c,d,e){if(!ea(Yd.get(b))&&!$d.get(b)){Zd.hasOwnProperty(b)&&J(Zd[b]);a=N.j(a);if(p.test(b)){J(52);if(!a)return!0;c=d||{};d={id:b,B:c.dataLayer||"dataLayer",ia:!!a.get("anonymizeIp"),sync:e,G:!1};a.get(">m")==b&&(d.G=!0);var g=String(a.get("name"));"t0"!=g&&(d.target=g);G(String(a.get("trackingId")))||(d.clientId= +String(a.get(Q)),d.ka=Number(a.get(n)),c=c.palindrome?r:q,c=(c=M.cookie.replace(/^|(; +)/g,";").match(c))?c.sort().join("").substring(1):void 0,d.la=c,d.qa=E(a.b.get(kb)||"","gclid"));c=d.B;g=(new Date).getTime();O[c]=O[c]||[];g={"gtm.start":g};e||(g.event="gtm.js");O[c].push(g);c=t(d)}!c&&Zd.hasOwnProperty(b)?(J(39),c=b+".js"):J(43);if(c){if(a){var ca=a.get(oe);qa(ca)||(ca=void 0)}c&&0<=c.indexOf("/")||(c=(ca?ca+"/34":bd(!1)+"/plugins/ua/")+c);ca=ae(c);a=ca.protocol;d=M.location.protocol;if(("https:"== +a||a==d||("http:"!=a?0:"http:"==d))&&B(ca)){if(ca=ca.url)a=(a=M.querySelector&&M.querySelector("script[nonce]")||null)?a.nonce||a.getAttribute&&a.getAttribute("nonce")||"":"",e?(e="",a&&Nd.test(a)&&(e=' nonce="'+a+'"'),f.test(ca)&&M.write("\x3c/script>')):(e=M.createElement("script"),e.type="text/javascript",e.async=!0,e.src=ca,a&&e.setAttribute("nonce",a),ca=M.getElementsByTagName("script")[0],ca.parentNode.insertBefore(e,ca));$d.set(b,!0)}}}},v=function(a,b){var c=A.get(a)|| +[];c.push(b);A.set(a,c)},C=function(a,b){Yd.set(a,b);b=A.get(a)||[];for(var c=0;ca.split("/")[0].indexOf(":")&&(a=ca+e[2].substring(0,e[2].lastIndexOf("/"))+"/"+a);c.href=a; +d=b(c);return{protocol:(c.protocol||"").toLowerCase(),host:d[0],port:d[1],path:d[2],query:c.search||"",url:a||""}};var Z={ga:function(){Z.f=[]}};Z.ga();Z.D=function(a){var b=Z.J.apply(Z,arguments);b=Z.f.concat(b);for(Z.f=[];0c;c++){var d=b[c].src;if(d&&0==d.indexOf(bd(!0)+ +"/analytics")){b=!0;break a}}b=!1}b&&(Ba=!0)}(O.gaplugins=O.gaplugins||{}).Linker=Dc;b=Dc.prototype;C("linker",Dc);X("decorate",b,b.ca,20);X("autoLink",b,b.S,25);C("displayfeatures",fd);C("adfeatures",fd);a=a&&a.q;ka(a)?Z.D.apply(N,a):J(50)}};N.da=function(){for(var a=N.getAll(),b=0;b.newline{display:block}.katex .base{position:relative;display:inline-block;white-space:nowrap;width:min-content}.katex .strut{display:inline-block}.katex .textbf{font-weight:bold}.katex .textit{font-style:italic}.katex .textrm{font-family:KaTeX_Main}.katex .textsf{font-family:KaTeX_SansSerif}.katex .texttt{font-family:KaTeX_Typewriter}.katex .mathdefault{font-family:KaTeX_Math;font-style:italic}.katex .mathit{font-family:KaTeX_Main;font-style:italic}.katex .mathrm{font-style:normal}.katex .mathbf{font-family:KaTeX_Main;font-weight:bold}.katex .boldsymbol{font-family:KaTeX_Math;font-weight:bold;font-style:italic}.katex .amsrm{font-family:KaTeX_AMS}.katex .mathbb,.katex .textbb{font-family:KaTeX_AMS}.katex .mathcal{font-family:KaTeX_Caligraphic}.katex .mathfrak,.katex .textfrak{font-family:KaTeX_Fraktur}.katex .mathtt{font-family:KaTeX_Typewriter}.katex .mathscr,.katex .textscr{font-family:KaTeX_Script}.katex .mathsf,.katex .textsf{font-family:KaTeX_SansSerif}.katex .mathboldsf,.katex .textboldsf{font-family:KaTeX_SansSerif;font-weight:bold}.katex .mathitsf,.katex .textitsf{font-family:KaTeX_SansSerif;font-style:italic}.katex .mainrm{font-family:KaTeX_Main;font-style:normal}.katex .vlist-t{display:inline-table;table-layout:fixed}.katex .vlist-r{display:table-row}.katex .vlist{display:table-cell;vertical-align:bottom;position:relative}.katex .vlist>span{display:block;height:0;position:relative}.katex .vlist>span>span{display:inline-block}.katex .vlist>span>.pstrut{overflow:hidden;width:0}.katex .vlist-t2{margin-right:-2px}.katex .vlist-s{display:table-cell;vertical-align:bottom;font-size:1px;width:2px;min-width:2px}.katex .msupsub{text-align:left}.katex .mfrac>span>span{text-align:center}.katex .mfrac .frac-line{display:inline-block;width:100%;border-bottom-style:solid}.katex .mfrac .frac-line,.katex .overline .overline-line,.katex .underline .underline-line,.katex .hline,.katex .hdashline,.katex .rule{min-height:1px}.katex .mspace{display:inline-block}.katex .llap,.katex .rlap,.katex .clap{width:0;position:relative}.katex .llap>.inner,.katex .rlap>.inner,.katex .clap>.inner{position:absolute}.katex .llap>.fix,.katex .rlap>.fix,.katex .clap>.fix{display:inline-block}.katex .llap>.inner{right:0}.katex .rlap>.inner,.katex .clap>.inner{left:0}.katex .clap>.inner>span{margin-left:-50%;margin-right:50%}.katex .rule{display:inline-block;border:solid 0;position:relative}.katex .overline .overline-line,.katex .underline .underline-line,.katex .hline{display:inline-block;width:100%;border-bottom-style:solid}.katex .hdashline{display:inline-block;width:100%;border-bottom-style:dashed}.katex .sqrt>.root{margin-left:.27777778em;margin-right:-.55555556em}.katex .sizing.reset-size1.size1,.katex .fontsize-ensurer.reset-size1.size1{font-size:1em}.katex .sizing.reset-size1.size2,.katex .fontsize-ensurer.reset-size1.size2{font-size:1.2em}.katex .sizing.reset-size1.size3,.katex .fontsize-ensurer.reset-size1.size3{font-size:1.4em}.katex .sizing.reset-size1.size4,.katex .fontsize-ensurer.reset-size1.size4{font-size:1.6em}.katex .sizing.reset-size1.size5,.katex .fontsize-ensurer.reset-size1.size5{font-size:1.8em}.katex .sizing.reset-size1.size6,.katex .fontsize-ensurer.reset-size1.size6{font-size:2em}.katex .sizing.reset-size1.size7,.katex .fontsize-ensurer.reset-size1.size7{font-size:2.4em}.katex .sizing.reset-size1.size8,.katex .fontsize-ensurer.reset-size1.size8{font-size:2.88em}.katex .sizing.reset-size1.size9,.katex .fontsize-ensurer.reset-size1.size9{font-size:3.456em}.katex .sizing.reset-size1.size10,.katex .fontsize-ensurer.reset-size1.size10{font-size:4.148em}.katex .sizing.reset-size1.size11,.katex .fontsize-ensurer.reset-size1.size11{font-size:4.976em}.katex .sizing.reset-size2.size1,.katex .fontsize-ensurer.reset-size2.size1{font-size:.83333333em}.katex .sizing.reset-size2.size2,.katex .fontsize-ensurer.reset-size2.size2{font-size:1em}.katex .sizing.reset-size2.size3,.katex .fontsize-ensurer.reset-size2.size3{font-size:1.16666667em}.katex .sizing.reset-size2.size4,.katex .fontsize-ensurer.reset-size2.size4{font-size:1.33333333em}.katex .sizing.reset-size2.size5,.katex .fontsize-ensurer.reset-size2.size5{font-size:1.5em}.katex .sizing.reset-size2.size6,.katex .fontsize-ensurer.reset-size2.size6{font-size:1.66666667em}.katex .sizing.reset-size2.size7,.katex .fontsize-ensurer.reset-size2.size7{font-size:2em}.katex .sizing.reset-size2.size8,.katex .fontsize-ensurer.reset-size2.size8{font-size:2.4em}.katex .sizing.reset-size2.size9,.katex .fontsize-ensurer.reset-size2.size9{font-size:2.88em}.katex .sizing.reset-size2.size10,.katex .fontsize-ensurer.reset-size2.size10{font-size:3.45666667em}.katex .sizing.reset-size2.size11,.katex .fontsize-ensurer.reset-size2.size11{font-size:4.14666667em}.katex .sizing.reset-size3.size1,.katex .fontsize-ensurer.reset-size3.size1{font-size:.71428571em}.katex .sizing.reset-size3.size2,.katex .fontsize-ensurer.reset-size3.size2{font-size:.85714286em}.katex .sizing.reset-size3.size3,.katex .fontsize-ensurer.reset-size3.size3{font-size:1em}.katex .sizing.reset-size3.size4,.katex .fontsize-ensurer.reset-size3.size4{font-size:1.14285714em}.katex .sizing.reset-size3.size5,.katex .fontsize-ensurer.reset-size3.size5{font-size:1.28571429em}.katex .sizing.reset-size3.size6,.katex .fontsize-ensurer.reset-size3.size6{font-size:1.42857143em}.katex .sizing.reset-size3.size7,.katex .fontsize-ensurer.reset-size3.size7{font-size:1.71428571em}.katex .sizing.reset-size3.size8,.katex .fontsize-ensurer.reset-size3.size8{font-size:2.05714286em}.katex .sizing.reset-size3.size9,.katex .fontsize-ensurer.reset-size3.size9{font-size:2.46857143em}.katex .sizing.reset-size3.size10,.katex .fontsize-ensurer.reset-size3.size10{font-size:2.96285714em}.katex .sizing.reset-size3.size11,.katex .fontsize-ensurer.reset-size3.size11{font-size:3.55428571em}.katex .sizing.reset-size4.size1,.katex .fontsize-ensurer.reset-size4.size1{font-size:.625em}.katex .sizing.reset-size4.size2,.katex .fontsize-ensurer.reset-size4.size2{font-size:.75em}.katex .sizing.reset-size4.size3,.katex .fontsize-ensurer.reset-size4.size3{font-size:.875em}.katex .sizing.reset-size4.size4,.katex .fontsize-ensurer.reset-size4.size4{font-size:1em}.katex .sizing.reset-size4.size5,.katex .fontsize-ensurer.reset-size4.size5{font-size:1.125em}.katex .sizing.reset-size4.size6,.katex .fontsize-ensurer.reset-size4.size6{font-size:1.25em}.katex .sizing.reset-size4.size7,.katex .fontsize-ensurer.reset-size4.size7{font-size:1.5em}.katex .sizing.reset-size4.size8,.katex .fontsize-ensurer.reset-size4.size8{font-size:1.8em}.katex .sizing.reset-size4.size9,.katex .fontsize-ensurer.reset-size4.size9{font-size:2.16em}.katex .sizing.reset-size4.size10,.katex .fontsize-ensurer.reset-size4.size10{font-size:2.5925em}.katex .sizing.reset-size4.size11,.katex .fontsize-ensurer.reset-size4.size11{font-size:3.11em}.katex .sizing.reset-size5.size1,.katex .fontsize-ensurer.reset-size5.size1{font-size:.55555556em}.katex .sizing.reset-size5.size2,.katex .fontsize-ensurer.reset-size5.size2{font-size:.66666667em}.katex .sizing.reset-size5.size3,.katex .fontsize-ensurer.reset-size5.size3{font-size:.77777778em}.katex .sizing.reset-size5.size4,.katex .fontsize-ensurer.reset-size5.size4{font-size:.88888889em}.katex .sizing.reset-size5.size5,.katex .fontsize-ensurer.reset-size5.size5{font-size:1em}.katex .sizing.reset-size5.size6,.katex .fontsize-ensurer.reset-size5.size6{font-size:1.11111111em}.katex .sizing.reset-size5.size7,.katex .fontsize-ensurer.reset-size5.size7{font-size:1.33333333em}.katex .sizing.reset-size5.size8,.katex .fontsize-ensurer.reset-size5.size8{font-size:1.6em}.katex .sizing.reset-size5.size9,.katex .fontsize-ensurer.reset-size5.size9{font-size:1.92em}.katex .sizing.reset-size5.size10,.katex .fontsize-ensurer.reset-size5.size10{font-size:2.30444444em}.katex .sizing.reset-size5.size11,.katex .fontsize-ensurer.reset-size5.size11{font-size:2.76444444em}.katex .sizing.reset-size6.size1,.katex .fontsize-ensurer.reset-size6.size1{font-size:.5em}.katex .sizing.reset-size6.size2,.katex .fontsize-ensurer.reset-size6.size2{font-size:.6em}.katex .sizing.reset-size6.size3,.katex .fontsize-ensurer.reset-size6.size3{font-size:.7em}.katex .sizing.reset-size6.size4,.katex .fontsize-ensurer.reset-size6.size4{font-size:.8em}.katex .sizing.reset-size6.size5,.katex .fontsize-ensurer.reset-size6.size5{font-size:.9em}.katex .sizing.reset-size6.size6,.katex .fontsize-ensurer.reset-size6.size6{font-size:1em}.katex .sizing.reset-size6.size7,.katex .fontsize-ensurer.reset-size6.size7{font-size:1.2em}.katex .sizing.reset-size6.size8,.katex .fontsize-ensurer.reset-size6.size8{font-size:1.44em}.katex .sizing.reset-size6.size9,.katex .fontsize-ensurer.reset-size6.size9{font-size:1.728em}.katex .sizing.reset-size6.size10,.katex .fontsize-ensurer.reset-size6.size10{font-size:2.074em}.katex .sizing.reset-size6.size11,.katex .fontsize-ensurer.reset-size6.size11{font-size:2.488em}.katex .sizing.reset-size7.size1,.katex .fontsize-ensurer.reset-size7.size1{font-size:.41666667em}.katex .sizing.reset-size7.size2,.katex .fontsize-ensurer.reset-size7.size2{font-size:.5em}.katex .sizing.reset-size7.size3,.katex .fontsize-ensurer.reset-size7.size3{font-size:.58333333em}.katex .sizing.reset-size7.size4,.katex .fontsize-ensurer.reset-size7.size4{font-size:.66666667em}.katex .sizing.reset-size7.size5,.katex .fontsize-ensurer.reset-size7.size5{font-size:.75em}.katex .sizing.reset-size7.size6,.katex .fontsize-ensurer.reset-size7.size6{font-size:.83333333em}.katex .sizing.reset-size7.size7,.katex .fontsize-ensurer.reset-size7.size7{font-size:1em}.katex .sizing.reset-size7.size8,.katex .fontsize-ensurer.reset-size7.size8{font-size:1.2em}.katex .sizing.reset-size7.size9,.katex .fontsize-ensurer.reset-size7.size9{font-size:1.44em}.katex .sizing.reset-size7.size10,.katex .fontsize-ensurer.reset-size7.size10{font-size:1.72833333em}.katex .sizing.reset-size7.size11,.katex .fontsize-ensurer.reset-size7.size11{font-size:2.07333333em}.katex .sizing.reset-size8.size1,.katex .fontsize-ensurer.reset-size8.size1{font-size:.34722222em}.katex .sizing.reset-size8.size2,.katex .fontsize-ensurer.reset-size8.size2{font-size:.41666667em}.katex .sizing.reset-size8.size3,.katex .fontsize-ensurer.reset-size8.size3{font-size:.48611111em}.katex .sizing.reset-size8.size4,.katex .fontsize-ensurer.reset-size8.size4{font-size:.55555556em}.katex .sizing.reset-size8.size5,.katex .fontsize-ensurer.reset-size8.size5{font-size:.625em}.katex .sizing.reset-size8.size6,.katex .fontsize-ensurer.reset-size8.size6{font-size:.69444444em}.katex .sizing.reset-size8.size7,.katex .fontsize-ensurer.reset-size8.size7{font-size:.83333333em}.katex .sizing.reset-size8.size8,.katex .fontsize-ensurer.reset-size8.size8{font-size:1em}.katex .sizing.reset-size8.size9,.katex .fontsize-ensurer.reset-size8.size9{font-size:1.2em}.katex .sizing.reset-size8.size10,.katex .fontsize-ensurer.reset-size8.size10{font-size:1.44027778em}.katex .sizing.reset-size8.size11,.katex .fontsize-ensurer.reset-size8.size11{font-size:1.72777778em}.katex .sizing.reset-size9.size1,.katex .fontsize-ensurer.reset-size9.size1{font-size:.28935185em}.katex .sizing.reset-size9.size2,.katex .fontsize-ensurer.reset-size9.size2{font-size:.34722222em}.katex .sizing.reset-size9.size3,.katex .fontsize-ensurer.reset-size9.size3{font-size:.40509259em}.katex .sizing.reset-size9.size4,.katex .fontsize-ensurer.reset-size9.size4{font-size:.46296296em}.katex .sizing.reset-size9.size5,.katex .fontsize-ensurer.reset-size9.size5{font-size:.52083333em}.katex .sizing.reset-size9.size6,.katex .fontsize-ensurer.reset-size9.size6{font-size:.5787037em}.katex .sizing.reset-size9.size7,.katex .fontsize-ensurer.reset-size9.size7{font-size:.69444444em}.katex .sizing.reset-size9.size8,.katex .fontsize-ensurer.reset-size9.size8{font-size:.83333333em}.katex .sizing.reset-size9.size9,.katex .fontsize-ensurer.reset-size9.size9{font-size:1em}.katex .sizing.reset-size9.size10,.katex .fontsize-ensurer.reset-size9.size10{font-size:1.20023148em}.katex .sizing.reset-size9.size11,.katex .fontsize-ensurer.reset-size9.size11{font-size:1.43981481em}.katex .sizing.reset-size10.size1,.katex .fontsize-ensurer.reset-size10.size1{font-size:.24108004em}.katex .sizing.reset-size10.size2,.katex .fontsize-ensurer.reset-size10.size2{font-size:.28929605em}.katex .sizing.reset-size10.size3,.katex .fontsize-ensurer.reset-size10.size3{font-size:.33751205em}.katex .sizing.reset-size10.size4,.katex .fontsize-ensurer.reset-size10.size4{font-size:.38572806em}.katex .sizing.reset-size10.size5,.katex .fontsize-ensurer.reset-size10.size5{font-size:.43394407em}.katex .sizing.reset-size10.size6,.katex .fontsize-ensurer.reset-size10.size6{font-size:.48216008em}.katex .sizing.reset-size10.size7,.katex .fontsize-ensurer.reset-size10.size7{font-size:.57859209em}.katex .sizing.reset-size10.size8,.katex .fontsize-ensurer.reset-size10.size8{font-size:.69431051em}.katex .sizing.reset-size10.size9,.katex .fontsize-ensurer.reset-size10.size9{font-size:.83317261em}.katex .sizing.reset-size10.size10,.katex .fontsize-ensurer.reset-size10.size10{font-size:1em}.katex .sizing.reset-size10.size11,.katex .fontsize-ensurer.reset-size10.size11{font-size:1.19961427em}.katex .sizing.reset-size11.size1,.katex .fontsize-ensurer.reset-size11.size1{font-size:.20096463em}.katex .sizing.reset-size11.size2,.katex .fontsize-ensurer.reset-size11.size2{font-size:.24115756em}.katex .sizing.reset-size11.size3,.katex .fontsize-ensurer.reset-size11.size3{font-size:.28135048em}.katex .sizing.reset-size11.size4,.katex .fontsize-ensurer.reset-size11.size4{font-size:.32154341em}.katex .sizing.reset-size11.size5,.katex .fontsize-ensurer.reset-size11.size5{font-size:.36173633em}.katex .sizing.reset-size11.size6,.katex .fontsize-ensurer.reset-size11.size6{font-size:.40192926em}.katex .sizing.reset-size11.size7,.katex .fontsize-ensurer.reset-size11.size7{font-size:.48231511em}.katex .sizing.reset-size11.size8,.katex .fontsize-ensurer.reset-size11.size8{font-size:.57877814em}.katex .sizing.reset-size11.size9,.katex .fontsize-ensurer.reset-size11.size9{font-size:.69453376em}.katex .sizing.reset-size11.size10,.katex .fontsize-ensurer.reset-size11.size10{font-size:.83360129em}.katex .sizing.reset-size11.size11,.katex .fontsize-ensurer.reset-size11.size11{font-size:1em}.katex .delimsizing.size1{font-family:KaTeX_Size1}.katex .delimsizing.size2{font-family:KaTeX_Size2}.katex .delimsizing.size3{font-family:KaTeX_Size3}.katex .delimsizing.size4{font-family:KaTeX_Size4}.katex .delimsizing.mult .delim-size1>span{font-family:KaTeX_Size1}.katex .delimsizing.mult .delim-size4>span{font-family:KaTeX_Size4}.katex .nulldelimiter{display:inline-block;width:.12em}.katex .delimcenter{position:relative}.katex .op-symbol{position:relative}.katex .op-symbol.small-op{font-family:KaTeX_Size1}.katex .op-symbol.large-op{font-family:KaTeX_Size2}.katex .op-limits>.vlist-t{text-align:center}.katex .accent>.vlist-t{text-align:center}.katex .accent .accent-body{position:relative}.katex .accent .accent-body:not(.accent-full){width:0}.katex .overlay{display:block}.katex .mtable .vertical-separator{display:inline-block;min-width:1px}.katex .mtable .arraycolsep{display:inline-block}.katex .mtable .col-align-c>.vlist-t{text-align:center}.katex .mtable .col-align-l>.vlist-t{text-align:left}.katex .mtable .col-align-r>.vlist-t{text-align:right}.katex .svg-align{text-align:left}.katex svg{display:block;position:absolute;width:100%;height:inherit;fill:currentColor;stroke:currentColor;fill-rule:nonzero;fill-opacity:1;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1}.katex svg path{stroke:none}.katex img{border-style:none;min-width:0;min-height:0;max-width:none;max-height:none}.katex .stretchy{width:100%;display:block;position:relative;overflow:hidden}.katex .stretchy::before,.katex .stretchy::after{content:""}.katex .hide-tail{width:100%;position:relative;overflow:hidden}.katex .halfarrow-left{position:absolute;left:0;width:50.2%;overflow:hidden}.katex .halfarrow-right{position:absolute;right:0;width:50.2%;overflow:hidden}.katex .brace-left{position:absolute;left:0;width:25.1%;overflow:hidden}.katex .brace-center{position:absolute;left:25%;width:50%;overflow:hidden}.katex .brace-right{position:absolute;right:0;width:25.1%;overflow:hidden}.katex .x-arrow-pad{padding:0 .5em}.katex .x-arrow,.katex .mover,.katex .munder{text-align:center}.katex .boxpad{padding:0 .3em 0 .3em}.katex .fbox,.katex .fcolorbox{box-sizing:border-box;border:.04em solid}.katex .cancel-pad{padding:0 .2em 0 .2em}.katex .cancel-lap{margin-left:-.2em;margin-right:-.2em}.katex .sout{border-bottom-style:solid;border-bottom-width:.08em}.katex-display{display:block;margin:1em 0;text-align:center}.katex-display>.katex{display:block;text-align:center;white-space:nowrap}.katex-display>.katex>.katex-html{display:block;position:relative}.katex-display>.katex>.katex-html>.tag{position:absolute;right:0}.katex-display.leqno>.katex>.katex-html>.tag{left:0;right:auto}.katex-display.fleqn>.katex{text-align:left}.cnblogs-markdown .hljs,.cnblogs-post-body .hljs{display:block;overflow-x:auto;padding:.5em;background:#fff;color:#000}.hljs-comment,.hljs-quote,.hljs-variable{color:#008000}.hljs-keyword,.hljs-selector-tag,.hljs-built_in,.hljs-name,.hljs-tag{color:#00f}.hljs-string,.hljs-title,.hljs-section,.hljs-attribute,.hljs-literal,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-addition{color:#a31515}.hljs-deletion,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-meta{color:#2b91af}.hljs-doctag{color:#808080}.hljs-attr{color:#f00}.hljs-symbol,.hljs-bullet,.hljs-link{color:#00b0e8}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}.cnblogs-markdown code,.cnblogs-post-body code{font-family:"Courier New",sans-serif !important;font-size:12px !important;line-height:20px;background-color:#f5f5f5 !important;border:1px solid #ccc !important;padding:0 5px !important;border-radius:3px !important;line-height:1.8;margin:1px 5px;vertical-align:middle;display:inline-block}.cnblogs-markdown pre code,.cnblogs-post-body pre code{display:block;margin:auto;vertical-align:auto;height:auto;line-height:1.5;padding:5px !important}.cnblogs-markdown .hljs,.cnblogs-post-body .hljs{font-family:"Courier New",sans-serif!important;font-size:12px !important;line-height:1.5!important;padding:5px !important}.cnblogs-markdown pre{margin-top:10px;margin-bottom:10px}.dropdown-menu a{color:#08c;text-decoration:none}.typeahead{z-index:1051;margin-top:2px}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;padding:0;float:left;margin:2px 0 0;list-style:none;background-color:#fff;text-shadow:none}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;outline:0;background-color:#4078c0;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu>li>a{display:block;padding:3px 10px;clear:both;font-weight:normal;line-height:20px;color:#333;white-space:nowrap}.mention_name{font-size:12px}.mention_username{font-size:12px;color:#999}.mention_image{float:left;margin-right:5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;width:20px;height:20px}.active .mention_username{color:#fff}.dropdown-menu>.tips{color:#fff;text-decoration:none;outline:0;background-color:#4078c0;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0);font-size:12px;padding:3px 5px;clear:both;line-height:20px} +/*! + * ui-dialog.css + * Date: 2014-07-03 + * https://github.com/aui/artDialog + * (c) 2009-2014 TangBin, http://www.planeArt.cn + * + * This is licensed under the GNU LGPL, version 2.1 or later. + * For details, see: http://www.gnu.org/licenses/lgpl-2.1.html + */ +.ui-dialog{*zoom:1;_float:left;position:relative;background-color:#fff;border:1px solid #999;border-radius:6px;outline:0;background-clip:padding-box;font-family:Helvetica,arial,sans-serif;font-size:14px;line-height:1.428571429;color:#333;opacity:0;-webkit-transform:scale(0);transform:scale(0);-webkit-transition:-webkit-transform .15s ease-in-out,opacity .15s ease-in-out;transition:transform .15s ease-in-out,opacity .15s ease-in-out}.ui-popup-show .ui-dialog{opacity:1;-webkit-transform:scale(1);transform:scale(1)}.ui-popup-focus .ui-dialog{box-shadow:0 0 8px rgba(0,0,0,.1)}.ui-popup-modal .ui-dialog{box-shadow:0 0 8px rgba(0,0,0,.1),0 0 256px rgba(255,255,255,.3)}.ui-dialog-grid{width:auto;margin:0;border:0 none;border-collapse:collapse;border-spacing:0;background:transparent}.ui-dialog-header,.ui-dialog-body,.ui-dialog-footer{padding:0;border:0 none;text-align:left;background:transparent}.ui-dialog-header{white-space:nowrap;border-bottom:1px solid #e5e5e5}.ui-dialog-close{position:relative;_position:absolute;float:right;top:13px;right:13px;_height:26px;padding:0 4px;font-size:21px;font-weight:bold;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20);cursor:pointer;background:transparent;_background:#fff;border:0;-webkit-appearance:none}.ui-dialog-close:hover,.ui-dialog-close:focus{color:#000;text-decoration:none;cursor:pointer;outline:0;opacity:.5;filter:alpha(opacity=50)}.ui-dialog-title{margin:0;line-height:1.428571429;min-height:16.428571429px;padding:15px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:bold;cursor:default}.ui-dialog-body{padding:20px;text-align:center}.ui-dialog-content{display:inline-block;position:relative;vertical-align:middle;*zoom:1;*display:inline;text-align:left}.ui-dialog-footer{padding:0 20px 20px 20px}.ui-dialog-statusbar{float:left;margin-right:20px;padding:6px 0;line-height:1.428571429;font-size:14px;color:#888;white-space:nowrap}.ui-dialog-statusbar label:hover{color:#333}.ui-dialog-statusbar input,.ui-dialog-statusbar .label{vertical-align:middle}.ui-dialog-button{float:right;white-space:nowrap}.ui-dialog-footer button+button{margin-bottom:0;margin-left:5px}.ui-dialog-footer button{width:auto;overflow:visible;display:inline-block;padding:6px 12px;_margin-left:5px;margin-bottom:0;font-size:14px;font-weight:normal;line-height:1.428571429;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;background-image:none;border:1px solid transparent;border-radius:4px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.ui-dialog-footer button:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.ui-dialog-footer button:hover,.ui-dialog-footer button:focus{color:#333;text-decoration:none}.ui-dialog-footer button:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.ui-dialog-footer button[disabled]{pointer-events:none;cursor:not-allowed;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;box-shadow:none}.ui-dialog-footer button{color:#333;background-color:#fff;border-color:#ccc}.ui-dialog-footer button:hover,.ui-dialog-footer button:focus,.ui-dialog-footer button:active{color:#333;background-color:#ebebeb;border-color:#adadad}.ui-dialog-footer button:active{background-image:none}.ui-dialog-footer button[disabled],.ui-dialog-footer button[disabled]:hover,.ui-dialog-footer button[disabled]:focus,.ui-dialog-footer button[disabled]:active{background-color:#fff;border-color:#ccc}.ui-dialog-footer button.ui-dialog-autofocus{color:#fff;background-color:#428bca;border-color:#357ebd}.ui-dialog-footer button.ui-dialog-autofocus:hover,.ui-dialog-footer button.ui-dialog-autofocus:focus,.ui-dialog-footer button.ui-dialog-autofocus:active{color:#fff;background-color:#3276b1;border-color:#285e8e}.ui-dialog-footer button.ui-dialog-autofocus:active{background-image:none}.ui-popup-top-left .ui-dialog,.ui-popup-top .ui-dialog,.ui-popup-top-right .ui-dialog{top:-8px}.ui-popup-bottom-left .ui-dialog,.ui-popup-bottom .ui-dialog,.ui-popup-bottom-right .ui-dialog{top:8px}.ui-popup-left-top .ui-dialog,.ui-popup-left .ui-dialog,.ui-popup-left-bottom .ui-dialog{left:-8px}.ui-popup-right-top .ui-dialog,.ui-popup-right .ui-dialog,.ui-popup-right-bottom .ui-dialog{left:8px}.ui-dialog-arrow-a,.ui-dialog-arrow-b{position:absolute;display:none;width:0;height:0;overflow:hidden;_color:#ff3fff;_filter:chroma(color=#ff3fff);border:8px dashed transparent}.ui-popup-follow .ui-dialog-arrow-a,.ui-popup-follow .ui-dialog-arrow-b{display:block}.ui-popup-top-left .ui-dialog-arrow-a,.ui-popup-top .ui-dialog-arrow-a,.ui-popup-top-right .ui-dialog-arrow-a{bottom:-16px;border-top:8px solid #7c7c7c}.ui-popup-top-left .ui-dialog-arrow-b,.ui-popup-top .ui-dialog-arrow-b,.ui-popup-top-right .ui-dialog-arrow-b{bottom:-15px;border-top:8px solid #fff}.ui-popup-top-left .ui-dialog-arrow-a,.ui-popup-top-left .ui-dialog-arrow-b{left:15px}.ui-popup-top .ui-dialog-arrow-a,.ui-popup-top .ui-dialog-arrow-b{left:50%;margin-left:-8px}.ui-popup-top-right .ui-dialog-arrow-a,.ui-popup-top-right .ui-dialog-arrow-b{right:15px}.ui-popup-bottom-left .ui-dialog-arrow-a,.ui-popup-bottom .ui-dialog-arrow-a,.ui-popup-bottom-right .ui-dialog-arrow-a{top:-16px;border-bottom:8px solid #7c7c7c}.ui-popup-bottom-left .ui-dialog-arrow-b,.ui-popup-bottom .ui-dialog-arrow-b,.ui-popup-bottom-right .ui-dialog-arrow-b{top:-15px;border-bottom:8px solid #fff}.ui-popup-bottom-left .ui-dialog-arrow-a,.ui-popup-bottom-left .ui-dialog-arrow-b{left:15px}.ui-popup-bottom .ui-dialog-arrow-a,.ui-popup-bottom .ui-dialog-arrow-b{margin-left:-8px;left:50%}.ui-popup-bottom-right .ui-dialog-arrow-a,.ui-popup-bottom-right .ui-dialog-arrow-b{right:15px}.ui-popup-left-top .ui-dialog-arrow-a,.ui-popup-left .ui-dialog-arrow-a,.ui-popup-left-bottom .ui-dialog-arrow-a{right:-16px;border-left:8px solid #7c7c7c}.ui-popup-left-top .ui-dialog-arrow-b,.ui-popup-left .ui-dialog-arrow-b,.ui-popup-left-bottom .ui-dialog-arrow-b{right:-15px;border-left:8px solid #fff}.ui-popup-left-top .ui-dialog-arrow-a,.ui-popup-left-top .ui-dialog-arrow-b{top:15px}.ui-popup-left .ui-dialog-arrow-a,.ui-popup-left .ui-dialog-arrow-b{margin-top:-8px;top:50%}.ui-popup-left-bottom .ui-dialog-arrow-a,.ui-popup-left-bottom .ui-dialog-arrow-b{bottom:15px}.ui-popup-right-top .ui-dialog-arrow-a,.ui-popup-right .ui-dialog-arrow-a,.ui-popup-right-bottom .ui-dialog-arrow-a{left:-16px;border-right:8px solid #7c7c7c}.ui-popup-right-top .ui-dialog-arrow-b,.ui-popup-right .ui-dialog-arrow-b,.ui-popup-right-bottom .ui-dialog-arrow-b{left:-15px;border-right:8px solid #fff}.ui-popup-right-top .ui-dialog-arrow-a,.ui-popup-right-top .ui-dialog-arrow-b{top:15px}.ui-popup-right .ui-dialog-arrow-a,.ui-popup-right .ui-dialog-arrow-b{margin-top:-8px;top:50%}.ui-popup-right-bottom .ui-dialog-arrow-a,.ui-popup-right-bottom .ui-dialog-arrow-b{bottom:15px}@-webkit-keyframes ui-dialog-loading{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes ui-dialog-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.ui-dialog-loading{vertical-align:middle;position:relative;display:block;*zoom:1;*display:inline;overflow:hidden;width:32px;height:32px;top:50%;margin:-16px auto 0 auto;font-size:0;text-indent:-999em;color:#666}.ui-dialog-loading{width:100%\9;text-indent:0\9;line-height:32px\9;text-align:center\9;font-size:12px\9}.ui-dialog-loading::after{position:absolute;content:'';width:3px;height:3px;margin:14.5px 0 0 14.5px;border-radius:100%;box-shadow:0 -10px 0 1px #ccc,10px 0 #ccc,0 10px #ccc,-10px 0 #ccc,-7px -7px 0 .5px #ccc,7px -7px 0 1.5px #ccc,7px 7px #ccc,-7px 7px #ccc;-webkit-transform:rotate(360deg);-webkit-animation:ui-dialog-loading 1.5s infinite linear;transform:rotate(360deg);animation:ui-dialog-loading 1.5s infinite linear;display:none\9} \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/blog-common.min.js.\344\270\213\350\275\275" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/blog-common.min.js.\344\270\213\350\275\275" new file mode 100644 index 0000000000000000000000000000000000000000..eac2a3d418bbe288254c94ebc7351b9df005e0d0 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/blog-common.min.js.\344\270\213\350\275\275" @@ -0,0 +1 @@ +function login(n){var t=location.href;return n&&t.indexOf("#"+n)<0&&(t+="#"+n),location.href=accountBaseAddress+"/signin?returnUrl="+encodeURIComponent(t),!1}function logout(){return confirm("确认退出吗?")&&$.ajax({type:"POST",url:"https://account.cnblogs.com/signout",xhrFields:{withCredentials:!0},complete:function(n){n.status==200&&location.reload(!0)}}),!1}function register(){return location.href=accountBaseAddress+"/signup?returnUrl="+encodeURIComponent(location.href),!1}function deliverAdT2(){$.getJSON("https://a1.cnblogs.com/group/T2",function(n){n&&$("#ad_t2").html(n.T2)})}function deliverAdC1(){canShowAdsense()?googletag.cmd.push(function(){googletag.display("div-gpt-ad-1546353474406-0")}):$.getJSON("https://a1.cnblogs.com/group/C1",function(n){if(n){var t=n.C1;t.indexOf("gitee.com")>0&&(t=t.replace("ga('send', 'event', 'Link', 'click', 'C1');","ga('send', 'event', 'Link', 'click', 'C1-default-gitee');"));$("#cnblogs_c1").html(t)}})}function deliverAdC2(){canShowAdsense()?screen.width<500?deliverC2Mobile():googletag.cmd.push(function(){googletag.display("div-gpt-ad-1539008685004-0")}):$("#cnblogs_c2").hide()}function deliverC2Mobile(){$("#cnblogs_c2").html(' ",rE:!0,sL:["actionscript","javascript","handlebars","xml"]}},{cN:"meta",v:[{b:/<\?xml/,e:/\?>/,r:10},{b:/<\?\w+/,e:/\?>/}]},{cN:"tag",b:"",c:[{cN:"name",b:/[^\/><\s]+/,r:0},t]}]}});hljs.registerLanguage("markdown",function(e){return{aliases:["md","mkdown","mkd"],c:[{cN:"section",v:[{b:"^#{1,6}",e:"$"},{b:"^.+?\\n[=-]{2,}$"}]},{b:"<",e:">",sL:"xml",r:0},{cN:"bullet",b:"^([*+-]|(\\d+\\.))\\s+"},{cN:"strong",b:"[*_]{2}.+?[*_]{2}"},{cN:"emphasis",v:[{b:"\\*.+?\\*"},{b:"_.+?_",r:0}]},{cN:"quote",b:"^>\\s+",e:"$"},{cN:"code",v:[{b:"^```w*s*$",e:"^```s*$"},{b:"`.+?`"},{b:"^( {4}| )",e:"$",r:0}]},{b:"^[-\\*]{3,}",e:"$"},{b:"\\[.+?\\][\\(\\[].*?[\\)\\]]",rB:!0,c:[{cN:"string",b:"\\[",e:"\\]",eB:!0,rE:!0,r:0},{cN:"link",b:"\\]\\(",e:"\\)",eB:!0,eE:!0},{cN:"symbol",b:"\\]\\[",e:"\\]",eB:!0,eE:!0}],r:10},{b:/^\[[^\n]+\]:/,rB:!0,c:[{cN:"symbol",b:/\[/,e:/\]/,eB:!0,eE:!0},{cN:"link",b:/:\s*/,e:/$/,eB:!0}]}]}});hljs.registerLanguage("javascript",function(e){var r="[A-Za-z$_][0-9A-Za-z$_]*",t={keyword:"in of if for while finally var new function do return void else break catch instanceof with throw case default try this switch continue typeof delete let yield const export super debugger as async await static import from as",literal:"true false null undefined NaN Infinity",built_in:"eval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError Number Math Date String RegExp Array Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray ArrayBuffer DataView JSON Intl arguments require module console window document Symbol Set Map WeakSet WeakMap Proxy Reflect Promise"},a={cN:"number",v:[{b:"\\b(0[bB][01]+)"},{b:"\\b(0[oO][0-7]+)"},{b:e.CNR}],r:0},n={cN:"subst",b:"\\$\\{",e:"\\}",k:t,c:[]},c={cN:"string",b:"`",e:"`",c:[e.BE,n]};n.c=[e.ASM,e.QSM,c,a,e.RM];var s=n.c.concat([e.CBCM,e.CLCM]);return{aliases:["js","jsx"],k:t,c:[{cN:"meta",r:10,b:/^\s*['"]use (strict|asm)['"]/},{cN:"meta",b:/^#!/,e:/$/},e.ASM,e.QSM,c,e.CLCM,e.CBCM,a,{b:/[{,]\s*/,r:0,c:[{b:r+"\\s*:",rB:!0,r:0,c:[{cN:"attr",b:r,r:0}]}]},{b:"("+e.RSR+"|\\b(case|return|throw)\\b)\\s*",k:"return throw case",c:[e.CLCM,e.CBCM,e.RM,{cN:"function",b:"(\\(.*?\\)|"+r+")\\s*=>",rB:!0,e:"\\s*=>",c:[{cN:"params",v:[{b:r},{b:/\(\s*\)/},{b:/\(/,e:/\)/,eB:!0,eE:!0,k:t,c:s}]}]},{b://,sL:"xml",c:[{b:/<\w+\s*\/>/,skip:!0},{b:/<\w+/,e:/(\/\w+|\w+\/)>/,skip:!0,c:[{b:/<\w+\s*\/>/,skip:!0},"self"]}]}],r:0},{cN:"function",bK:"function",e:/\{/,eE:!0,c:[e.inherit(e.TM,{b:r}),{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,c:s}],i:/\[|%/},{b:/\$[(.]/},e.METHOD_GUARD,{cN:"class",bK:"class",e:/[{;=]/,eE:!0,i:/[:"\[\]]/,c:[{bK:"extends"},e.UTM]},{bK:"constructor",e:/\{/,eE:!0}],i:/#(?!!)/}});hljs.registerLanguage("erlang-repl",function(e){return{k:{built_in:"spawn spawn_link self",keyword:"after and andalso|10 band begin bnot bor bsl bsr bxor case catch cond div end fun if let not of or orelse|10 query receive rem try when xor"},c:[{cN:"meta",b:"^[0-9]+> ",r:10},e.C("%","$"),{cN:"number",b:"\\b(\\d+#[a-fA-F0-9]+|\\d+(\\.\\d+)?([eE][-+]?\\d+)?)",r:0},e.ASM,e.QSM,{b:"\\?(::)?([A-Z]\\w*(::)?)+"},{b:"->"},{b:"ok"},{b:"!"},{b:"(\\b[a-z'][a-zA-Z0-9_']*:[a-z'][a-zA-Z0-9_']*)|(\\b[a-z'][a-zA-Z0-9_']*)",r:0},{b:"[A-Z][a-zA-Z0-9_']*",r:0}]}});hljs.registerLanguage("r",function(e){var r="([a-zA-Z]|\\.[a-zA-Z.])[a-zA-Z0-9._]*";return{c:[e.HCM,{b:r,l:r,k:{keyword:"function if in break next repeat else for return switch while try tryCatch stop warning require library attach detach source setMethod setGeneric setGroupGeneric setClass ...",literal:"NULL NA TRUE FALSE T F Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10"},r:0},{cN:"number",b:"0[xX][0-9a-fA-F]+[Li]?\\b",r:0},{cN:"number",b:"\\d+(?:[eE][+\\-]?\\d*)?L\\b",r:0},{cN:"number",b:"\\d+\\.(?!\\d)(?:i\\b)?",r:0},{cN:"number",b:"\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{cN:"number",b:"\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",r:0},{b:"`",e:"`",r:0},{cN:"string",c:[e.BE],v:[{b:'"',e:'"'},{b:"'",e:"'"}]}]}});hljs.registerLanguage("go",function(e){var t={keyword:"break default func interface select case map struct chan else goto package switch const fallthrough if range type continue for import return var go defer bool byte complex64 complex128 float32 float64 int8 int16 int32 int64 string uint8 uint16 uint32 uint64 int uint uintptr rune",literal:"true false iota nil",built_in:"append cap close complex copy imag len make new panic print println real recover delete"};return{aliases:["golang"],k:t,i:"]",e:"[;{}]"},{b:t,e:"{"}],rB:!0,rE:!0,i:"[<='$\"]",r:0,c:[e.CLCM,e.CBCM,o,b("keyword","all\\b"),b("variable","@{"+r+"}"),b("selector-tag",t+"%?",0),b("selector-id","#"+t),b("selector-class","\\."+t,0),b("selector-tag","&",0),{cN:"selector-attr",b:"\\[",e:"\\]"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"\\(",e:"\\)",c:i},{b:"!important"}]};return a.push(e.CLCM,e.CBCM,l,C,u,p),{cI:!0,i:"[=>'/<($\"]",c:a}});hljs.registerLanguage("cmake",function(e){return{aliases:["cmake.in"],cI:!0,k:{keyword:"add_custom_command add_custom_target add_definitions add_dependencies add_executable add_library add_subdirectory add_test aux_source_directory break build_command cmake_minimum_required cmake_policy configure_file create_test_sourcelist define_property else elseif enable_language enable_testing endforeach endfunction endif endmacro endwhile execute_process export find_file find_library find_package find_path find_program fltk_wrap_ui foreach function get_cmake_property get_directory_property get_filename_component get_property get_source_file_property get_target_property get_test_property if include include_directories include_external_msproject include_regular_expression install link_directories load_cache load_command macro mark_as_advanced message option output_required_files project qt_wrap_cpp qt_wrap_ui remove_definitions return separate_arguments set set_directory_properties set_property set_source_files_properties set_target_properties set_tests_properties site_name source_group string target_link_libraries try_compile try_run unset variable_watch while build_name exec_program export_library_dependencies install_files install_programs install_targets link_libraries make_directory remove subdir_depends subdirs use_mangled_mesa utility_source variable_requires write_file qt5_use_modules qt5_use_package qt5_wrap_cpp on off true false and or equal less greater strless strgreater strequal matches"},c:[{cN:"variable",b:"\\${",e:"}"},e.HCM,e.QSM,e.NM]}});hljs.registerLanguage("dos",function(e){var r=e.C(/^\s*@?rem\b/,/$/,{r:10}),t={cN:"symbol",b:"^\\s*[A-Za-z._?][A-Za-z0-9_$#@~.?]*(:|\\s+label)",r:0};return{aliases:["bat","cmd"],cI:!0,i:/\/\*/,k:{keyword:"if else goto for in do call exit not exist errorlevel defined equ neq lss leq gtr geq",built_in:"prn nul lpt3 lpt2 lpt1 con com4 com3 com2 com1 aux shift cd dir echo setlocal endlocal set pause copy append assoc at attrib break cacls cd chcp chdir chkdsk chkntfs cls cmd color comp compact convert date dir diskcomp diskcopy doskey erase fs find findstr format ftype graftabl help keyb label md mkdir mode more move path pause print popd pushd promt rd recover rem rename replace restore rmdir shiftsort start subst time title tree type ver verify vol ping net ipconfig taskkill xcopy ren del"},c:[{cN:"variable",b:/%%[^ ]|%[^ ]+?%|![^ ]+?!/},{cN:"function",b:t.b,e:"goto:eof",c:[e.inherit(e.TM,{b:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),r]},{cN:"number",b:"\\b\\d+",r:0},r]}});hljs.registerLanguage("haskell",function(e){var i={v:[e.C("--","$"),e.C("{-","-}",{c:["self"]})]},a={cN:"meta",b:"{-#",e:"#-}"},l={cN:"meta",b:"^#",e:"$"},c={cN:"type",b:"\\b[A-Z][\\w']*",r:0},n={b:"\\(",e:"\\)",i:'"',c:[a,l,{cN:"type",b:"\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?"},e.inherit(e.TM,{b:"[_a-z][\\w']*"}),i]},s={b:"{",e:"}",c:n.c};return{aliases:["hs"],k:"let in if then else case of where do module import hiding qualified type data newtype deriving class instance as default infix infixl infixr foreign export ccall stdcall cplusplus jvm dotnet safe unsafe family forall mdo proc rec",c:[{bK:"module",e:"where",k:"module where",c:[n,i],i:"\\W\\.|;"},{b:"\\bimport\\b",e:"$",k:"import qualified as hiding",c:[n,i],i:"\\W\\.|;"},{cN:"class",b:"^(\\s*)?(class|instance)\\b",e:"where",k:"class family instance where",c:[c,n,i]},{cN:"class",b:"\\b(data|(new)?type)\\b",e:"$",k:"data family type newtype deriving",c:[a,c,n,s,i]},{bK:"default",e:"$",c:[c,n,i]},{bK:"infix infixl infixr",e:"$",c:[e.CNM,i]},{b:"\\bforeign\\b",e:"$",k:"foreign import export ccall stdcall cplusplus jvm dotnet safe unsafe",c:[c,e.QSM,i]},{cN:"meta",b:"#!\\/usr\\/bin\\/env runhaskell",e:"$"},a,l,e.QSM,e.CNM,c,e.inherit(e.TM,{b:"^[_a-z][\\w']*"}),i,{b:"->|<-"}]}});hljs.registerLanguage("diff",function(e){return{aliases:["patch"],c:[{cN:"meta",r:10,v:[{b:/^@@ +\-\d+,\d+ +\+\d+,\d+ +@@$/},{b:/^\*\*\* +\d+,\d+ +\*\*\*\*$/},{b:/^\-\-\- +\d+,\d+ +\-\-\-\-$/}]},{cN:"comment",v:[{b:/Index: /,e:/$/},{b:/={3,}/,e:/$/},{b:/^\-{3}/,e:/$/},{b:/^\*{3} /,e:/$/},{b:/^\+{3}/,e:/$/},{b:/\*{5}/,e:/\*{5}$/}]},{cN:"addition",b:"^\\+",e:"$"},{cN:"deletion",b:"^\\-",e:"$"},{cN:"addition",b:"^\\!",e:"$"}]}});hljs.registerLanguage("nginx",function(e){var r={cN:"variable",v:[{b:/\$\d+/},{b:/\$\{/,e:/}/},{b:"[\\$\\@]"+e.UIR}]},b={eW:!0,l:"[a-z/_]+",k:{literal:"on off yes no true false none blocked debug info notice warn error crit select break last permanent redirect kqueue rtsig epoll poll /dev/poll"},r:0,i:"=>",c:[e.HCM,{cN:"string",c:[e.BE,r],v:[{b:/"/,e:/"/},{b:/'/,e:/'/}]},{b:"([a-z]+):/",e:"\\s",eW:!0,eE:!0,c:[r]},{cN:"regexp",c:[e.BE,r],v:[{b:"\\s\\^",e:"\\s|{|;",rE:!0},{b:"~\\*?\\s+",e:"\\s|{|;",rE:!0},{b:"\\*(\\.[a-z\\-]+)+"},{b:"([a-z\\-]+\\.)+\\*"}]},{cN:"number",b:"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}(:\\d{1,5})?\\b"},{cN:"number",b:"\\b\\d+[kKmMgGdshdwy]*\\b",r:0},r]};return{aliases:["nginxconf"],c:[e.HCM,{b:e.UIR+"\\s+{",rB:!0,e:"{",c:[{cN:"section",b:e.UIR}],r:0},{b:e.UIR+"\\s",e:";|{",rB:!0,c:[{cN:"attribute",b:e.UIR,starts:b}],r:0}],i:"[^\\s\\}]"}});hljs.registerLanguage("groovy",function(e){return{k:{literal:"true false null",keyword:"byte short char int long boolean float double void def as in assert trait super this abstract static volatile transient public private protected synchronized final class interface enum if else for while switch case break default continue throw throws try catch finally implements extends new import package return instanceof"},c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,{cN:"string",b:'"""',e:'"""'},{cN:"string",b:"'''",e:"'''"},{cN:"string",b:"\\$/",e:"/\\$",r:10},e.ASM,{cN:"regexp",b:/~?\/[^\/\n]+\//,c:[e.BE]},e.QSM,{cN:"meta",b:"^#!/usr/bin/env",e:"$",i:"\n"},e.BNM,{cN:"class",bK:"class interface trait enum",e:"{",i:":",c:[{bK:"extends implements"},e.UTM]},e.CNM,{cN:"meta",b:"@[A-Za-z]+"},{cN:"string",b:/[^\?]{0}[A-Za-z0-9_$]+ *:/},{b:/\?/,e:/\:/},{cN:"symbol",b:"^\\s*[A-Za-z0-9_$]+:",r:0}],i:/#|<\//}});hljs.registerLanguage("verilog",function(e){var n={keyword:"accept_on alias always always_comb always_ff always_latch and assert assign assume automatic before begin bind bins binsof bit break buf|0 bufif0 bufif1 byte case casex casez cell chandle checker class clocking cmos config const constraint context continue cover covergroup coverpoint cross deassign default defparam design disable dist do edge else end endcase endchecker endclass endclocking endconfig endfunction endgenerate endgroup endinterface endmodule endpackage endprimitive endprogram endproperty endspecify endsequence endtable endtask enum event eventually expect export extends extern final first_match for force foreach forever fork forkjoin function generate|5 genvar global highz0 highz1 if iff ifnone ignore_bins illegal_bins implements implies import incdir include initial inout input inside instance int integer interconnect interface intersect join join_any join_none large let liblist library local localparam logic longint macromodule matches medium modport module nand negedge nettype new nexttime nmos nor noshowcancelled not notif0 notif1 or output package packed parameter pmos posedge primitive priority program property protected pull0 pull1 pulldown pullup pulsestyle_ondetect pulsestyle_onevent pure rand randc randcase randsequence rcmos real realtime ref reg reject_on release repeat restrict return rnmos rpmos rtran rtranif0 rtranif1 s_always s_eventually s_nexttime s_until s_until_with scalared sequence shortint shortreal showcancelled signed small soft solve specify specparam static string strong strong0 strong1 struct super supply0 supply1 sync_accept_on sync_reject_on table tagged task this throughout time timeprecision timeunit tran tranif0 tranif1 tri tri0 tri1 triand trior trireg type typedef union unique unique0 unsigned until until_with untyped use uwire var vectored virtual void wait wait_order wand weak weak0 weak1 while wildcard wire with within wor xnor xor",literal:"null",built_in:"$finish $stop $exit $fatal $error $warning $info $realtime $time $printtimescale $bitstoreal $bitstoshortreal $itor $signed $cast $bits $stime $timeformat $realtobits $shortrealtobits $rtoi $unsigned $asserton $assertkill $assertpasson $assertfailon $assertnonvacuouson $assertoff $assertcontrol $assertpassoff $assertfailoff $assertvacuousoff $isunbounded $sampled $fell $changed $past_gclk $fell_gclk $changed_gclk $rising_gclk $steady_gclk $coverage_control $coverage_get $coverage_save $set_coverage_db_name $rose $stable $past $rose_gclk $stable_gclk $future_gclk $falling_gclk $changing_gclk $display $coverage_get_max $coverage_merge $get_coverage $load_coverage_db $typename $unpacked_dimensions $left $low $increment $clog2 $ln $log10 $exp $sqrt $pow $floor $ceil $sin $cos $tan $countbits $onehot $isunknown $fatal $warning $dimensions $right $high $size $asin $acos $atan $atan2 $hypot $sinh $cosh $tanh $asinh $acosh $atanh $countones $onehot0 $error $info $random $dist_chi_square $dist_erlang $dist_exponential $dist_normal $dist_poisson $dist_t $dist_uniform $q_initialize $q_remove $q_exam $async$and$array $async$nand$array $async$or$array $async$nor$array $sync$and$array $sync$nand$array $sync$or$array $sync$nor$array $q_add $q_full $psprintf $async$and$plane $async$nand$plane $async$or$plane $async$nor$plane $sync$and$plane $sync$nand$plane $sync$or$plane $sync$nor$plane $system $display $displayb $displayh $displayo $strobe $strobeb $strobeh $strobeo $write $readmemb $readmemh $writememh $value$plusargs $dumpvars $dumpon $dumplimit $dumpports $dumpportson $dumpportslimit $writeb $writeh $writeo $monitor $monitorb $monitorh $monitoro $writememb $dumpfile $dumpoff $dumpall $dumpflush $dumpportsoff $dumpportsall $dumpportsflush $fclose $fdisplay $fdisplayb $fdisplayh $fdisplayo $fstrobe $fstrobeb $fstrobeh $fstrobeo $swrite $swriteb $swriteh $swriteo $fscanf $fread $fseek $fflush $feof $fopen $fwrite $fwriteb $fwriteh $fwriteo $fmonitor $fmonitorb $fmonitorh $fmonitoro $sformat $sformatf $fgetc $ungetc $fgets $sscanf $rewind $ftell $ferror"};return{aliases:["v","sv","svh"],cI:!1,k:n,l:/[\w\$]+/,c:[e.CBCM,e.CLCM,e.QSM,{cN:"number",c:[e.BE],v:[{b:"\\b((\\d+'(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)"},{b:"\\B(('(b|h|o|d|B|H|O|D))[0-9xzXZa-fA-F_]+)"},{b:"\\b([0-9_])+",r:0}]},{cN:"variable",v:[{b:"#\\((?!parameter).+\\)"},{b:"\\.\\w+",r:0}]},{cN:"meta",b:"`",e:"$",k:{"meta-keyword":"define __FILE__ __LINE__ begin_keywords celldefine default_nettype define else elsif end_keywords endcelldefine endif ifdef ifndef include line nounconnected_drive pragma resetall timescale unconnected_drive undef undefineall"},r:0}]}});hljs.registerLanguage("bash",function(e){var t={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},s={cN:"string",b:/"/,e:/"/,c:[e.BE,t,{cN:"variable",b:/\$\(/,e:/\)/,c:[e.BE]}]},a={cN:"string",b:/'/,e:/'/};return{aliases:["sh","zsh"],l:/\b-?[a-z\._]+\b/,k:{keyword:"if then else elif fi for while in do done case esac function",literal:"true false",built_in:"break cd continue eval exec exit export getopts hash pwd readonly return shift test times trap umask unset alias bind builtin caller command declare echo enable help let local logout mapfile printf read readarray source type typeset ulimit unalias set shopt autoload bg bindkey bye cap chdir clone comparguments compcall compctl compdescribe compfiles compgroups compquote comptags comptry compvalues dirs disable disown echotc echoti emulate fc fg float functions getcap getln history integer jobs kill limit log noglob popd print pushd pushln rehash sched setcap setopt stat suspend ttyctl unfunction unhash unlimit unsetopt vared wait whence where which zcompile zformat zftp zle zmodload zparseopts zprof zpty zregexparse zsocket zstyle ztcp",_:"-ne -eq -lt -gt -f -d -e -s -l -a"},c:[{cN:"meta",b:/^#![^\n]+sh\s*$/,r:10},{cN:"function",b:/\w[\w\d_]*\s*\(\s*\)\s*\{/,rB:!0,c:[e.inherit(e.TM,{b:/\w[\w\d_]*/})],r:0},e.HCM,s,a,t]}});hljs.registerLanguage("java",function(e){var a="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",t=a+"(<"+a+"(\\s*,\\s*"+a+")*>)?",r="false synchronized int abstract float private char boolean static null if const for true while long strictfp finally protected import native final void enum else break transient catch instanceof byte super volatile case assert short package default double public try this switch continue throws protected public private module requires exports do",s="\\b(0[bB]([01]+[01_]+[01]+|[01]+)|0[xX]([a-fA-F0-9]+[a-fA-F0-9_]+[a-fA-F0-9]+|[a-fA-F0-9]+)|(([\\d]+[\\d_]+[\\d]+|[\\d]+)(\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))?|\\.([\\d]+[\\d_]+[\\d]+|[\\d]+))([eE][-+]?\\d+)?)[lLfF]?",c={cN:"number",b:s,r:0};return{aliases:["jsp"],k:r,i:/<\/|#/,c:[e.C("/\\*\\*","\\*/",{r:0,c:[{b:/\w+@/,r:0},{cN:"doctag",b:"@[A-Za-z]+"}]}),e.CLCM,e.CBCM,e.ASM,e.QSM,{cN:"class",bK:"class interface",e:/[{;=]/,eE:!0,k:"class interface",i:/[:"\[\]]/,c:[{bK:"extends implements"},e.UTM]},{bK:"new throw return else",r:0},{cN:"function",b:"("+t+"\\s+)+"+e.UIR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:r,c:[{b:e.UIR+"\\s*\\(",rB:!0,r:0,c:[e.UTM]},{cN:"params",b:/\(/,e:/\)/,k:r,r:0,c:[e.ASM,e.QSM,e.CNM,e.CBCM]},e.CLCM,e.CBCM]},c,{cN:"meta",b:"@[A-Za-z]+"}]}});hljs.registerLanguage("perl",function(e){var t="getpwent getservent quotemeta msgrcv scalar kill dbmclose undef lc ma syswrite tr send umask sysopen shmwrite vec qx utime local oct semctl localtime readpipe do return format read sprintf dbmopen pop getpgrp not getpwnam rewinddir qqfileno qw endprotoent wait sethostent bless s|0 opendir continue each sleep endgrent shutdown dump chomp connect getsockname die socketpair close flock exists index shmgetsub for endpwent redo lstat msgctl setpgrp abs exit select print ref gethostbyaddr unshift fcntl syscall goto getnetbyaddr join gmtime symlink semget splice x|0 getpeername recv log setsockopt cos last reverse gethostbyname getgrnam study formline endhostent times chop length gethostent getnetent pack getprotoent getservbyname rand mkdir pos chmod y|0 substr endnetent printf next open msgsnd readdir use unlink getsockopt getpriority rindex wantarray hex system getservbyport endservent int chr untie rmdir prototype tell listen fork shmread ucfirst setprotoent else sysseek link getgrgid shmctl waitpid unpack getnetbyname reset chdir grep split require caller lcfirst until warn while values shift telldir getpwuid my getprotobynumber delete and sort uc defined srand accept package seekdir getprotobyname semop our rename seek if q|0 chroot sysread setpwent no crypt getc chown sqrt write setnetent setpriority foreach tie sin msgget map stat getlogin unless elsif truncate exec keys glob tied closedirioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when",r={cN:"subst",b:"[$@]\\{",e:"\\}",k:t},s={b:"->{",e:"}"},n={v:[{b:/\$\d/},{b:/[\$%@](\^\w\b|#\w+(::\w+)*|{\w+}|\w+(::\w*)*)/},{b:/[\$%@][^\s\w{]/,r:0}]},i=[e.BE,r,n],o=[n,e.HCM,e.C("^\\=\\w","\\=cut",{eW:!0}),s,{cN:"string",c:i,v:[{b:"q[qwxr]?\\s*\\(",e:"\\)",r:5},{b:"q[qwxr]?\\s*\\[",e:"\\]",r:5},{b:"q[qwxr]?\\s*\\{",e:"\\}",r:5},{b:"q[qwxr]?\\s*\\|",e:"\\|",r:5},{b:"q[qwxr]?\\s*\\<",e:"\\>",r:5},{b:"qw\\s+q",e:"q",r:5},{b:"'",e:"'",c:[e.BE]},{b:'"',e:'"'},{b:"`",e:"`",c:[e.BE]},{b:"{\\w+}",c:[],r:0},{b:"-?\\w+\\s*\\=\\>",c:[],r:0}]},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\/\\/|"+e.RSR+"|\\b(split|return|print|reverse|grep)\\b)\\s*",k:"split return print reverse grep",r:0,c:[e.HCM,{cN:"regexp",b:"(s|tr|y)/(\\\\.|[^/])*/(\\\\.|[^/])*/[a-z]*",r:10},{cN:"regexp",b:"(m|qr)?/",e:"/[a-z]*",c:[e.BE],r:0}]},{cN:"function",bK:"sub",e:"(\\s*\\(.*?\\))?[;{]",eE:!0,r:5,c:[e.TM]},{b:"-\\w\\b",r:0},{b:"^__DATA__$",e:"^__END__$",sL:"mojolicious",c:[{b:"^@@.*",e:"$",cN:"comment"}]}];return r.c=o,s.c=o,{aliases:["pl","pm"],l:/[\w\.]+/,k:t,c:o}});hljs.registerLanguage("coffeescript",function(e){var c={keyword:"in if for while finally new do return else break catch instanceof throw try this switch continue typeof delete debugger super yield import export from as default await then unless until loop of by when and or is isnt not",literal:"true false null undefined yes no on off",built_in:"npm require console print module global window document"},n="[A-Za-z$_][0-9A-Za-z$_]*",r={cN:"subst",b:/#\{/,e:/}/,k:c},i=[e.BNM,e.inherit(e.CNM,{starts:{e:"(\\s*/)?",r:0}}),{cN:"string",v:[{b:/'''/,e:/'''/,c:[e.BE]},{b:/'/,e:/'/,c:[e.BE]},{b:/"""/,e:/"""/,c:[e.BE,r]},{b:/"/,e:/"/,c:[e.BE,r]}]},{cN:"regexp",v:[{b:"///",e:"///",c:[r,e.HCM]},{b:"//[gim]*",r:0},{b:/\/(?![ *])(\\\/|.)*?\/[gim]*(?=\W|$)/}]},{b:"@"+n},{sL:"javascript",eB:!0,eE:!0,v:[{b:"```",e:"```"},{b:"`",e:"`"}]}];r.c=i;var s=e.inherit(e.TM,{b:n}),t="(\\(.*\\))?\\s*\\B[-=]>",o={cN:"params",b:"\\([^\\(]",rB:!0,c:[{b:/\(/,e:/\)/,k:c,c:["self"].concat(i)}]};return{aliases:["coffee","cson","iced"],k:c,i:/\/\*/,c:i.concat([e.C("###","###"),e.HCM,{cN:"function",b:"^\\s*"+n+"\\s*=\\s*"+t,e:"[-=]>",rB:!0,c:[s,o]},{b:/[:\(,=]\s*/,r:0,c:[{cN:"function",b:t,e:"[-=]>",rB:!0,c:[o]}]},{cN:"class",bK:"class",e:"$",i:/[:="\[\]]/,c:[{bK:"extends",eW:!0,i:/[:="\[\]]/,c:[s]},s]},{b:n+":",e:":",rB:!0,rE:!0,r:0}])}});hljs.registerLanguage("erlang",function(e){var r="[a-z'][a-zA-Z0-9_']*",c="("+r+":"+r+"|"+r+")",b={keyword:"after and andalso|10 band begin bnot bor bsl bzr bxor case catch cond div end fun if let not of orelse|10 query receive rem try when xor",literal:"false true"},i=e.C("%","$"),n={cN:"number",b:"\\b(\\d+#[a-fA-F0-9]+|\\d+(\\.\\d+)?([eE][-+]?\\d+)?)",r:0},a={b:"fun\\s+"+r+"/\\d+"},d={b:c+"\\(",e:"\\)",rB:!0,r:0,c:[{b:c,r:0},{b:"\\(",e:"\\)",eW:!0,rE:!0,r:0}]},o={b:"{",e:"}",r:0},t={b:"\\b_([A-Z][A-Za-z0-9_]*)?",r:0},f={b:"[A-Z][a-zA-Z0-9_]*",r:0},l={b:"#"+e.UIR,r:0,rB:!0,c:[{b:"#"+e.UIR,r:0},{b:"{",e:"}",r:0}]},s={bK:"fun receive if try case",e:"end",k:b};s.c=[i,a,e.inherit(e.ASM,{cN:""}),s,d,e.QSM,n,o,t,f,l];var u=[i,a,s,d,e.QSM,n,o,t,f,l];d.c[1].c=u,o.c=u,l.c[1].c=u;var h={cN:"params",b:"\\(",e:"\\)",c:u};return{aliases:["erl"],k:b,i:"(",rB:!0,i:"\\(|#|//|/\\*|\\\\|:|;",c:[h,e.inherit(e.TM,{b:r})],starts:{e:";|\\.",k:b,c:u}},i,{b:"^-",e:"\\.",r:0,eE:!0,rB:!0,l:"-"+e.IR,k:"-module -record -undef -export -ifdef -ifndef -author -copyright -doc -vsn -import -include -include_lib -compile -define -else -endif -file -behaviour -behavior -spec",c:[h]},n,e.QSM,l,t,f,o,{b:/\.$/}]}});hljs.registerLanguage("dockerfile",function(e){return{aliases:["docker"],cI:!0,k:"from maintainer expose env arg user onbuild stopsignal",c:[e.HCM,e.ASM,e.QSM,e.NM,{bK:"run cmd entrypoint volume add copy workdir label healthcheck shell",starts:{e:/[^\\]\n/,sL:"bash"}}],i:">|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},c={cN:"doctag",b:"@[A-Za-z]+"},a={b:"#<",e:">"},s=[e.C("#","$",{c:[c]}),e.C("^\\=begin","^\\=end",{c:[c],r:10}),e.C("^__END__","\\n$")],n={cN:"subst",b:"#\\{",e:"}",k:r},t={cN:"string",c:[e.BE,n],v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/`/,e:/`/},{b:"%[qQwWx]?\\(",e:"\\)"},{b:"%[qQwWx]?\\[",e:"\\]"},{b:"%[qQwWx]?{",e:"}"},{b:"%[qQwWx]?<",e:">"},{b:"%[qQwWx]?/",e:"/"},{b:"%[qQwWx]?%",e:"%"},{b:"%[qQwWx]?-",e:"-"},{b:"%[qQwWx]?\\|",e:"\\|"},{b:/\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/},{b:/<<(-?)\w+$/,e:/^\s*\w+$/}]},i={cN:"params",b:"\\(",e:"\\)",endsParent:!0,k:r},d=[t,a,{cN:"class",bK:"class module",e:"$|;",i:/=/,c:[e.inherit(e.TM,{b:"[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?"}),{b:"<\\s*",c:[{b:"("+e.IR+"::)?"+e.IR}]}].concat(s)},{cN:"function",bK:"def",e:"$|;",c:[e.inherit(e.TM,{b:b}),i].concat(s)},{b:e.IR+"::"},{cN:"symbol",b:e.UIR+"(\\!|\\?)?:",r:0},{cN:"symbol",b:":(?!\\s)",c:[t,{b:b}],r:0},{cN:"number",b:"(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b",r:0},{b:"(\\$\\W)|((\\$|\\@\\@?)(\\w+))"},{cN:"params",b:/\|/,e:/\|/,k:r},{b:"("+e.RSR+"|unless)\\s*",k:"unless",c:[a,{cN:"regexp",c:[e.BE,n],i:/\n/,v:[{b:"/",e:"/[a-z]*"},{b:"%r{",e:"}[a-z]*"},{b:"%r\\(",e:"\\)[a-z]*"},{b:"%r!",e:"![a-z]*"},{b:"%r\\[",e:"\\][a-z]*"}]}].concat(s),r:0}].concat(s);n.c=d,i.c=d;var l="[>?]>",o="[\\w#]+\\(\\w+\\):\\d+:\\d+>",u="(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>",w=[{b:/^\s*=>/,starts:{e:"$",c:d}},{cN:"meta",b:"^("+l+"|"+o+"|"+u+")",starts:{e:"$",c:d}}];return{aliases:["rb","gemspec","podspec","thor","irb"],k:r,i:/\/\*/,c:s.concat(w).concat(d)}});hljs.registerLanguage("css",function(e){var c="[a-zA-Z-][a-zA-Z0-9_-]*",t={b:/[A-Z\_\.\-]+\s*:/,rB:!0,e:";",eW:!0,c:[{cN:"attribute",b:/\S/,e:":",eE:!0,starts:{eW:!0,eE:!0,c:[{b:/[\w-]+\(/,rB:!0,c:[{cN:"built_in",b:/[\w-]+/},{b:/\(/,e:/\)/,c:[e.ASM,e.QSM]}]},e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"number",b:"#[0-9A-Fa-f]+"},{cN:"meta",b:"!important"}]}}]};return{cI:!0,i:/[=\/|'\$]/,c:[e.CBCM,{cN:"selector-id",b:/#[A-Za-z0-9_-]+/},{cN:"selector-class",b:/\.[A-Za-z0-9_-]+/},{cN:"selector-attr",b:/\[/,e:/\]/,i:"$"},{cN:"selector-pseudo",b:/:(:)?[a-zA-Z0-9\_\-\+\(\)"'.]+/},{b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{b:"@",e:"[{;]",i:/:/,c:[{cN:"keyword",b:/\w+/},{b:/\s/,eW:!0,eE:!0,r:0,c:[e.ASM,e.QSM,e.CSSNM]}]},{cN:"selector-tag",b:c,r:0},{b:"{",e:"}",i:/\S/,c:[e.CBCM,t]}]}});hljs.registerLanguage("cpp",function(t){var e={cN:"keyword",b:"\\b[a-z\\d_]*_t\\b"},r={cN:"string",v:[{b:'(u8?|U)?L?"',e:'"',i:"\\n",c:[t.BE]},{b:'(u8?|U)?R"',e:'"',c:[t.BE]},{b:"'\\\\?.",e:"'",i:"."}]},s={cN:"number",v:[{b:"\\b(0b[01']+)"},{b:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{b:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],r:0},i={cN:"meta",b:/#\s*[a-z]+\b/,e:/$/,k:{"meta-keyword":"if else elif endif define undef warning error line pragma ifdef ifndef include"},c:[{b:/\\\n/,r:0},t.inherit(r,{cN:"meta-string"}),{cN:"meta-string",b:/<[^\n>]*>/,e:/$/,i:"\\n"},t.CLCM,t.CBCM]},a=t.IR+"\\s*\\(",c={keyword:"int float while private char catch import module export virtual operator sizeof dynamic_cast|10 typedef const_cast|10 const for static_cast|10 union namespace unsigned long volatile static protected bool template mutable if public friend do goto auto void enum else break extern using asm case typeid short reinterpret_cast|10 default double register explicit signed typename try this switch continue inline delete alignof constexpr decltype noexcept static_assert thread_local restrict _Bool complex _Complex _Imaginary atomic_bool atomic_char atomic_schar atomic_uchar atomic_short atomic_ushort atomic_int atomic_uint atomic_long atomic_ulong atomic_llong atomic_ullong new throw return and or not",built_in:"std string cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap array shared_ptr abort abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr",literal:"true false nullptr NULL"},n=[e,t.CLCM,t.CBCM,s,r];return{aliases:["c","cc","h","c++","h++","hpp"],k:c,i:"",k:c,c:["self",e]},{b:t.IR+"::",k:c},{v:[{b:/=/,e:/;/},{b:/\(/,e:/\)/},{bK:"new throw return else",e:/;/}],k:c,c:n.concat([{b:/\(/,e:/\)/,k:c,c:n.concat(["self"]),r:0}]),r:0},{cN:"function",b:"("+t.IR+"[\\*&\\s]+)+"+a,rB:!0,e:/[{;=]/,eE:!0,k:c,i:/[^\w\s\*&]/,c:[{b:a,rB:!0,c:[t.TM],r:0},{cN:"params",b:/\(/,e:/\)/,k:c,r:0,c:[t.CLCM,t.CBCM,r,s,e]},t.CLCM,t.CBCM,i]},{cN:"class",bK:"class struct",e:/[{;:]/,c:[{b://,c:["self"]},t.TM]}]),exports:{preprocessor:i,strings:r,k:c}}});hljs.registerLanguage("basic",function(E){return{cI:!0,i:"^.",l:"[a-zA-Z][a-zA-Z0-9_$%!#]*",k:{keyword:"ABS ASC AND ATN AUTO|0 BEEP BLOAD|10 BSAVE|10 CALL CALLS CDBL CHAIN CHDIR CHR$|10 CINT CIRCLE CLEAR CLOSE CLS COLOR COM COMMON CONT COS CSNG CSRLIN CVD CVI CVS DATA DATE$ DEFDBL DEFINT DEFSNG DEFSTR DEF|0 SEG USR DELETE DIM DRAW EDIT END ENVIRON ENVIRON$ EOF EQV ERASE ERDEV ERDEV$ ERL ERR ERROR EXP FIELD FILES FIX FOR|0 FRE GET GOSUB|10 GOTO HEX$ IF|0 THEN ELSE|0 INKEY$ INP INPUT INPUT# INPUT$ INSTR IMP INT IOCTL IOCTL$ KEY ON OFF LIST KILL LEFT$ LEN LET LINE LLIST LOAD LOC LOCATE LOF LOG LPRINT USING LSET MERGE MID$ MKDIR MKD$ MKI$ MKS$ MOD NAME NEW NEXT NOISE NOT OCT$ ON OR PEN PLAY STRIG OPEN OPTION BASE OUT PAINT PALETTE PCOPY PEEK PMAP POINT POKE POS PRINT PRINT] PSET PRESET PUT RANDOMIZE READ REM RENUM RESET|0 RESTORE RESUME RETURN|0 RIGHT$ RMDIR RND RSET RUN SAVE SCREEN SGN SHELL SIN SOUND SPACE$ SPC SQR STEP STICK STOP STR$ STRING$ SWAP SYSTEM TAB TAN TIME$ TIMER TROFF TRON TO USR VAL VARPTR VARPTR$ VIEW WAIT WHILE WEND WIDTH WINDOW WRITE XOR"},c:[E.QSM,E.C("REM","$",{r:10}),E.C("'","$",{r:0}),{cN:"symbol",b:"^[0-9]+ ",r:10},{cN:"number",b:"\\b([0-9]+[0-9edED.]*[#!]?)",r:0},{cN:"number",b:"(&[hH][0-9a-fA-F]{1,4})"},{cN:"number",b:"(&[oO][0-7]{1,6})"}]}});hljs.registerLanguage("dart",function(e){var t={cN:"subst",b:"\\$\\{",e:"}",k:"true false null this is new super"},r={cN:"string",v:[{b:"r'''",e:"'''"},{b:'r"""',e:'"""'},{b:"r'",e:"'",i:"\\n"},{b:'r"',e:'"',i:"\\n"},{b:"'''",e:"'''",c:[e.BE,t]},{b:'"""',e:'"""',c:[e.BE,t]},{b:"'",e:"'",i:"\\n",c:[e.BE,t]},{b:'"',e:'"',i:"\\n",c:[e.BE,t]}]};t.c=[e.CNM,r];var n={keyword:"assert async await break case catch class const continue default do else enum extends false final finally for if in is new null rethrow return super switch sync this throw true try var void while with yield abstract as dynamic export external factory get implements import library operator part set static typedef",built_in:"print Comparable DateTime Duration Function Iterable Iterator List Map Match Null Object Pattern RegExp Set Stopwatch String StringBuffer StringSink Symbol Type Uri bool double int num document window querySelector querySelectorAll Element ElementList"};return{k:n,c:[r,e.C("/\\*\\*","\\*/",{sL:"markdown"}),e.C("///","$",{sL:"markdown"}),e.CLCM,e.CBCM,{cN:"class",bK:"class interface",e:"{",eE:!0,c:[{bK:"extends implements"},e.UTM]},e.CNM,{cN:"meta",b:"@[A-Za-z]+"},{b:"=>"}]}});hljs.registerLanguage("delphi",function(e){var r="exports register file shl array record property for mod while set ally label uses raise not stored class safecall var interface or private static exit index inherited to else stdcall override shr asm far resourcestring finalization packed virtual out and protected library do xorwrite goto near function end div overload object unit begin string on inline repeat until destructor write message program with read initialization except default nil if case cdecl in downto threadvar of try pascal const external constructor type public then implementation finally published procedure absolute reintroduce operator as is abstract alias assembler bitpacked break continue cppdecl cvar enumerator experimental platform deprecated unimplemented dynamic export far16 forward generic helper implements interrupt iochecks local name nodefault noreturn nostackframe oldfpccall otherwise saveregisters softfloat specialize strict unaligned varargs ",t=[e.CLCM,e.C(/\{/,/\}/,{r:0}),e.C(/\(\*/,/\*\)/,{r:10})],a={cN:"meta",v:[{b:/\{\$/,e:/\}/},{b:/\(\*\$/,e:/\*\)/}]},c={cN:"string",b:/'/,e:/'/,c:[{b:/''/}]},i={cN:"string",b:/(#\d+)+/},o={b:e.IR+"\\s*=\\s*class\\s*\\(",rB:!0,c:[e.TM]},n={cN:"function",bK:"function constructor destructor procedure",e:/[:;]/,k:"function constructor|10 destructor|10 procedure|10",c:[e.TM,{cN:"params",b:/\(/,e:/\)/,k:r,c:[c,i,a].concat(t)},a].concat(t)};return{aliases:["dpr","dfm","pas","pascal","freepascal","lazarus","lpr","lfm"],cI:!0,k:r,i:/"|\$[G-Zg-z]|\/\*|<\/|\|/,c:[c,i,e.NM,o,n,a].concat(t)}});hljs.registerLanguage("vbscript",function(e){return{aliases:["vbs"],cI:!0,k:{keyword:"call class const dim do loop erase execute executeglobal exit for each next function if then else on error option explicit new private property let get public randomize redim rem select case set stop sub while wend with end to elseif is or xor and not class_initialize class_terminate default preserve in me byval byref step resume goto",built_in:"lcase month vartype instrrev ubound setlocale getobject rgb getref string weekdayname rnd dateadd monthname now day minute isarray cbool round formatcurrency conversions csng timevalue second year space abs clng timeserial fixs len asc isempty maths dateserial atn timer isobject filter weekday datevalue ccur isdate instr datediff formatdatetime replace isnull right sgn array snumeric log cdbl hex chr lbound msgbox ucase getlocale cos cdate cbyte rtrim join hour oct typename trim strcomp int createobject loadpicture tan formatnumber mid scriptenginebuildversion scriptengine split scriptengineminorversion cint sin datepart ltrim sqr scriptenginemajorversion time derived eval date formatpercent exp inputbox left ascw chrw regexp server response request cstr err",literal:"true false null nothing empty"},i:"//",c:[e.inherit(e.QSM,{c:[{b:'""'}]}),e.C(/'/,/$/,{r:0}),e.CNM]}});hljs.registerLanguage("awk",function(e){var r={cN:"variable",v:[{b:/\$[\w\d#@][\w\d_]*/},{b:/\$\{(.*?)}/}]},b="BEGIN END if else while do for in break continue delete next nextfile function func exit|10",n={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,r:10},{b:/(u|b)?r?"""/,e:/"""/,r:10},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},e.ASM,e.QSM]};return{k:{keyword:b},c:[r,n,e.RM,e.HCM,e.NM]}});hljs.registerLanguage("smalltalk",function(e){var s="[a-z][a-zA-Z0-9_]*",a={cN:"string",b:"\\$.{1}"},r={cN:"symbol",b:"#"+e.UIR};return{aliases:["st"],k:"self super nil true false thisContext",c:[e.C('"','"'),e.ASM,{cN:"type",b:"\\b[A-Z][A-Za-z0-9_]*",r:0},{b:s+":",r:0},e.CNM,r,a,{b:"\\|[ ]*"+s+"([ ]+"+s+")*[ ]*\\|",rB:!0,e:/\|/,i:/\S/,c:[{b:"(\\|[ ]*)?"+s}]},{b:"\\#\\(",e:"\\)",c:[e.ASM,a,e.CNM,r]}]}});hljs.registerLanguage("shell",function(s){return{aliases:["console"],c:[{cN:"meta",b:"^\\s{0,3}[\\w\\d\\[\\]()@-]*[>%$#]",starts:{e:"$",sL:"bash"}}]}});hljs.registerLanguage("clojure",function(e){var t={"builtin-name":"def defonce cond apply if-not if-let if not not= = < > <= >= == + / * - rem quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? string? map? nil? contains? zero? instance? not-every? not-any? libspec? -> ->> .. . inc compare do dotimes mapcat take remove take-while drop letfn drop-last take-last drop-while while intern condp case reduced cycle split-at split-with repeat replicate iterate range merge zipmap declare line-seq sort comparator sort-by dorun doall nthnext nthrest partition eval doseq await await-for let agent atom send send-off release-pending-sends add-watch mapv filterv remove-watch agent-error restart-agent set-error-handler error-handler set-error-mode! error-mode shutdown-agents quote var fn loop recur throw try monitor-enter monitor-exit defmacro defn defn- macroexpand macroexpand-1 for dosync and or when when-not when-let comp juxt partial sequence memoize constantly complement identity assert peek pop doto proxy defstruct first rest cons defprotocol cast coll deftype defrecord last butlast sigs reify second ffirst fnext nfirst nnext defmulti defmethod meta with-meta ns in-ns create-ns import refer keys select-keys vals key val rseq name namespace promise into transient persistent! conj! assoc! dissoc! pop! disj! use class type num float double short byte boolean bigint biginteger bigdec print-method print-dup throw-if printf format load compile get-in update-in pr pr-on newline flush read slurp read-line subvec with-open memfn time re-find re-groups rand-int rand mod locking assert-valid-fdecl alias resolve ref deref refset swap! reset! set-validator! compare-and-set! alter-meta! reset-meta! commute get-validator alter ref-set ref-history-count ref-min-history ref-max-history ensure sync io! new next conj set! to-array future future-call into-array aset gen-class reduce map filter find empty hash-map hash-set sorted-map sorted-map-by sorted-set sorted-set-by vec vector seq flatten reverse assoc dissoc list disj get union difference intersection extend extend-type extend-protocol int nth delay count concat chunk chunk-buffer chunk-append chunk-first chunk-rest max min dec unchecked-inc-int unchecked-inc unchecked-dec-inc unchecked-dec unchecked-negate unchecked-add-int unchecked-add unchecked-subtract-int unchecked-subtract chunk-next chunk-cons chunked-seq? prn vary-meta lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize"},r="a-zA-Z_\\-!.?+*=<>&#'",n="["+r+"]["+r+"0-9/;:]*",a="[-+]?\\d+(\\.\\d+)?",o={b:n,r:0},s={cN:"number",b:a,r:0},c=e.inherit(e.QSM,{i:null}),i=e.C(";","$",{r:0}),d={cN:"literal",b:/\b(true|false|nil)\b/},l={b:"[\\[\\{]",e:"[\\]\\}]"},m={cN:"comment",b:"\\^"+n},p=e.C("\\^\\{","\\}"),u={cN:"symbol",b:"[:]{1,2}"+n},f={b:"\\(",e:"\\)"},h={eW:!0,r:0},y={k:t,l:n,cN:"name",b:n,starts:h},b=[f,c,m,p,i,u,l,s,d,o];return f.c=[e.C("comment",""),y,h],h.c=b,l.c=b,p.c=[l],{aliases:["clj"],i:/\S/,c:[f,c,m,p,i,u,l,s,d]}});hljs.registerLanguage("objectivec",function(e){var t={cN:"built_in",b:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},_={keyword:"int float while char export sizeof typedef const struct for union unsigned long volatile static bool mutable if do return goto void enum else break extern asm case short default double register explicit signed typename this switch continue wchar_t inline readonly assign readwrite self @synchronized id typeof nonatomic super unichar IBOutlet IBAction strong weak copy in out inout bycopy byref oneway __strong __weak __block __autoreleasing @private @protected @public @try @property @end @throw @catch @finally @autoreleasepool @synthesize @dynamic @selector @optional @required @encode @package @import @defs @compatibility_alias __bridge __bridge_transfer __bridge_retained __bridge_retain __covariant __contravariant __kindof _Nonnull _Nullable _Null_unspecified __FUNCTION__ __PRETTY_FUNCTION__ __attribute__ getter setter retain unsafe_unretained nonnull nullable null_unspecified null_resettable class instancetype NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN",literal:"false true FALSE TRUE nil YES NO NULL",built_in:"BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once"},i=/[a-zA-Z@][a-zA-Z0-9_]*/,n="@interface @class @protocol @implementation";return{aliases:["mm","objc","obj-c"],k:_,l:i,i:""}]}]},{cN:"class",b:"("+n.split(" ").join("|")+")\\b",e:"({|$)",eE:!0,k:n,l:i,c:[e.UTM]},{b:"\\."+e.UIR,r:0}]}});hljs.registerLanguage("ini",function(e){var b={cN:"string",c:[e.BE],v:[{b:"'''",e:"'''",r:10},{b:'"""',e:'"""',r:10},{b:'"',e:'"'},{b:"'",e:"'"}]};return{aliases:["toml"],cI:!0,i:/\S/,c:[e.C(";","$"),e.HCM,{cN:"section",b:/^\s*\[+/,e:/\]+/},{b:/^[a-z0-9\[\]_-]+\s*=\s*/,e:"$",rB:!0,c:[{cN:"attr",b:/[a-z0-9\[\]_-]+/},{b:/=/,eW:!0,r:0,c:[{cN:"literal",b:/\bon|off|true|false|yes|no\b/},{cN:"variable",v:[{b:/\$[\w\d"][\w\d_]*/},{b:/\$\{(.*?)}/}]},b,{cN:"number",b:/([\+\-]+)?[\d]+_[\d_]+/},e.NM]}]}]}});hljs.registerLanguage("makefile",function(e){var i={cN:"variable",v:[{b:"\\$\\("+e.UIR+"\\)",c:[e.BE]},{b:/\$[@%>>|\.\.\.) /},c={cN:"subst",b:/\{/,e:/\}/,k:r,i:/#/},a={cN:"string",c:[e.BE],v:[{b:/(u|b)?r?'''/,e:/'''/,c:[b],r:10},{b:/(u|b)?r?"""/,e:/"""/,c:[b],r:10},{b:/(fr|rf|f)'''/,e:/'''/,c:[b,c]},{b:/(fr|rf|f)"""/,e:/"""/,c:[b,c]},{b:/(u|r|ur)'/,e:/'/,r:10},{b:/(u|r|ur)"/,e:/"/,r:10},{b:/(b|br)'/,e:/'/},{b:/(b|br)"/,e:/"/},{b:/(fr|rf|f)'/,e:/'/,c:[c]},{b:/(fr|rf|f)"/,e:/"/,c:[c]},e.ASM,e.QSM]},s={cN:"number",r:0,v:[{b:e.BNR+"[lLjJ]?"},{b:"\\b(0o[0-7]+)[lLjJ]?"},{b:e.CNR+"[lLjJ]?"}]},i={cN:"params",b:/\(/,e:/\)/,c:["self",b,s,a]};return c.c=[a,s,b],{aliases:["py","gyp"],k:r,i:/(<\/|->|\?)|=>/,c:[b,s,a,e.HCM,{v:[{cN:"function",bK:"def"},{cN:"class",bK:"class"}],e:/:/,i:/[${=;\n,]/,c:[e.UTM,i,{b:/->/,eW:!0,k:"None"}]},{cN:"meta",b:/^[\t ]*@/,e:/$/},{b:/\b(print|exec)\(/}]}});hljs.registerLanguage("powershell",function(e){var t={b:"`[\\s\\S]",r:0},o={cN:"variable",v:[{b:/\$[\w\d][\w\d_:]*/}]},r={cN:"literal",b:/\$(null|true|false)\b/},n={cN:"string",v:[{b:/"/,e:/"/},{b:/@"/,e:/^"@/}],c:[t,o,{cN:"variable",b:/\$[A-z]/,e:/[^A-z]/}]},a={cN:"string",v:[{b:/'/,e:/'/},{b:/@'/,e:/^'@/}]},i={cN:"doctag",v:[{b:/\.(synopsis|description|example|inputs|outputs|notes|link|component|role|functionality)/},{b:/\.(parameter|forwardhelptargetname|forwardhelpcategory|remotehelprunspace|externalhelp)\s+\S+/}]},s=e.inherit(e.C(null,null),{v:[{b:/#/,e:/$/},{b:/<#/,e:/#>/}],c:[i]});return{aliases:["ps"],l:/-?[A-z\.\-]+/,cI:!0,k:{keyword:"if else foreach return function do while until elseif begin for trap data dynamicparam end break throw param continue finally in switch exit filter try process catch",built_in:"Add-Computer Add-Content Add-History Add-JobTrigger Add-Member Add-PSSnapin Add-Type Checkpoint-Computer Clear-Content Clear-EventLog Clear-History Clear-Host Clear-Item Clear-ItemProperty Clear-Variable Compare-Object Complete-Transaction Connect-PSSession Connect-WSMan Convert-Path ConvertFrom-Csv ConvertFrom-Json ConvertFrom-SecureString ConvertFrom-StringData ConvertTo-Csv ConvertTo-Html ConvertTo-Json ConvertTo-SecureString ConvertTo-Xml Copy-Item Copy-ItemProperty Debug-Process Disable-ComputerRestore Disable-JobTrigger Disable-PSBreakpoint Disable-PSRemoting Disable-PSSessionConfiguration Disable-WSManCredSSP Disconnect-PSSession Disconnect-WSMan Disable-ScheduledJob Enable-ComputerRestore Enable-JobTrigger Enable-PSBreakpoint Enable-PSRemoting Enable-PSSessionConfiguration Enable-ScheduledJob Enable-WSManCredSSP Enter-PSSession Exit-PSSession Export-Alias Export-Clixml Export-Console Export-Counter Export-Csv Export-FormatData Export-ModuleMember Export-PSSession ForEach-Object Format-Custom Format-List Format-Table Format-Wide Get-Acl Get-Alias Get-AuthenticodeSignature Get-ChildItem Get-Command Get-ComputerRestorePoint Get-Content Get-ControlPanelItem Get-Counter Get-Credential Get-Culture Get-Date Get-Event Get-EventLog Get-EventSubscriber Get-ExecutionPolicy Get-FormatData Get-Host Get-HotFix Get-Help Get-History Get-IseSnippet Get-Item Get-ItemProperty Get-Job Get-JobTrigger Get-Location Get-Member Get-Module Get-PfxCertificate Get-Process Get-PSBreakpoint Get-PSCallStack Get-PSDrive Get-PSProvider Get-PSSession Get-PSSessionConfiguration Get-PSSnapin Get-Random Get-ScheduledJob Get-ScheduledJobOption Get-Service Get-TraceSource Get-Transaction Get-TypeData Get-UICulture Get-Unique Get-Variable Get-Verb Get-WinEvent Get-WmiObject Get-WSManCredSSP Get-WSManInstance Group-Object Import-Alias Import-Clixml Import-Counter Import-Csv Import-IseSnippet Import-LocalizedData Import-PSSession Import-Module Invoke-AsWorkflow Invoke-Command Invoke-Expression Invoke-History Invoke-Item Invoke-RestMethod Invoke-WebRequest Invoke-WmiMethod Invoke-WSManAction Join-Path Limit-EventLog Measure-Command Measure-Object Move-Item Move-ItemProperty New-Alias New-Event New-EventLog New-IseSnippet New-Item New-ItemProperty New-JobTrigger New-Object New-Module New-ModuleManifest New-PSDrive New-PSSession New-PSSessionConfigurationFile New-PSSessionOption New-PSTransportOption New-PSWorkflowExecutionOption New-PSWorkflowSession New-ScheduledJobOption New-Service New-TimeSpan New-Variable New-WebServiceProxy New-WinEvent New-WSManInstance New-WSManSessionOption Out-Default Out-File Out-GridView Out-Host Out-Null Out-Printer Out-String Pop-Location Push-Location Read-Host Receive-Job Register-EngineEvent Register-ObjectEvent Register-PSSessionConfiguration Register-ScheduledJob Register-WmiEvent Remove-Computer Remove-Event Remove-EventLog Remove-Item Remove-ItemProperty Remove-Job Remove-JobTrigger Remove-Module Remove-PSBreakpoint Remove-PSDrive Remove-PSSession Remove-PSSnapin Remove-TypeData Remove-Variable Remove-WmiObject Remove-WSManInstance Rename-Computer Rename-Item Rename-ItemProperty Reset-ComputerMachinePassword Resolve-Path Restart-Computer Restart-Service Restore-Computer Resume-Job Resume-Service Save-Help Select-Object Select-String Select-Xml Send-MailMessage Set-Acl Set-Alias Set-AuthenticodeSignature Set-Content Set-Date Set-ExecutionPolicy Set-Item Set-ItemProperty Set-JobTrigger Set-Location Set-PSBreakpoint Set-PSDebug Set-PSSessionConfiguration Set-ScheduledJob Set-ScheduledJobOption Set-Service Set-StrictMode Set-TraceSource Set-Variable Set-WmiInstance Set-WSManInstance Set-WSManQuickConfig Show-Command Show-ControlPanelItem Show-EventLog Sort-Object Split-Path Start-Job Start-Process Start-Service Start-Sleep Start-Transaction Start-Transcript Stop-Computer Stop-Job Stop-Process Stop-Service Stop-Transcript Suspend-Job Suspend-Service Tee-Object Test-ComputerSecureChannel Test-Connection Test-ModuleManifest Test-Path Test-PSSessionConfigurationFile Trace-Command Unblock-File Undo-Transaction Unregister-Event Unregister-PSSessionConfiguration Unregister-ScheduledJob Update-FormatData Update-Help Update-List Update-TypeData Use-Transaction Wait-Event Wait-Job Wait-Process Where-Object Write-Debug Write-Error Write-EventLog Write-Host Write-Output Write-Progress Write-Verbose Write-Warning Add-MDTPersistentDrive Disable-MDTMonitorService Enable-MDTMonitorService Get-MDTDeploymentShareStatistics Get-MDTMonitorData Get-MDTOperatingSystemCatalog Get-MDTPersistentDrive Import-MDTApplication Import-MDTDriver Import-MDTOperatingSystem Import-MDTPackage Import-MDTTaskSequence New-MDTDatabase Remove-MDTMonitorData Remove-MDTPersistentDrive Restore-MDTPersistentDrive Set-MDTMonitorData Test-MDTDeploymentShare Test-MDTMonitorData Update-MDTDatabaseSchema Update-MDTDeploymentShare Update-MDTLinkedDS Update-MDTMedia Update-MDTMedia Add-VamtProductKey Export-VamtData Find-VamtManagedMachine Get-VamtConfirmationId Get-VamtProduct Get-VamtProductKey Import-VamtData Initialize-VamtData Install-VamtConfirmationId Install-VamtProductActivation Install-VamtProductKey Update-VamtProduct",nomarkup:"-ne -eq -lt -gt -ge -le -not -like -notlike -match -notmatch -contains -notcontains -in -notin -replace"},c:[t,e.NM,n,a,r,o,s]}});hljs.registerLanguage("json",function(e){var i={literal:"true false null"},n=[e.QSM,e.CNM],r={e:",",eW:!0,eE:!0,c:n,k:i},t={b:"{",e:"}",c:[{cN:"attr",b:/"/,e:/"/,c:[e.BE],i:"\\n"},e.inherit(r,{b:/:/})],i:"\\S"},c={b:"\\[",e:"\\]",c:[e.inherit(r)],i:"\\S"};return n.splice(n.length,0,t,c),{c:n,k:i,i:"\\S"}});hljs.registerLanguage("apache",function(e){var r={cN:"number",b:"[\\$%]\\d+"};return{aliases:["apacheconf"],cI:!0,c:[e.HCM,{cN:"section",b:""},{cN:"attribute",b:/\w+/,r:0,k:{nomarkup:"order deny allow setenv rewriterule rewriteengine rewritecond documentroot sethandler errordocument loadmodule options header listen serverroot servername"},starts:{e:/$/,r:0,k:{literal:"on off all"},c:[{cN:"meta",b:"\\s\\[",e:"\\]$"},{cN:"variable",b:"[\\$%]\\{",e:"\\}",c:["self",r]},r,e.QSM]}}],i:/\S/}});hljs.registerLanguage("django",function(e){var t={b:/\|[A-Za-z]+:?/,k:{name:"truncatewords removetags linebreaksbr yesno get_digit timesince random striptags filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort dictsortreversed default_if_none pluralize lower join center default truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize localtime utc timezone"},c:[e.QSM,e.ASM]};return{aliases:["jinja"],cI:!0,sL:"xml",c:[e.C(/\{%\s*comment\s*%}/,/\{%\s*endcomment\s*%}/),e.C(/\{#/,/#}/),{cN:"template-tag",b:/\{%/,e:/%}/,c:[{cN:"name",b:/\w+/,k:{name:"comment endcomment load templatetag ifchanged endifchanged if endif firstof for endfor ifnotequal endifnotequal widthratio extends include spaceless endspaceless regroup ifequal endifequal ssi now with cycle url filter endfilter debug block endblock else autoescape endautoescape csrf_token empty elif endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix plural get_current_language language get_available_languages get_current_language_bidi get_language_info get_language_info_list localize endlocalize localtime endlocaltime timezone endtimezone get_current_timezone verbatim"},starts:{eW:!0,k:"in by as",c:[t],r:0}}]},{cN:"template-variable",b:/\{\{/,e:/}}/,c:[t]}]}});hljs.registerLanguage("scala",function(e){var t={cN:"meta",b:"@[A-Za-z]+"},a={cN:"subst",v:[{b:"\\$[A-Za-z0-9_]+"},{b:"\\${",e:"}"}]},r={cN:"string",v:[{b:'"',e:'"',i:"\\n",c:[e.BE]},{b:'"""',e:'"""',r:10},{b:'[a-z]+"',e:'"',i:"\\n",c:[e.BE,a]},{cN:"string",b:'[a-z]+"""',e:'"""',c:[a],r:10}]},c={cN:"symbol",b:"'\\w[\\w\\d_]*(?!')"},i={cN:"type",b:"\\b[A-Z][A-Za-z0-9_]*",r:0},s={cN:"title",b:/[^0-9\n\t "'(),.`{}\[\]:;][^\n\t "'(),.`{}\[\]:;]+|[^0-9\n\t "'(),.`{}\[\]:;=]/,r:0},n={cN:"class",bK:"class object trait type",e:/[:={\[\n;]/,eE:!0,c:[{bK:"extends with",r:10},{b:/\[/,e:/\]/,eB:!0,eE:!0,r:0,c:[i]},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,r:0,c:[i]},s]},l={cN:"function",bK:"def",e:/[:={\[(\n;]/,eE:!0,c:[s]};return{k:{literal:"true false null",keyword:"type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit"},c:[e.CLCM,e.CBCM,r,c,i,l,n,e.CNM,t]}});hljs.registerLanguage("vbnet",function(e){return{aliases:["vb"],cI:!0,k:{keyword:"addhandler addressof alias and andalso aggregate ansi as assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into is isfalse isnot istrue join key let lib like loop me mid mod module mustinherit mustoverride mybase myclass namespace narrowing new next not notinheritable notoverridable of off on operator option optional or order orelse overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim rem removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly xor",built_in:"boolean byte cbool cbyte cchar cdate cdec cdbl char cint clng cobj csbyte cshort csng cstr ctype date decimal directcast double gettype getxmlnamespace iif integer long object sbyte short single string trycast typeof uinteger ulong ushort",literal:"true false nothing"},i:"//|{|}|endif|gosub|variant|wend",c:[e.inherit(e.QSM,{c:[{b:'""'}]}),e.C("'","$",{rB:!0,c:[{cN:"doctag",b:"'''|",c:[e.PWM]},{cN:"doctag",b:"",c:[e.PWM]}]}),e.CNM,{cN:"meta",b:"#",e:"$",k:{"meta-keyword":"if else elseif end region externalsource"}}]}});hljs.registerLanguage("cs",function(e){var i={keyword:"abstract as base bool break byte case catch char checked const continue decimal default delegate do double enum event explicit extern finally fixed float for foreach goto if implicit in int interface internal is lock long nameof object operator out override params private protected public readonly ref sbyte sealed short sizeof stackalloc static string struct switch this try typeof uint ulong unchecked unsafe ushort using virtual void volatile while add alias ascending async await by descending dynamic equals from get global group into join let on orderby partial remove select set value var where yield",literal:"null false true"},t={cN:"string",b:'@"',e:'"',c:[{b:'""'}]},r=e.inherit(t,{i:/\n/}),a={cN:"subst",b:"{",e:"}",k:i},c=e.inherit(a,{i:/\n/}),n={cN:"string",b:/\$"/,e:'"',i:/\n/,c:[{b:"{{"},{b:"}}"},e.BE,c]},s={cN:"string",b:/\$@"/,e:'"',c:[{b:"{{"},{b:"}}"},{b:'""'},a]},o=e.inherit(s,{i:/\n/,c:[{b:"{{"},{b:"}}"},{b:'""'},c]});a.c=[s,n,t,e.ASM,e.QSM,e.CNM,e.CBCM],c.c=[o,n,r,e.ASM,e.QSM,e.CNM,e.inherit(e.CBCM,{i:/\n/})];var l={v:[s,n,t,e.ASM,e.QSM]},b=e.IR+"(<"+e.IR+"(\\s*,\\s*"+e.IR+")*>)?(\\[\\])?";return{aliases:["csharp"],k:i,i:/::/,c:[e.C("///","$",{rB:!0,c:[{cN:"doctag",v:[{b:"///",r:0},{b:""},{b:""}]}]}),e.CLCM,e.CBCM,{cN:"meta",b:"#",e:"$",k:{"meta-keyword":"if else elif endif define undef warning error line region endregion pragma checksum"}},l,e.CNM,{bK:"class interface",e:/[{;=]/,i:/[^\s:]/,c:[e.TM,e.CLCM,e.CBCM]},{bK:"namespace",e:/[{;=]/,i:/[^\s:]/,c:[e.inherit(e.TM,{b:"[a-zA-Z](\\.?\\w)*"}),e.CLCM,e.CBCM]},{cN:"meta",b:"^\\s*\\[",eB:!0,e:"\\]",eE:!0,c:[{cN:"meta-string",b:/"/,e:/"/}]},{bK:"new return throw await else",r:0},{cN:"function",b:"("+b+"\\s+)+"+e.IR+"\\s*\\(",rB:!0,e:/[{;=]/,eE:!0,k:i,c:[{b:e.IR+"\\s*\\(",rB:!0,c:[e.TM],r:0},{cN:"params",b:/\(/,e:/\)/,eB:!0,eE:!0,k:i,r:0,c:[l,e.CNM,e.CBCM]},e.CLCM,e.CBCM]}]}});hljs.registerLanguage("sql",function(e){var t=e.C("--","$");return{cI:!0,i:/[<>{}*#]/,c:[{bK:"begin end start commit rollback savepoint lock alter create drop rename call delete do handler insert load replace select truncate update set show pragma grant merge describe use explain help declare prepare execute deallocate release unlock purge reset change stop analyze cache flush optimize repair kill install uninstall checksum restore check backup revoke comment",e:/;/,eW:!0,l:/[\w\.]+/,k:{keyword:"abort abs absolute acc acce accep accept access accessed accessible account acos action activate add addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias allocate allow alter always analyze ancillary and any anydata anydataset anyschema anytype apply archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound buffer_cache buffer_pool build bulk by byte byteordermark bytes cache caching call calling cancel capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base char_length character_length characters characterset charindex charset charsetform charsetid check checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation collect colu colum column column_value columns columns_updated comment commit compact compatibility compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection consider consistent constant constraint constraints constructor container content contents context contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user cursor curtime customdatum cycle data database databases datafile datafiles datalength date_add date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor deterministic diagnostics difference dimension direct_load directory disable disable_all disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div do document domain dotnet double downgrade drop dumpfile duplicate duration each edition editionable editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding execu execut execute exempt exists exit exp expire explain export export_set extended extent external external_1 external_2 externally extract failed failed_login_attempts failover failure far fast feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final finish first first_value fixed flash_cache flashback floor flush following follows for forall force form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ftp full function general generated get get_format get_lock getdate getutcdate global global_name globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex hierarchy high high_priority hosts hour http id ident_current ident_incr ident_seed identified identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile initial initialized initially initrans inmemory inner innodb input insert install instance instantiable instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists keep keep_duplicates key keys kill language large last last_day last_insert_id last_value lax lcase lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call logoff logon logs long loop low low_priority lower lpad lrtrim ltrim main make_set makedate maketime managed management manual map mapping mask master master_pos_wait match matched materialized max maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans md5 measures median medium member memcompress memory merge microsecond mid migration min minextents minimum mining minus minute minvalue missing mod mode model modification modify module monitoring month months mount move movement multiset mutex name name_const names nan national native natural nav nchar nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck noswitch not nothing notice notrim novalidate now nowait nth_value nullif nulls num numb numbe nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary out outer outfile outline output over overflow overriding package pad parallel parallel_enable parameters parent parse partial partition partitions pascal passing password password_grace_time password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction prediction_cost prediction_details prediction_probability prediction_set prepare present preserve prior priority private private_sga privileges procedural procedure procedure_analyze processlist profiles project prompt protection public publishingservername purge quarter query quick quiesce quota quotename radians raise rand range rank raw read reads readsize rebuild record records recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename repair repeat replace replicate replication required reset resetlogs resize resource respect restore restricted result result_cache resumable resume retention return returning returns reuse reverse revoke right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll sdo_georaster sdo_topo_geometry search sec_to_time second section securefile security seed segment select self sequence sequential serializable server servererror session session_user sessions_per_user set sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone standby start starting startup statement static statistics stats_binomial_test stats_crosstab stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime table tables tablespace tan tdo template temporary terminated tertiary_weights test than then thread through tier ties time time_format time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unpivot unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear wellformed when whene whenev wheneve whenever where while whitespace with within without work wrapped xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek",literal:"true false null",built_in:"array bigint binary bit blob boolean char character date dec decimal float int int8 integer interval number numeric real record serial serial8 smallint text varchar varying void"},c:[{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]},{cN:"string",b:'"',e:'"',c:[e.BE,{b:'""'}]},{cN:"string",b:"`",e:"`",c:[e.BE]},e.CNM,e.CBCM,t]},e.CBCM,t]}});hljs.registerLanguage("scss",function(e){var t="[a-zA-Z-][a-zA-Z0-9_-]*",i={cN:"variable",b:"(\\$"+t+")\\b"},r={cN:"number",b:"#[0-9A-Fa-f]+"};({cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:!0,i:"[^\\s]",starts:{eW:!0,eE:!0,c:[r,e.CSSNM,e.QSM,e.ASM,e.CBCM,{cN:"meta",b:"!important"}]}});return{cI:!0,i:"[=/|']",c:[e.CLCM,e.CBCM,{cN:"selector-id",b:"\\#[A-Za-z0-9_-]+",r:0},{cN:"selector-class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"selector-attr",b:"\\[",e:"\\]",i:"$"},{cN:"selector-tag",b:"\\b(a|abbr|acronym|address|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|command|datalist|dd|del|details|dfn|div|dl|dt|em|embed|fieldset|figcaption|figure|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|keygen|label|legend|li|link|map|mark|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|pre|progress|q|rp|rt|ruby|samp|script|section|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video)\\b",r:0},{b:":(visited|valid|root|right|required|read-write|read-only|out-range|optional|only-of-type|only-child|nth-of-type|nth-last-of-type|nth-last-child|nth-child|not|link|left|last-of-type|last-child|lang|invalid|indeterminate|in-range|hover|focus|first-of-type|first-line|first-letter|first-child|first|enabled|empty|disabled|default|checked|before|after|active)"},{b:"::(after|before|choices|first-letter|first-line|repeat-index|repeat-item|selection|value)"},i,{cN:"attribute",b:"\\b(z-index|word-wrap|word-spacing|word-break|width|widows|white-space|visibility|vertical-align|unicode-bidi|transition-timing-function|transition-property|transition-duration|transition-delay|transition|transform-style|transform-origin|transform|top|text-underline-position|text-transform|text-shadow|text-rendering|text-overflow|text-indent|text-decoration-style|text-decoration-line|text-decoration-color|text-decoration|text-align-last|text-align|tab-size|table-layout|right|resize|quotes|position|pointer-events|perspective-origin|perspective|page-break-inside|page-break-before|page-break-after|padding-top|padding-right|padding-left|padding-bottom|padding|overflow-y|overflow-x|overflow-wrap|overflow|outline-width|outline-style|outline-offset|outline-color|outline|orphans|order|opacity|object-position|object-fit|normal|none|nav-up|nav-right|nav-left|nav-index|nav-down|min-width|min-height|max-width|max-height|mask|marks|margin-top|margin-right|margin-left|margin-bottom|margin|list-style-type|list-style-position|list-style-image|list-style|line-height|letter-spacing|left|justify-content|initial|inherit|ime-mode|image-orientation|image-resolution|image-rendering|icon|hyphens|height|font-weight|font-variant-ligatures|font-variant|font-style|font-stretch|font-size-adjust|font-size|font-language-override|font-kerning|font-feature-settings|font-family|font|float|flex-wrap|flex-shrink|flex-grow|flex-flow|flex-direction|flex-basis|flex|filter|empty-cells|display|direction|cursor|counter-reset|counter-increment|content|column-width|column-span|column-rule-width|column-rule-style|column-rule-color|column-rule|column-gap|column-fill|column-count|columns|color|clip-path|clip|clear|caption-side|break-inside|break-before|break-after|box-sizing|box-shadow|box-decoration-break|bottom|border-width|border-top-width|border-top-style|border-top-right-radius|border-top-left-radius|border-top-color|border-top|border-style|border-spacing|border-right-width|border-right-style|border-right-color|border-right|border-radius|border-left-width|border-left-style|border-left-color|border-left|border-image-width|border-image-source|border-image-slice|border-image-repeat|border-image-outset|border-image|border-color|border-collapse|border-bottom-width|border-bottom-style|border-bottom-right-radius|border-bottom-left-radius|border-bottom-color|border-bottom|border|background-size|background-repeat|background-position|background-origin|background-image|background-color|background-clip|background-attachment|background-blend-mode|background|backface-visibility|auto|animation-timing-function|animation-play-state|animation-name|animation-iteration-count|animation-fill-mode|animation-duration|animation-direction|animation-delay|animation|align-self|align-items|align-content)\\b",i:"[^\\s]"},{b:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{b:":",e:";",c:[i,r,e.CSSNM,e.QSM,e.ASM,{cN:"meta",b:"!important"}]},{b:"@",e:"[{;]",k:"mixin include extend for if else each while charset import debug media page content font-face namespace warn",c:[i,e.QSM,e.ASM,r,e.CSSNM,{b:"\\s[A-Za-z0-9_.-]+",r:0}]}]}});hljs.registerLanguage("fsharp",function(e){var t={b:"<",e:">",c:[e.inherit(e.TM,{b:/'[a-zA-Z0-9_]+/})]};return{aliases:["fs"],k:"abstract and as assert base begin class default delegate do done downcast downto elif else end exception extern false finally for fun function global if in inherit inline interface internal lazy let match member module mutable namespace new null of open or override private public rec return sig static struct then to true try type upcast use val void when while with yield",i:/\/\*/,c:[{cN:"keyword",b:/\b(yield|return|let|do)!/},{cN:"string",b:'@"',e:'"',c:[{b:'""'}]},{cN:"string",b:'"""',e:'"""'},e.C("\\(\\*","\\*\\)"),{cN:"class",bK:"type",e:"\\(|=|$",eE:!0,c:[e.UTM,t]},{cN:"meta",b:"\\[<",e:">\\]",r:10},{cN:"symbol",b:"\\B('[A-Za-z])\\b",c:[e.BE]},e.CLCM,e.inherit(e.QSM,{i:null}),e.CNM]}});hljs.registerLanguage("vhdl",function(e){var r="\\d(_|\\d)*",t="[eE][-+]?"+r,n=r+"(\\."+r+")?("+t+")?",o="\\w+",i=r+"#"+o+"(\\."+o+")?#("+t+")?",a="\\b("+i+"|"+n+")";return{cI:!0,k:{keyword:"abs access after alias all and architecture array assert assume assume_guarantee attribute begin block body buffer bus case component configuration constant context cover disconnect downto default else elsif end entity exit fairness file for force function generate generic group guarded if impure in inertial inout is label library linkage literal loop map mod nand new next nor not null of on open or others out package port postponed procedure process property protected pure range record register reject release rem report restrict restrict_guarantee return rol ror select sequence severity shared signal sla sll sra srl strong subtype then to transport type unaffected units until use variable vmode vprop vunit wait when while with xnor xor",built_in:"boolean bit character integer time delay_length natural positive string bit_vector file_open_kind file_open_status std_logic std_logic_vector unsigned signed boolean_vector integer_vector std_ulogic std_ulogic_vector unresolved_unsigned u_unsigned unresolved_signed u_signedreal_vector time_vector",literal:"false true note warning error failure line text side width"},i:"{",c:[e.CBCM,e.C("--","$"),e.QSM,{cN:"number",b:a,r:0},{cN:"string",b:"'(U|X|0|1|Z|W|L|H|-)'",c:[e.BE]},{cN:"symbol",b:"'[A-Za-z](_?[A-Za-z0-9])*",c:[e.BE]}]}});hljs.registerLanguage("swift",function(e){var i={keyword:"__COLUMN__ __FILE__ __FUNCTION__ __LINE__ as as! as? associativity break case catch class continue convenience default defer deinit didSet do dynamic dynamicType else enum extension fallthrough false fileprivate final for func get guard if import in indirect infix init inout internal is lazy left let mutating nil none nonmutating open operator optional override postfix precedence prefix private protocol Protocol public repeat required rethrows return right self Self set static struct subscript super switch throw throws true try try! try? Type typealias unowned var weak where while willSet",literal:"true false nil",built_in:"abs advance alignof alignofValue anyGenerator assert assertionFailure bridgeFromObjectiveC bridgeFromObjectiveCUnconditional bridgeToObjectiveC bridgeToObjectiveCUnconditional c contains count countElements countLeadingZeros debugPrint debugPrintln distance dropFirst dropLast dump encodeBitsAsWords enumerate equal fatalError filter find getBridgedObjectiveCType getVaList indices insertionSort isBridgedToObjectiveC isBridgedVerbatimToObjectiveC isUniquelyReferenced isUniquelyReferencedNonObjC join lazy lexicographicalCompare map max maxElement min minElement numericCast overlaps partition posix precondition preconditionFailure print println quickSort readLine reduce reflect reinterpretCast reverse roundUpToAlignment sizeof sizeofValue sort split startsWith stride strideof strideofValue swap toString transcode underestimateCount unsafeAddressOf unsafeBitCast unsafeDowncast unsafeUnwrap unsafeReflect withExtendedLifetime withObjectAtPlusZero withUnsafePointer withUnsafePointerToObject withUnsafeMutablePointer withUnsafeMutablePointers withUnsafePointer withUnsafePointers withVaList zip"},t={cN:"type",b:"\\b[A-Z][\\wÀ-ʸ']*",r:0},n=e.C("/\\*","\\*/",{c:["self"]}),r={cN:"subst",b:/\\\(/,e:"\\)",k:i,c:[]},a={cN:"number",b:"\\b([\\d_]+(\\.[\\deE_]+)?|0x[a-fA-F0-9_]+(\\.[a-fA-F0-9p_]+)?|0b[01_]+|0o[0-7_]+)\\b",r:0},o=e.inherit(e.QSM,{c:[r,e.BE]});return r.c=[a],{k:i,c:[o,e.CLCM,n,t,a,{cN:"function",bK:"func",e:"{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][0-9A-Za-z$_]*/}),{b://},{cN:"params",b:/\(/,e:/\)/,endsParent:!0,k:i,c:["self",a,o,e.CBCM,{b:":"}],i:/["']/}],i:/\[|%/},{cN:"class",bK:"struct protocol class extension enum",k:i,e:"\\{",eE:!0,c:[e.inherit(e.TM,{b:/[A-Za-z$_][\u00C0-\u02B80-9A-Za-z$_]*/})]},{cN:"meta",b:"(@warn_unused_result|@exported|@lazy|@noescape|@NSCopying|@NSManaged|@objc|@convention|@required|@noreturn|@IBAction|@IBDesignable|@IBInspectable|@IBOutlet|@infix|@prefix|@postfix|@autoclosure|@testable|@available|@nonobjc|@NSApplicationMain|@UIApplicationMain)"},{bK:"import",e:/$/,c:[e.CLCM,n]}]}});hljs.registerLanguage("yaml",function(e){var b="true false yes no null",a="^[ \\-]*",r="[a-zA-Z_][\\w\\-]*",t={cN:"attr",v:[{b:a+r+":"},{b:a+'"'+r+'":'},{b:a+"'"+r+"':"}]},c={cN:"template-variable",v:[{b:"{{",e:"}}"},{b:"%{",e:"}"}]},l={cN:"string",r:0,v:[{b:/'/,e:/'/},{b:/"/,e:/"/},{b:/\S+/}],c:[e.BE,c]};return{cI:!0,aliases:["yml","YAML","yaml"],c:[t,{cN:"meta",b:"^---s*$",r:10},{cN:"string",b:"[\\|>] *$",rE:!0,c:l.c,e:t.v[0].b},{b:"<%[%=-]?",e:"[%-]?%>",sL:"ruby",eB:!0,eE:!0,r:0},{cN:"type",b:"!!"+e.UIR},{cN:"meta",b:"&"+e.UIR+"$"},{cN:"meta",b:"\\*"+e.UIR+"$"},{cN:"bullet",b:"^ *-",r:0},e.HCM,{bK:b,k:{literal:b}},e.CNM,l]}});hljs.registerLanguage("php",function(e){var c={b:"\\$+[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"},i={cN:"meta",b:/<\?(php)?|\?>/},t={cN:"string",c:[e.BE,i],v:[{b:'b"',e:'"'},{b:"b'",e:"'"},e.inherit(e.ASM,{i:null}),e.inherit(e.QSM,{i:null})]},a={v:[e.BNM,e.CNM]};return{aliases:["php3","php4","php5","php6"],cI:!0,k:"and include_once list abstract global private echo interface as static endswitch array null if endwhile or const for endforeach self var while isset public protected exit foreach throw elseif include __FILE__ empty require_once do xor return parent clone use __CLASS__ __LINE__ else break print eval new catch __METHOD__ case exception default die require __FUNCTION__ enddeclare final try switch continue endfor endif declare unset true false trait goto instanceof insteadof __DIR__ __NAMESPACE__ yield finally",c:[e.HCM,e.C("//","$",{c:[i]}),e.C("/\\*","\\*/",{c:[{cN:"doctag",b:"@[A-Za-z]+"}]}),e.C("__halt_compiler.+?;",!1,{eW:!0,k:"__halt_compiler",l:e.UIR}),{cN:"string",b:/<<<['"]?\w+['"]?$/,e:/^\w+;?$/,c:[e.BE,{cN:"subst",v:[{b:/\$\w+/},{b:/\{\$/,e:/\}/}]}]},i,{cN:"keyword",b:/\$this\b/},c,{b:/(::|->)+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/},{cN:"function",bK:"function",e:/[;{]/,eE:!0,i:"\\$|\\[|%",c:[e.UTM,{cN:"params",b:"\\(",e:"\\)",c:["self",c,e.CBCM,t,a]}]},{cN:"class",bK:"class interface",e:"{",eE:!0,i:/[:\(\$"]/,c:[{bK:"extends implements"},e.UTM]},{bK:"namespace",e:";",i:/[\.']/,c:[e.UTM]},{bK:"use",e:";",c:[e.UTM]},{b:"=>"},t,a]}});hljs.registerLanguage("http",function(e){var t="HTTP/[0-9\\.]+";return{aliases:["https"],i:"\\S",c:[{b:"^"+t,e:"$",c:[{cN:"number",b:"\\b\\d{3}\\b"}]},{b:"^[A-Z]+ (.*?) "+t+"$",rB:!0,e:"$",c:[{cN:"string",b:" ",e:" ",eB:!0,eE:!0},{b:t},{cN:"keyword",b:"[A-Z]+"}]},{cN:"attribute",b:"^\\w",e:": ",eE:!0,i:"\\n|\\s|=",starts:{e:"$",r:0}},{b:"\\n\\n",starts:{sL:[],eW:!0}}]}}); \ No newline at end of file diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/icon_weibo_24.png" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/icon_weibo_24.png" new file mode 100644 index 0000000000000000000000000000000000000000..793e4e97ed9b24329350e8f9f7765baf834f5738 Binary files /dev/null and "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/icon_weibo_24.png" differ diff --git "a/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/jquery-2.2.0.min.js.\344\270\213\350\275\275" "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/jquery-2.2.0.min.js.\344\270\213\350\275\275" new file mode 100644 index 0000000000000000000000000000000000000000..06ac2631505fe2b7245b7b7bec2d759b4d51c624 --- /dev/null +++ "b/\345\260\232\347\241\205\350\260\267Java\345\205\245\351\227\250\346\225\231\347\250\213\357\274\214java\347\224\265\345\255\220\344\271\246+Java\351\235\242\350\257\225\347\234\237\351\242\230\357\274\2102023\346\226\260\347\211\210\357\274\211/06_\350\275\257\344\273\266\344\270\216\350\265\204\346\226\231/02-\346\226\207\346\234\254\347\274\226\350\276\221\345\231\250-EditPlus/\345\246\202\344\275\225\346\263\250\345\206\214/EditPlus\345\220\204\344\270\252\347\211\210\346\234\254\347\232\204\346\263\250\345\206\214\347\240\201_files/jquery-2.2.0.min.js.\344\270\213\350\275\275" @@ -0,0 +1,4 @@ +/*! jQuery v2.2.0 | (c) jQuery Foundation | jquery.org/license */ +!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="2.2.0",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(e.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=a&&a.toString();return!n.isArray(a)&&b-parseFloat(b)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!k.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?i[j.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=d.createElement("script"),b.text=a,d.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(s(a)){for(c=a.length;c>d;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):g.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:h.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,g=0,h=[];if(s(a))for(d=a.length;d>g;g++)e=b(a[g],g,c),null!=e&&h.push(e);else for(g in a)e=b(a[g],g,c),null!=e&&h.push(e);return f.apply([],h)},guid:1,proxy:function(a,b){var c,d,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(d=e.call(arguments,2),f=function(){return a.apply(b||this,d.concat(e.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:l}),"function"==typeof Symbol&&(n.fn[Symbol.iterator]=c[Symbol.iterator]),n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){i["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=!!a&&"length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ga(),z=ga(),A=ga(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+M+"))|)"+L+"*\\]",O=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+N+")*)|.*)\\)|)",P=new RegExp(L+"+","g"),Q=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),R=new RegExp("^"+L+"*,"+L+"*"),S=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),T=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),U=new RegExp(O),V=new RegExp("^"+M+"$"),W={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M+"|[*])"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},X=/^(?:input|select|textarea|button)$/i,Y=/^h\d$/i,Z=/^[^{]+\{\s*\[native \w/,$=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,_=/[+~]/,aa=/'|\\/g,ba=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),ca=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},da=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(ea){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fa(a,b,d,e){var f,h,j,k,l,o,r,s,w=b&&b.ownerDocument,x=b?b.nodeType:9;if(d=d||[],"string"!=typeof a||!a||1!==x&&9!==x&&11!==x)return d;if(!e&&((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,p)){if(11!==x&&(o=$.exec(a)))if(f=o[1]){if(9===x){if(!(j=b.getElementById(f)))return d;if(j.id===f)return d.push(j),d}else if(w&&(j=w.getElementById(f))&&t(b,j)&&j.id===f)return d.push(j),d}else{if(o[2])return H.apply(d,b.getElementsByTagName(a)),d;if((f=o[3])&&c.getElementsByClassName&&b.getElementsByClassName)return H.apply(d,b.getElementsByClassName(f)),d}if(c.qsa&&!A[a+" "]&&(!q||!q.test(a))){if(1!==x)w=b,s=a;else if("object"!==b.nodeName.toLowerCase()){(k=b.getAttribute("id"))?k=k.replace(aa,"\\$&"):b.setAttribute("id",k=u),r=g(a),h=r.length,l=V.test(k)?"#"+k:"[id='"+k+"']";while(h--)r[h]=l+" "+qa(r[h]);s=r.join(","),w=_.test(a)&&oa(b.parentNode)||b}if(s)try{return H.apply(d,w.querySelectorAll(s)),d}catch(y){}finally{k===u&&b.removeAttribute("id")}}}return i(a.replace(Q,"$1"),b,d,e)}function ga(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ha(a){return a[u]=!0,a}function ia(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ja(a,b){var c=a.split("|"),e=c.length;while(e--)d.attrHandle[c[e]]=b}function ka(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function la(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function na(a){return ha(function(b){return b=+b,ha(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function oa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=fa.support={},f=fa.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fa.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=n.documentElement,p=!f(n),(e=n.defaultView)&&e.top!==e&&(e.addEventListener?e.addEventListener("unload",da,!1):e.attachEvent&&e.attachEvent("onunload",da)),c.attributes=ia(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ia(function(a){return a.appendChild(n.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Z.test(n.getElementsByClassName),c.getById=ia(function(a){return o.appendChild(a).id=u,!n.getElementsByName||!n.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ba,ca);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ba,ca);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return"undefined"!=typeof b.getElementsByClassName&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=Z.test(n.querySelectorAll))&&(ia(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ia(function(a){var b=n.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=Z.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ia(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",O)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=Z.test(o.compareDocumentPosition),t=b||Z.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===n||a.ownerDocument===v&&t(v,a)?-1:b===n||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,g=[a],h=[b];if(!e||!f)return a===n?-1:b===n?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return ka(a,b);c=a;while(c=c.parentNode)g.unshift(c);c=b;while(c=c.parentNode)h.unshift(c);while(g[d]===h[d])d++;return d?ka(g[d],h[d]):g[d]===v?-1:h[d]===v?1:0},n):n},fa.matches=function(a,b){return fa(a,null,null,b)},fa.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(T,"='$1']"),c.matchesSelector&&p&&!A[b+" "]&&(!r||!r.test(b))&&(!q||!q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fa(b,n,null,[a]).length>0},fa.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fa.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fa.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fa.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fa.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fa.selectors={cacheLength:50,createPseudo:ha,match:W,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ba,ca),a[3]=(a[3]||a[4]||a[5]||"").replace(ba,ca),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fa.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fa.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return W.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&U.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ba,ca).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fa.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(P," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h,t=!1;if(q){if(f){while(p){m=b;while(m=m[p])if(h?m.nodeName.toLowerCase()===r:1===m.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){m=q,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n&&j[2],m=n&&q.childNodes[n];while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if(1===m.nodeType&&++t&&m===b){k[a]=[w,n,t];break}}else if(s&&(m=b,l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),j=k[a]||[],n=j[0]===w&&j[1],t=n),t===!1)while(m=++n&&m&&m[p]||(t=n=0)||o.pop())if((h?m.nodeName.toLowerCase()===r:1===m.nodeType)&&++t&&(s&&(l=m[u]||(m[u]={}),k=l[m.uniqueID]||(l[m.uniqueID]={}),k[a]=[w,t]),m===b))break;return t-=e,t===d||t%d===0&&t/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fa.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ha(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ha(function(a){var b=[],c=[],d=h(a.replace(Q,"$1"));return d[u]?ha(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ha(function(a){return function(b){return fa(a,b).length>0}}),contains:ha(function(a){return a=a.replace(ba,ca),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ha(function(a){return V.test(a||"")||fa.error("unsupported lang: "+a),a=a.replace(ba,ca).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Y.test(a.nodeName)},input:function(a){return X.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:na(function(){return[0]}),last:na(function(a,b){return[b-1]}),eq:na(function(a,b,c){return[0>c?c+b:c]}),even:na(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:na(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:na(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:na(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function ra(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j,k=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(j=b[u]||(b[u]={}),i=j[b.uniqueID]||(j[b.uniqueID]={}),(h=i[d])&&h[0]===w&&h[1]===f)return k[2]=h[2];if(i[d]=k,k[2]=a(b,c,g))return!0}}}function sa(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ta(a,b,c){for(var d=0,e=b.length;e>d;d++)fa(a,b[d],c);return c}function ua(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function va(a,b,c,d,e,f){return d&&!d[u]&&(d=va(d)),e&&!e[u]&&(e=va(e,f)),ha(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ta(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ua(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ua(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ua(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function wa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=ra(function(a){return a===b},h,!0),l=ra(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[ra(sa(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return va(i>1&&sa(m),i>1&&qa(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(Q,"$1"),c,e>i&&wa(a.slice(i,e)),f>e&&wa(a=a.slice(e)),f>e&&qa(a))}m.push(c)}return sa(m)}function xa(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,o,q,r=0,s="0",t=f&&[],u=[],v=j,x=f||e&&d.find.TAG("*",k),y=w+=null==v?1:Math.random()||.1,z=x.length;for(k&&(j=g===n||g||k);s!==z&&null!=(l=x[s]);s++){if(e&&l){o=0,g||l.ownerDocument===n||(m(l),h=!p);while(q=a[o++])if(q(l,g||n,h)){i.push(l);break}k&&(w=y)}c&&((l=!q&&l)&&r--,f&&t.push(l))}if(r+=s,c&&s!==r){o=0;while(q=b[o++])q(t,u,g,h);if(f){if(r>0)while(s--)t[s]||u[s]||(u[s]=F.call(i));u=ua(u)}H.apply(i,u),k&&!f&&u.length>0&&r+b.length>1&&fa.uniqueSort(i)}return k&&(w=y,j=v),t};return c?ha(f):f}return h=fa.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xa(e,d)),f.selector=a}return f},i=fa.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ba,ca),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=W.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ba,ca),_.test(j[0].type)&&oa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qa(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,!b||_.test(a)&&oa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ia(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ia(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ja("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ia(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ja("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ia(function(a){return null==a.getAttribute("disabled")})||ja(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fa}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.uniqueSort=n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},v=function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c},w=n.expr.match.needsContext,x=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,y=/^.[^:#\[\.,]*$/;function z(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(y.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return h.call(b,a)>-1!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(z(this,a||[],!1))},not:function(a){return this.pushStack(z(this,a||[],!0))},is:function(a){return!!z(this,"string"==typeof a&&w.test(a)?n(a):a||[],!1).length}});var A,B=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,C=n.fn.init=function(a,b,c){var e,f;if(!a)return this;if(c=c||A,"string"==typeof a){if(e="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:B.exec(a),!e||!e[1]&&b)return!b||b.jquery?(b||c).find(a):this.constructor(b).find(a);if(e[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(e[1],b&&b.nodeType?b.ownerDocument||b:d,!0)),x.test(e[1])&&n.isPlainObject(b))for(e in b)n.isFunction(this[e])?this[e](b[e]):this.attr(e,b[e]);return this}return f=d.getElementById(e[2]),f&&f.parentNode&&(this.length=1,this[0]=f),this.context=d,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?void 0!==c.ready?c.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};C.prototype=n.fn,A=n(d);var D=/^(?:parents|prev(?:Until|All))/,E={children:!0,contents:!0,next:!0,prev:!0};n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=w.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.uniqueSort(f):f)},index:function(a){return a?"string"==typeof a?h.call(n(a),this[0]):h.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.uniqueSort(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function F(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return u(a,"parentNode")},parentsUntil:function(a,b,c){return u(a,"parentNode",c)},next:function(a){return F(a,"nextSibling")},prev:function(a){return F(a,"previousSibling")},nextAll:function(a){return u(a,"nextSibling")},prevAll:function(a){return u(a,"previousSibling")},nextUntil:function(a,b,c){return u(a,"nextSibling",c)},prevUntil:function(a,b,c){return u(a,"previousSibling",c)},siblings:function(a){return v((a.parentNode||{}).firstChild,a)},children:function(a){return v(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(E[a]||n.uniqueSort(e),D.test(a)&&e.reverse()),this.pushStack(e)}});var G=/\S+/g;function H(a){var b={};return n.each(a.match(G)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?H(a):n.extend({},a);var b,c,d,e,f=[],g=[],h=-1,i=function(){for(e=a.once,d=b=!0;g.length;h=-1){c=g.shift();while(++h-1)f.splice(c,1),h>=c&&h--}),this},has:function(a){return a?n.inArray(a,f)>-1:f.length>0},empty:function(){return f&&(f=[]),this},disable:function(){return e=g=[],f=c="",this},disabled:function(){return!f},lock:function(){return e=g=[],c||(f=c=""),this},locked:function(){return!!e},fireWith:function(a,c){return e||(c=c||[],c=[a,c.slice?c.slice():c],g.push(c),b||i()),this},fire:function(){return j.fireWith(this,arguments),this},fired:function(){return!!d}};return j},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().progress(c.notify).done(c.resolve).fail(c.reject):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=e.call(arguments),d=c.length,f=1!==d||a&&n.isFunction(a.promise)?d:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?e.call(arguments):d,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(d>1)for(i=new Array(d),j=new Array(d),k=new Array(d);d>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().progress(h(b,j,i)).done(h(b,k,c)).fail(g.reject):--f;return f||g.resolveWith(k,c),g.promise()}});var I;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(I.resolveWith(d,[n]),n.fn.triggerHandler&&(n(d).triggerHandler("ready"),n(d).off("ready"))))}});function J(){d.removeEventListener("DOMContentLoaded",J),a.removeEventListener("load",J),n.ready()}n.ready.promise=function(b){return I||(I=n.Deferred(),"complete"===d.readyState||"loading"!==d.readyState&&!d.documentElement.doScroll?a.setTimeout(n.ready):(d.addEventListener("DOMContentLoaded",J),a.addEventListener("load",J))),I.promise(b)},n.ready.promise();var K=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)K(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},L=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function M(){this.expando=n.expando+M.uid++}M.uid=1,M.prototype={register:function(a,b){var c=b||{};return a.nodeType?a[this.expando]=c:Object.defineProperty(a,this.expando,{value:c,writable:!0,configurable:!0}),a[this.expando]},cache:function(a){if(!L(a))return{};var b=a[this.expando];return b||(b={},L(a)&&(a.nodeType?a[this.expando]=b:Object.defineProperty(a,this.expando,{value:b,configurable:!0}))),b},set:function(a,b,c){var d,e=this.cache(a);if("string"==typeof b)e[b]=c;else for(d in b)e[d]=b[d];return e},get:function(a,b){return void 0===b?this.cache(a):a[this.expando]&&a[this.expando][b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=a[this.expando];if(void 0!==f){if(void 0===b)this.register(a);else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in f?d=[b,e]:(d=e,d=d in f?[d]:d.match(G)||[])),c=d.length;while(c--)delete f[d[c]]}(void 0===b||n.isEmptyObject(f))&&(a.nodeType?a[this.expando]=void 0:delete a[this.expando])}},hasData:function(a){var b=a[this.expando];return void 0!==b&&!n.isEmptyObject(b)}};var N=new M,O=new M,P=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Q=/[A-Z]/g;function R(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(Q,"-$&").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:P.test(c)?n.parseJSON(c):c}catch(e){}O.set(a,b,c); +}else c=void 0;return c}n.extend({hasData:function(a){return O.hasData(a)||N.hasData(a)},data:function(a,b,c){return O.access(a,b,c)},removeData:function(a,b){O.remove(a,b)},_data:function(a,b,c){return N.access(a,b,c)},_removeData:function(a,b){N.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=O.get(f),1===f.nodeType&&!N.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),R(f,d,e[d])));N.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){O.set(this,a)}):K(this,function(b){var c,d;if(f&&void 0===b){if(c=O.get(f,a)||O.get(f,a.replace(Q,"-$&").toLowerCase()),void 0!==c)return c;if(d=n.camelCase(a),c=O.get(f,d),void 0!==c)return c;if(c=R(f,d,void 0),void 0!==c)return c}else d=n.camelCase(a),this.each(function(){var c=O.get(this,d);O.set(this,d,b),a.indexOf("-")>-1&&void 0!==c&&O.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){O.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=N.get(a,b),c&&(!d||n.isArray(c)?d=N.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return N.get(a,c)||N.access(a,c,{empty:n.Callbacks("once memory").add(function(){N.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length",""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};$.optgroup=$.option,$.tbody=$.tfoot=$.colgroup=$.caption=$.thead,$.th=$.td;function _(a,b){var c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function aa(a,b){for(var c=0,d=a.length;d>c;c++)N.set(a[c],"globalEval",!b||N.get(b[c],"globalEval"))}var ba=/<|&#?\w+;/;function ca(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],o=0,p=a.length;p>o;o++)if(f=a[o],f||0===f)if("object"===n.type(f))n.merge(m,f.nodeType?[f]:f);else if(ba.test(f)){g=g||l.appendChild(b.createElement("div")),h=(Y.exec(f)||["",""])[1].toLowerCase(),i=$[h]||$._default,g.innerHTML=i[1]+n.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;n.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",o=0;while(f=m[o++])if(d&&n.inArray(f,d)>-1)e&&e.push(f);else if(j=n.contains(f.ownerDocument,f),g=_(l.appendChild(f),"script"),j&&aa(g),c){k=0;while(f=g[k++])Z.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var da=/^key/,ea=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,fa=/^([^.]*)(?:\.(.+)|)/;function ga(){return!0}function ha(){return!1}function ia(){try{return d.activeElement}catch(a){}}function ja(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ja(a,h,c,d,b[h],f);return a}if(null==d&&null==e?(e=c,d=c=void 0):null==e&&("string"==typeof c?(e=d,d=void 0):(e=d,d=c,c=void 0)),e===!1)e=ha;else if(!e)return this;return 1===f&&(g=e,e=function(a){return n().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=n.guid++)),a.each(function(){n.event.add(this,b,e,d,c)})}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=N.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return"undefined"!=typeof n&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(G)||[""],j=b.length;while(j--)h=fa.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=N.hasData(a)&&N.get(a);if(r&&(i=r.events)){b=(b||"").match(G)||[""],j=b.length;while(j--)if(h=fa.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&N.remove(a,"handle events")}},dispatch:function(a){a=n.event.fix(a);var b,c,d,f,g,h=[],i=e.call(arguments),j=(N.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.rnamespace||a.rnamespace.test(g.namespace))&&(a.handleObj=g,a.data=g.data,d=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==d&&(a.result=d)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&("click"!==a.type||isNaN(a.button)||a.button<1))for(;i!==this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>-1:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,la=/\s*$/g;function pa(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a:a}function qa(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function ra(a){var b=na.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function sa(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(N.hasData(a)&&(f=N.access(a),g=N.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}O.hasData(a)&&(h=O.access(a),i=n.extend({},h),O.set(b,i))}}function ta(a,b){var c=b.nodeName.toLowerCase();"input"===c&&X.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function ua(a,b,c,d){b=f.apply([],b);var e,g,h,i,j,k,m=0,o=a.length,p=o-1,q=b[0],r=n.isFunction(q);if(r||o>1&&"string"==typeof q&&!l.checkClone&&ma.test(q))return a.each(function(e){var f=a.eq(e);r&&(b[0]=q.call(this,e,f.html())),ua(f,b,c,d)});if(o&&(e=ca(b,a[0].ownerDocument,!1,a,d),g=e.firstChild,1===e.childNodes.length&&(e=g),g||d)){for(h=n.map(_(e,"script"),qa),i=h.length;o>m;m++)j=e,m!==p&&(j=n.clone(j,!0,!0),i&&n.merge(h,_(j,"script"))),c.call(a[m],j,m);if(i)for(k=h[h.length-1].ownerDocument,n.map(h,ra),m=0;i>m;m++)j=h[m],Z.test(j.type||"")&&!N.access(j,"globalEval")&&n.contains(k,j)&&(j.src?n._evalUrl&&n._evalUrl(j.src):n.globalEval(j.textContent.replace(oa,"")))}return a}function va(a,b,c){for(var d,e=b?n.filter(b,a):a,f=0;null!=(d=e[f]);f++)c||1!==d.nodeType||n.cleanData(_(d)),d.parentNode&&(c&&n.contains(d.ownerDocument,d)&&aa(_(d,"script")),d.parentNode.removeChild(d));return a}n.extend({htmlPrefilter:function(a){return a.replace(ka,"<$1>")},clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=_(h),f=_(a),d=0,e=f.length;e>d;d++)ta(f[d],g[d]);if(b)if(c)for(f=f||_(a),g=g||_(h),d=0,e=f.length;e>d;d++)sa(f[d],g[d]);else sa(a,h);return g=_(h,"script"),g.length>0&&aa(g,!i&&_(a,"script")),h},cleanData:function(a){for(var b,c,d,e=n.event.special,f=0;void 0!==(c=a[f]);f++)if(L(c)){if(b=c[N.expando]){if(b.events)for(d in b.events)e[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);c[N.expando]=void 0}c[O.expando]&&(c[O.expando]=void 0)}}}),n.fn.extend({domManip:ua,detach:function(a){return va(this,a,!0)},remove:function(a){return va(this,a)},text:function(a){return K(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return ua(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=pa(this,a);b.appendChild(a)}})},prepend:function(){return ua(this,arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=pa(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return ua(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return ua(this,arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(_(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return K(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!la.test(a)&&!$[(Y.exec(a)||["",""])[1].toLowerCase()]){a=n.htmlPrefilter(a);try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(_(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=[];return ua(this,arguments,function(b){var c=this.parentNode;n.inArray(this,a)<0&&(n.cleanData(_(this)),c&&c.replaceChild(b,this))},a)}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),f=e.length-1,h=0;f>=h;h++)c=h===f?this:this.clone(!0),n(e[h])[b](c),g.apply(d,c.get());return this.pushStack(d)}});var wa,xa={HTML:"block",BODY:"block"};function ya(a,b){var c=n(b.createElement(a)).appendTo(b.body),d=n.css(c[0],"display");return c.detach(),d}function za(a){var b=d,c=xa[a];return c||(c=ya(a,b),"none"!==c&&c||(wa=(wa||n("