Java
武凯凯
纵深入尘埃里,雷雨大作我也放声而歌
展开
-
Java 文件压缩与解压
/** * 压缩文件 * * @param zipPath 文件压缩后生成的文件路径 * @param files 需要压缩的文件 */ public static void compressionFile(String zipPath, File[] files) throws IOException { ZipOutputStream zipOutputStream = new ZipOutputStream(new...原创 2020-09-18 10:32:13 · 85 阅读 · 0 评论 -
Java 快速排序
/** * @author wkk * @date 2020/1/9 11:09 */ public class MyTestQuickSort { public static void main(String[] args) { int[] arr = {213, 499, 1, 53, 56, 3, 4, 89, 0, 388, 45, 34}; ...原创 2020-01-14 20:29:14 · 190 阅读 · 0 评论 -
Java 线程池
文章目录ThreadPoolExecutor执行规则线程回收任务队列拒绝策略Executors 提供的几种默认线程池自动增长线程池定长线程池任务调度线程池串行线程池串行的任务调度线程池工作窃取线程池 ThreadPoolExecutor ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( ...原创 2019-11-02 11:12:32 · 110 阅读 · 0 评论 -
Java 有关自动装箱的一个有趣的小东西
这个是 《深入理解Java虚拟机》书中的一个例子,思考下下面的这段代码运行的结果是什么? public static void main(String[] args) { Integer a = 1; Integer b = 1; Integer c = 3; Integer d = 3; Integer e ...原创 2019-10-25 19:56:05 · 112 阅读 · 0 评论 -
自己手动实现远程执行功能
在阅读《深入理解Java虚拟机》第二版,一书中。第九章看到的demo。 这个小东西实现的功能,就是让服务器可以在运行时期动态的执行代码,打印日志等, 而不需要修改服务器代码,重启服务器。一开始以为是比较高深的东西,但是实际上,确实不算很难。 书中提供了 5 个类用于动态执行代码。使用了一个 JSP 文件来作为触发执行操作的入口,并且获取程序的执行结果。需要说明的是这5个类以及这个 jsp 文件都是...原创 2019-10-25 19:54:20 · 447 阅读 · 0 评论 -
String 类型 IP 与 int 类型互转
之前无意中看到的一个阿里的面试题,然后就花了点时间去解决。原理就是利用int类型占用四个字节32位来存放ip地址的四段8位二进制数。 public class IpTest { public static void main(String[] args) { String ip = "192.168.23.106"; int intIp = stringI...原创 2019-09-06 12:18:06 · 367 阅读 · 0 评论 -
获取指定长度的英文数字字符串
public static String getRandomString(int length) { StringBuilder stringBuilder = new StringBuilder(); Random random = new Random(); for (int i = 0; i < length; i++) { ...原创 2019-09-16 14:16:01 · 137 阅读 · 0 评论