纵然,自己手写工具方法会很爽,但有些工具类还是值得参考:
Display-----
StringUtils
The bread and butter of the commons-lang library, this utility class includes some methods that should seriously have been included in String long time ago.
- StringUtils.isEmpty(null) && StringUtils.isEmpty(""); // true
- StringUtils.isBlank(" \n\t"); // true
- StringUtils.substringAfterLast("foo.bar.baz", "."); // "baz"
- StringUtils.substringBeforeLast("foo.bar.baz", "."); // "foo.bar"
- StringUtils.split("foo.bar.baz", '.'); // { "foo", "bar", "baz" }
- StringUtils.split("foo, bar,baz", ", "); // { "foo", "bar", "baz" }
- StringUtils.leftPad("1", 3, '0'); // "001"
IOUtils and FileUtils
A must-have for the rare occasions where you need to manipulate files by hand. Both are pretty much alike (FileUtils for File, IOUtils for InputStream and Reader classes) and come bundled in commons-io.
- File file1;
- File file2;
- InputStream inputStream;
- OutputStream outputStream;
- // copy one file into another
- FileUtils.copyFile(file1, file2);
- IOUtils.copy(inputStream, outputStream);
- // read a file into a String
- String s1 = FileUtils.readFileToString(file1);
- String s2 = IOUtils.toString(inputStream);
- // read a file into a list of Strings, one item per line
- List<String> l1 = FileUtils.readLines(file1);
- List<String> l2 = IOUtils.readLines(inputStream);
- // put this in your finally() clause after manipulating streams
- IOUtils.closeQuietly(inputStream);
- // return the list of xml and text files in the specified folder and any subfolders
- Collection<File> c1 = FileUtils.listFiles(file1, { "xml", "txt" }, true);
- // copy one folder and its contents into another
- FileUtils.copyDirectoryToDirectory(file1, file2);
- // delete one folder and its contents
- FileUtils.deleteDirectory(file1);
ETC
Google collections
This is the best implementation of a collections extension that I know of. Some of these are shouting to be included in the JDK:
- // create an ArrayList with three arguments
- List<String> list = Lists.newArrayList("foo", "bar", "baz");
- // notice that there is no generics or class cast,
- // and still this line does not generate a warning.
- Set<String> s = Sets.newConcurrentHashSet();
- // intersect and union are basic features of a Set, if you ask me
- Set<String> s = Sets.intersect(s1, s2);
- // Example of multiple values in a Map
- ListMultimap<String, Validator> validators = new ArrayListMultimap<String, Validator>();
- validators.put("save", new RequiredValidator());
- validators.put("save", new StringValidator());
- validators.put("delete", new NumberValidator());
- validators.get("save"); // { RequiredValidator, StringValidator }
- validators.get("foo"); // empty List (not null)
- validators.values(); // { RequiredValidator, StringValidator, NumberValidator }
相关推荐
[工具类] 获得汉字拼音首字母的java工具类.java.txt [工具类] 获取绝对路径 .java.txt [工具类] 记录log日志文件的工具类 .java.txt [工具类] 连接数据库的工具类 .java.txt [工具类] 使用Java程序来实现HTTP文件的...
使用java工具类可有效的提高开发效率! 没有CSDN积分的朋友到这里源头下载:http://www.javacs.cn/bbs/thread-382-1-1.html 感谢支持 [工具类] CookieCounter .java.txt [工具类] 验证码img .jsp.txt [工具类] Java中...
1、java工具类RabbitmqUtil是本人封装好的直接使用 2、常用的方法都在里面 3、改一下初始化配置参数就行
java工具类合集,开源框架。
java工具类java工具类java工具类java工具类java工具类java工具类java工具类java工具类java工具类
java工具类
项目中各种常用的JAVA工具类 比如FileUtils DateUtils 等等,封装得很完美
1.[工具类] 读取、打印输出、保存xml .java 2.[工具类] Java中计算任意两个日期之间的工作天数 .java 3.[工具类] MD5 .java 4.[工具类] 时间工具TimeUtil.java 5.[工具类] 通信服务端simpleServer 6.[工具类] 使用...
功能比较全面的java工具类。包括数据库方面的,日期格式方面的,文件操作的,网络操作,String工具类以及常用类。
数据库池工具类 MD5加密工具类 文件上传工具类 UUID工具类 Mail工具类 Cookie工具类
JNA(Java Native Access )提供一组Java工具类用于在运行期动态访问系统本地库(native library:如Window的dll)而不需要编写任何Native/JNI代码。开发人员只要在一个java接口中描述目标native library的函数与...
这是本人在公司培训时做的一个PPT文档,介绍了Java常用的工具类
java抓取网页java工具类java抓取网页java工具类
java 工具类 lang3 jar包 StringUtils ArrayUtils SystemUtils
使用springboot集成了elasticsearch,封装了常用api,并使用自定义注解创建mapping,简化开发,开箱即用。注:使用的是elasticsearch 5.x版本
提供了很丰富的java工具类,包括字符串、数字、日期、文件、图像、编码解码、校验工具、文档操作等。 主要分为以下几种: - 1.通用操作类,例如String、数字、日期、各种校验等 - 2.文档操作,excel、pdf等 - 3.加密...
java工具类 1、Oracle8/8i/9i数据库(thin模式) 2、DB2数据库 3、SQL Server7.0/2000数据库 4、Sybase数据库 5、Informix数据库 6、MySQL数据库 7、PostgreSQL数据库 8、access数据库直连用ODBC的