2022年1月

今天在解析一个5M的文本文件时,耗时两分多钟,找了半天才发现原因是使用String += s的方式拼接字符串导致的。
123-1.png

换成StringBuilder后速度提升了4个数量级!123-2.png

至于原因,大家应该都懂,我就不再赘述了。
基础不能忘!!!
基础不能忘!!!
基础不能忘!!!

原文:what-is-a-good-java-library-to-zip-unzip-files

Demo:@user2003470

import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.core.ZipFile;


public static void unzip(){
    String source = "some/compressed/file.zip";
    String destination = "some/destination/folder";
    String password = "password";

    try {
         ZipFile zipFile = new ZipFile(source);
         if (zipFile.isEncrypted()) {
            zipFile.setPassword(password);
         }
         zipFile.extractAll(destination);
    } catch (ZipException e) {
        e.printStackTrace();
    }
}

The Maven dependency is:

<dependency>
    <groupId>net.lingala.zip4j</groupId>
    <artifactId>zip4j</artifactId>
    <version>1.3.2</version>
</dependency>

转发:https://superuser.com/questions/1431826/expose-api-over-tcp-of-snap-installed-docker-on-ubuntu-18-04

@Rumdex

By running: systemctl status snap.docker.dockerd.service I was able
to see which was the loaded service file:
/etc/systemd/system/snap.docker.dockerd.service Just looked inside
this file looking for the ExecStart directive. It was there. So just
had to add -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock to
that line, so it ended up looking like:
ExecStart=/usr/bin/snap run docker.dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
Rebooted. Works.