<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<% String commandstr = "D:/WinRAR/Rar.exe x -t -o+ -p- C:/Users/guoshuai/workspace/LOGDEV/WebContent/LOG/Image/imageshow.rar C:/Users/guoshuai/workspace/LOGDEV/WebContent/LOG/Image/showrar/";
Process p ;
try {
p = Runtime.getRuntime().exec(commandstr);
while (true){
if(p.waitFor() == 0) break;
}
}
catch (Exception e) {}
%>
</body>
</html>rar里面有5个图片,结果最多只能解压缩出一两个文件,之后rar.exe进程常驻,开始报错。
javaw.exe cpu占用97%
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<% String commandstr = "D:/WinRAR/Rar.exe x -t -o+ -p- C:/Users/guoshuai/workspace/LOGDEV/WebContent/LOG/Image/imageshow.rar C:/Users/guoshuai/workspace/LOGDEV/WebContent/LOG/Image/showrar/";
Process p ;
try {
p = Runtime.getRuntime().exec(commandstr);
while (true){
if(p.waitFor() == 0) break;
}
}
catch (Exception e) {}
%>
</body>
</html>rar里面有5个图片,结果最多只能解压缩出一两个文件,之后rar.exe进程常驻,开始报错。
javaw.exe cpu占用97%
try {
// ZipInputStream zis = new ZipInputStream(new FileInputStream(
// "Archive.zip"));
ZipInputStream zis = new ZipInputStream(new FileInputStream("e.zip"));
// ZipFile z=new ZipFile(Archive.zip);
ZipEntry ze = null; while ((ze=zis.getNextEntry()) != null) { if (!ze.isDirectory()) {
System.out.println(ze.getName());
// File child = new File(ze.getName());
String filename=ze.getName();
int at=filename.lastIndexOf("/");
System.out.println(at);
if(at!=-1)
{
String path=filename.substring(0, at);
File pa=new File(path);
pa.mkdirs();
FileOutputStream outputStream = new FileOutputStream(pa+filename.substring(at));
byte[] buffer = new byte[1024];
int bytesRead = 0; while ((bytesRead = zis.read(buffer)) > 0) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
outputStream.close();
}else
{
FileOutputStream outputStream = new FileOutputStream(filename);
byte[] buffer = new byte[1024];
int bytesRead = 0; while ((bytesRead = zis.read(buffer)) > 0) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.flush();
outputStream.close();
}
}
}
zis.close();
} catch (Exception e) {
e.printStackTrace();
}