• 编写java程序压缩Linux本地目录


    注:图片如果损坏,点击文章链接:https://www.toutiao.com/i6809285459722633736/

    创建工程

    java压缩打包本地目录然后编写脚本执行

     

    使用maven工程

    java压缩打包本地目录然后编写脚本执行

     

    勾选,然后下一步

    java压缩打包本地目录然后编写脚本执行

     

    填写基本信息

    java压缩打包本地目录然后编写脚本执行

     

    注意改一下编码和JDK

    java压缩打包本地目录然后编写脚本执行

     

    pom配置(附在文档后面)

    java压缩打包本地目录然后编写脚本执行

     

    引入jar(这个包一直不能下载,所以另外导入)

    java压缩打包本地目录然后编写脚本执行

     

    创建运行类

    java压缩打包本地目录然后编写脚本执行

     

    编写代码

    java压缩打包本地目录然后编写脚本执行

     

    java压缩打包本地目录然后编写脚本执行

     

    继续编写

    java压缩打包本地目录然后编写脚本执行

     

    java压缩打包本地目录然后编写脚本执行

     

    主方法测试下,先在windows上测试完成后,再放到linux上执行看下,本地测试就不测试了,直接打包

    java压缩打包本地目录然后编写脚本执行

     

    打包,执行install

    java压缩打包本地目录然后编写脚本执行

     

    因为我们引入了别的包,所以我们的包会比别的包大一些,不要弄错了

    java压缩打包本地目录然后编写脚本执行

     

    就是这个包

    java压缩打包本地目录然后编写脚本执行

     

    拷贝pom时候,注意更改自己的主类

    java压缩打包本地目录然后编写脚本执行

     

    改名字上传

    java压缩打包本地目录然后编写脚本执行

     

    然后执行打包语句

    java -jar zipexe.jar /usr/local/pimages /data/1.tar.gz

    java压缩打包本地目录然后编写脚本执行

     

    编写一个脚本,方便下次执行

    java压缩打包本地目录然后编写脚本执行

     

    执行结果

    java压缩打包本地目录然后编写脚本执行

     

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.xlgl.wzy</groupId>
    <artifactId>mail</artifactId>
    <version>0.0.1-SNAPSHOT</version>
     
    <dependencies>
     
    <dependency> 
    <groupId>commonsIO</groupId>   <!--自定义-->
    <artifactId>commonsIO</artifactId>  <!--自定义-->
    <version>2.5.0</version>   <!--自定义-->
    <scope>system</scope>  <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
    <systemPath>${pom.basedir}/jar/commonsIO-2.5.0.jar</systemPath>  <!--项目根目录下的lib文件夹下-->
    </dependency>
     
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.10</version>
    </dependency>
     
    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.8</version>
    </dependency>
     
     
    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-compress</artifactId>
    <version>1.5</version>
    </dependency>
     
    <!--邮件发送-->
    <dependency>
    <groupId>javax.mail</groupId>
    <artifactId>mail</artifactId>
    <version>1.4.7</version>
    </dependency>
    </dependencies>
     
    <build>
    <plugins>
    <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
    <descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
    <archive>
    <manifest>
    <mainClass>com.xlgl.wzy.zip.ZipExecute</mainClass>
    </manifest>
    </archive>
    </configuration>
    <executions>
    <execution>
    <id>make-assembly</id>
    <phase>package</phase>
    <goals>
    <goal>single</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
    </project>
     
     

     
  • 相关阅读:
    微信小程序非域名测试环境,手机预览不正常,模拟器和真机调试正常解决办法
    vue 建项目及初步开发遇到的问题
    开发&测试
    架构&项目
    运维
    读书&源码
    ArrayList
    jdk集合知识点整理
    jdk集合关系图
    jvm知识点整理
  • 原文地址:https://www.cnblogs.com/bqwzy/p/12590352.html
Copyright © 2020-2023  润新知