PRELOADER

当前文章 : 《压缩包解压》

5/5/2019 —— 

最近迷上的一首歌的歌词

  • 一张褪色的照片
  • 好像带给我一点点怀念
  • 巷尾老爷爷买的热汤面
  • 味道弥漫过旧旧的后园
  • 流浪猫睡熟在摇晃秋千
  • 夕阳照了一遍他眯着眼
  • 那张同桌寄的明信片
  • 安静的躺在课桌的里面
  • 快要过完的春天
  • 还有雕刻着图案的门帘
  • 窄窄的长长的过道两边
  • 老房子依然升起了炊烟
  • 刚刚下完了小雨的季节
  • 爸妈又一起走过的老街
  • 记不得哪年的哪一天
  • 很漫长又很短暂的岁月
  • 现在已经回不去
  • 早已流逝的光阴
  • 手里的那一张渐渐模糊不清的车票
  • 成了回忆的信号
  • 忘不掉的是什么我也不知道
  • 想不起当年模样
  • 看也看不到去也去不了的地方
  • 也许那老街的腔调是属于我的忧伤
  • 嘴角那点微笑越来越勉强
  • 忘不掉的是什么我也不知道
  • 放不下熟悉片段
  • 回头望一眼已经很多年的时间
  • 透过手指间看着天
  • 我又回到那老街
  • 靠在你们身边渐行渐远
  • 快要过完的春天
  • 还有雕刻着图案的门帘
  • 窄窄的长长的过道两边
  • 老房子依然升起了炊烟
  • 刚刚下完小雨的季节
  • 爸妈又一起走过的老街
  • 记不得哪年的哪一天
  • 很漫长又很短暂的岁月
  • 现在已经回不去
  • 早已流逝的光阴
  • 手里的那一张渐渐模糊不清的车票
  • 成了回忆的信号
  • 忘不掉的是什么我也不知道
  • 想不起当年模样
  • 看也看不到去也不去了的地方
  • 也许那老街的腔调是属于我的忧伤
  • 嘴角那点微笑越来越勉强
  • 忘不掉的是什么我也不知道
  • 放不下熟悉片段
  • 回头望一眼已经很多年的时间
  • 透过手指间看着天
  • 我又回到那老街
  • 靠在你们身边渐行渐远

还是干正事吧

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Enumeration;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import com.github.junrar.Archive;
import com.github.junrar.rarfile.FileHeader;

/**
* @date: 2018年10月15日 下午5:27:32
* @说明: 解压工具类
**/
public class ZipUtil {

/***
* synchronized ,防止出现并发问题
**/
public static synchronized void unrar(String rarFileName, String extPlace) throws Exception {
unRarFile(rarFileName, extPlace);
}

public static synchronized void unzip(String zipFileName, String extPlace) throws Exception {
unZipFiles(zipFileName, extPlace);
}

/**
* 解压zip格式的压缩文件到指定位置
*
* @param zipFileName
* 压缩文件
* @param extPlace
* 解压目录
* @throws Exception
*/
public static boolean unZipFiles(String zipFileName, String extPlace) throws Exception {
System.setProperty("sun.zip.encoding", System.getProperty("sun.jnu.encoding"));
try {
(new File(extPlace)).mkdirs();
File f = new File(zipFileName);
ZipFile zipFile = new ZipFile(zipFileName, "GBK"); // 处理中文文件名乱码的问题
if ((!f.exists()) && (f.length() <= 0)) {
throw new Exception("要解压的文件不存在!");
}
String strPath, gbkPath, strtemp;
File tempFile = new File(extPlace);
strPath = tempFile.getAbsolutePath();
Enumeration<?> e = zipFile.getEntries();
while (e.hasMoreElements()) {
ZipEntry zipEnt = (ZipEntry) e.nextElement();
gbkPath = zipEnt.getName();
if (zipEnt.isDirectory()) {
strtemp = strPath + File.separator + gbkPath;
File dir = new File(strtemp);
dir.mkdirs();
continue;
} else { // 读写文件
InputStream is = zipFile.getInputStream(zipEnt);
BufferedInputStream bis = new BufferedInputStream(is);
gbkPath = zipEnt.getName();
strtemp = strPath + File.separator + gbkPath;// 建目录
String strsubdir = gbkPath;
for (int i = 0; i < strsubdir.length(); i++) {
if (strsubdir.substring(i, i + 1).equalsIgnoreCase("/")) {
String temp = strPath + File.separator + strsubdir.substring(0, i);
File subdir = new File(temp);
if (!subdir.exists())
subdir.mkdir();
}
}
FileOutputStream fos = new FileOutputStream(strtemp);
BufferedOutputStream bos = new BufferedOutputStream(fos);
int c;
while ((c = bis.read()) != -1) {
bos.write((byte) c);
}
bos.close();
fos.close();
}
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}

/**
* 根据原始rar路径,解压到指定文件夹下.
*
* @param srcRarPath
* 原始rar路径
* @param dstDirectoryPath
* 解压到的文件夹
*/
public static void unRarFile(String srcRarPath, String dstDirectoryPath) {
if (!srcRarPath.toLowerCase().endsWith(".rar")) {
System.out.println("非rar文件!");
return;
}
File dstDiretory = new File(dstDirectoryPath);
if (!dstDiretory.exists()) {// 目标目录不存在时,创建该文件夹
dstDiretory.mkdirs();
}
Archive a = null;
try {
a = new Archive(new File(srcRarPath));
if (a != null) {
// a.getMainHeader().print(); // 打印文件信息.
FileHeader fh = a.nextFileHeader();
while (fh != null) {
// 防止文件名中文乱码问题的处理
String fileName = fh.getFileNameW().isEmpty() ? fh.getFileNameString() : fh.getFileNameW();
if (fh.isDirectory()) { // 文件夹
File fol = new File(dstDirectoryPath + File.separator + fileName);
fol.mkdirs();
} else { // 文件
File out = new File(dstDirectoryPath + File.separator + fileName.trim());
try {
if (!out.exists()) {
if (!out.getParentFile().exists()) {// 相对路径可能多级,可能需要创建父目录.
out.getParentFile().mkdirs();
}
out.createNewFile();
}
FileOutputStream os = new FileOutputStream(out);
a.extractFile(fh, os);
os.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
fh = a.nextFileHeader();
}
a.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}