Java开发过程中的常用工具类库
发布日期:2021-05-08 23:11:08 浏览次数:18 分类:博客文章

本文共 5607 字,大约阅读时间需要 18 分钟。

Java开发过程中的常用工具类库

目录


当我们想要自己开发一个工具时先在网上找找有没有大厂已经帮我们实现好的工具类。毕竟重复造轮子不是什么好事~


Apache Commons类库

Apache Commons是一个非常有用的工具包,为解决各种实际的问题提供了通用现成的代码,不需要我们程序员再重复造轮子。关于这个类库的详细介绍可以访问。下面表格列出了部分的工具包。我们平时开发过程中可以根据自己的需要挑选合适的工具包。

Components Description Latest Version Released
Byte Code Engineering Library - analyze, create, and manipulate Java class files 6.3.1 2019/3/24
Easy-to-use wrappers around the Java reflection and introspection APIs. 1.9.3 2016/9/26
Bean Scripting Framework - interface to scripting languages, including JSR-223 3.1 2010/6/24
Chain of Responsibility pattern implemention. 1.2 2008/6/2
Command Line arguments parser. 1.4 2017/3/9
General encoding/decoding algorithms (for example phonetic, base64, URL). 1.12 2019/2/16
Extends or augments the Java Collections Framework. 4.3 2019/2/5
Defines an API for working with tar, zip and bzip2 files. 1.18 2018/8/16
Reading of configuration/preferences files in various formats. 2.4 2018/10/29
A cryptographic library optimized with AES-NI wrapping Openssl or JCE algorithm implementations. 1.0.0 2016/7/22
Component for reading and writing comma separated value files. 1.6 2018/9/25
Alternative invocation mechanism for unix-daemon-like java code. 1.0.15 2013/4/3
Database connection pooling services. 2.6.0 2019/2/19
JDBC helper library. 1.7 2017/7/20
XML-to-Java-object mapping utility. 3.2 2011/12/13
Library for sending e-mail from Java. 1.5 2017/8/1
API for dealing with external process execution and environment management in Java. 1.3 2014/11/6
File upload capability for your servlets and web applications. 1.4 2019/1/16
A functor is a function that can be manipulated as an object, or an object representing a single, generic function. 1 2011-??-??
Space and coordinates. 1 2018-??-??
A pure-Java image library. 0.97-incubator 2009/2/20
Collection of I/O utilities. 2.6 2017/10/15
Java Compiler Interface 1.1 2013/10/14
Java Caching System 2.2,1 2018/8/23
XML based scripting and processing engine. 1.0.1 2017/9/27
Expression language which extends the Expression Language of the JSTL. 3.1 2017/4/14
Utilities for manipulating Java Beans using the XPath syntax. 1.3 2008/8/14
Provides extra functionality for classes in java.lang. 3.9 2019/4/15
Wrapper around a variety of logging API implementations. 1.2 2014/7/11
Lightweight, self-contained mathematics and statistics components. 3.5 2015/4/17
Collection of network utilities and protocol implementations. 3.6 2017/2/15
Number types (complex, quaternion, fraction) and utilities (arrays, combinatorics). 1 2017-??-??
An Object-Graph Navigation Language 4 2013-??-??
Generic object pooling component. 2.6.2 2019/4/11
Library for creating dynamic proxies. 1 2008/2/28
Common implementation of RDF 1.1 that could be implemented by systems on the JVM. 0.3.0-incubating 2016/11/15
Implementations of random numbers generators. 1.2 2018/12/12
An implementation of the State Chart XML specification aimed at creating and maintaining a Java SCXML engine.It is capable of executing a state machine defined using a SCXML document, and abstracts out the environment interfaces. 0.9 2008/12/1
Statistics. 0.1 ????-??-??
Apache Commons Text is a library focused on algorithms working on strings. 1.6 2018/10/16
Framework to define validators and validation rules in an xml file. 1.6 2017/2/21
Virtual File System component for treating files, FTP, SMB, ZIP and such like as a single logical file system. 2.3 2019/2/4
Provides an easy way to enhance (weave) compiled bytecode. 2 2018/9/7

除了上面表格中的工具包,Apache Common项目还包括以下几个工具包,其中的http-client是我们平时非常常用的。

  • Cactus: Cactus is a simple test framework for unit testing server-side java code (Servlets, EJBs, Tag Libs, Filters, ...). The intent of Cactus is to lower the cost of writing tests for server-side code.
  • HiveMind: HiveMind is a services and configuration microkernel. HiveMind allows you to create your application using a service oriented architecture.
  • HttpClient 3.x: Framework for working with the client-side of the HTTP protocol.
  • Naming: The Naming subproject will contain common JNDI code along with various JNDI providers.

Guava类库

Guava工程包含了若干被Google的 Java项目广泛依赖 的核心库,例如:集合 [collections] 、缓存 [caching] 、原生类型支持 [primitives support] 、并发库 [concurrency libraries] 、通用注解 [common annotations] 、字符串处理 [string processing] 、I/O 等等。下面列出Guava工具包中的常用功能点,以便需要的时候查阅使用。

基本工具 [Basic utilities]

  • :null是模棱两可的,会引起令人困惑的错误,有些时候它让人很不舒服。很多Guava工具类用快速失败拒绝null值,而不是盲目地接受。
  • : 让方法中的条件检查更简单。
  • : 简化Object方法实现,如hashCode()和toString()。
  • :简化了异常和错误的传播与检查。

集合[Collections]

Guava对JDK集合的扩展,这是Guava最成熟和为人所知的部分

  • : 用不变的集合进行防御性编程和性能提升。
  • : multisets, multimaps, tables, bidirectional maps等。
  • : 提供java.util.Collections中没有的集合工具。
  • :让实现和扩展集合类变得更容易,比如创建Collection的装饰器,或实现迭代器。

[Caches]

Guava Cache:本地缓存实现,支持多种缓存过期策略。

[Functional idioms]

Guava的函数式支持可以显著简化代码,但请谨慎使用它。

并发[Concurrency]

强大而简单的抽象,让编写正确的并发代码更简单

  • :完成后触发回调的Future
  • :抽象可开启和关闭的服务,帮助你维护服务的状态逻辑

[Strings]

非常有用的字符串工具,包括分割、连接、填充等操作

[Primitives]

扩展 JDK 未提供的原生类型(如int、char)操作, 包括某些类型的无符号形式

[Ranges]

可比较类型的区间API,包括连续和离散类型

简化I/O尤其是I/O流和文件的操作,针对Java5和6版本

[Hash]

提供比Object.hashCode()更复杂的散列实现,并提供布鲁姆过滤器的实现

[EventBus]

发布-订阅模式的组件通信,但组件不需要显式地注册到其他组件中

[Math]

优化的、充分测试的数学工具类

[Reflection]

Guava 的 Java 反射机制工具类

Spring中的常用工具类

  • FileCopyUtils;
  • WebUtil;

参考下面博客:

其他工具

  • junit:单元测试工具;
  • mockito-all
  • lombok:Lombok提供了简单的注解的形式来帮助我们消除一些必须有但显得很臃肿的Java样板代码;
  • netty-all:网络应用程序框架,用于快速和方便的开发维护高性能协议服务器和客户端;
  • jsoup:jsoup 是一款 Java 的 HTML 解析器,可直接解析某个 URL 地址、HTML 文本内容。它提供了一套非常省力的 API,可通过 DOM,CSS 以及类似于 jQuery 的操作方法来取出和操作数据;
  • dom4j:处理XML的开源框架。它集成了XPath并提供全力支持DOM,JAXP和Java平台。
  • javax.script、org.apache.http.client.utils:脚本API供那些希望在其 Java 应用程序中执行用脚本语言编写的程序的应用程序编程人员使用

参考

  • 并发编程网Guava教程
  • Apache Common官网
上一篇:本机安装的 JDK8,启动 IDEA2019 没反应
下一篇:到底什么是短链接

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年03月28日 17时22分58秒