123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package com.hssx.pcbms.util;
- import org.springframework.util.DigestUtils;
- import java.io.*;
- import java.text.ParseException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.zip.ZipEntry;
- import java.util.zip.ZipOutputStream;
- /**
- * Author: 吴涛涛 cuiyi@itany.com
- * Date : 2019 - 07 - 25 16:56
- * Description:<描述>MD5加密工具
- * Version: 1.0
- */
- public class MD5Util {
- public static String getPassword(String password) {
- return DigestUtils.md5DigestAsHex(password.getBytes());
- }
- public static void main(String[] args) throws ParseException {
- }
- // public void zipDemo() {
- // //需要压缩的文件--包括文件地址和文件名
- // String[] path = {"D:\\666.jpg", "D:\\777.jpg"};
- // // 要生成的压缩文件地址和文件名称
- // String desPath = "D:\\new.zip";
- // File zipFile = new File(desPath);
- // ZipOutputStream zipStream = null;
- // FileInputStream zipSource = null;
- // BufferedInputStream bufferStream = null;
- // try {
- // //构造最终压缩包的输出流
- // zipStream = new ZipOutputStream(new FileOutputStream(zipFile));
- // for (int i = 0; i < path.length; i++) {
- // File file = new File(path[i]);
- // //将需要压缩的文件格式化为输入流
- // zipSource = new FileInputStream(file);
- // //压缩条目不是具体独立的文件,而是压缩包文件列表中的列表项,称为条目,就像索引一样
- // ZipEntry zipEntry = new ZipEntry(i + "2222.jpg");//"2222.jpg"是添加到压缩包里的源文件的名字加i是防止名字相同出错
- // //定位该压缩条目位置,开始写入文件到压缩包中
- // zipStream.putNextEntry(zipEntry);
- // //输入缓冲流
- // bufferStream = new BufferedInputStream(zipSource, 1024 * 10);
- // int read = 0;
- // //创建读写缓冲区
- // byte[] buf = new byte[1024 * 10];
- // while ((read = bufferStream.read(buf, 0, 1024 * 10)) != -1) {
- // zipStream.write(buf, 0, read);
- // }
- // }
- //
- // } catch (Exception e) {
- // e.printStackTrace();
- // } finally {
- // //关闭流
- // try {
- // if (null != bufferStream) bufferStream.close();
- // if (null != zipStream) zipStream.close();
- // if (null != zipSource) zipSource.close();
- // } catch (IOException e) {
- // e.printStackTrace();
- // }
- // }
- // }
- //
- // public static void zip4jDemo(){
- //// 生成的压缩文件
- // ZipFile zipFile = null;
- // try {
- // zipFile = new ZipFile("D:\\aa.zip");
- //
- // ZipParameters parameters = new ZipParameters();
- // // 压缩方式
- // parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
- // // 压缩级别
- // parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
- // // 要打包的文件夹
- // File currentFile = new File("D:\\666");
- // File[] fs = currentFile.listFiles();
- // // 遍历test文件夹下所有的文件、文件夹
- // for (File f : fs) {
- // if (f.isDirectory()) {
- // zipFile.addFolder(f.getPath(), parameters);
- // } else {
- // zipFile.addFile(f, parameters);
- // }
- // }
- // zipFile.addFolder("D:\\666", parameters);
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // }
- }
|