java解压rar文件出错public void unRarFile(String rarFileName,String extPlace)
{
Archive archive = null;
File out = null;
File file = null;
File dir = null;
FileOutputStream os = null;
FileHeader fh = null;
String path, dirPath = "";
try
{
file = new File(rarFileName);
System.out.println("file.getName = "+file.getName());
archive = new Archive(file);
}
catch (RarException e1)
{
e1.printStackTrace();
}
catch (IOException e1)
{
e1.printStackTrace();
}
finally
{
if (file != null)
{
file = null;
}
}
if (archive != null)
{
try
{
fh = archive.nextFileHeader();
while (fh != null)
{
path = (extPlace + fh.getFileNameString().trim()).replaceAll("\\\\", "/");
int end = path.lastIndexOf("/");
if (end != -1)
{
dirPath = path.substring(0, end);
}
try
{
dir = new File(dirPath);
if (!dir.exists())
{
dir.mkdirs();
}
}
catch (RuntimeException e1)
{
e1.printStackTrace();
}
finally
{
if (dir != null)
{
dir = null;
}
}
if (fh.isDirectory())
{
fh = archive.nextFileHeader();
continue;
}
out = new File(extPlace + fh.getFileNameString().trim());
try
{
os = new FileOutputStream(out);
archive.extractFile(fh, os);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (RarException e)
{
e.printStackTrace();
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
if (out != null)
{
out = null;
}
}
fh = archive.nextFileHeader();
}
}
catch (RuntimeException e)
{
e.printStackTrace();
}
finally
{
fh = null;
if (archive != null)
{
try
{
archive.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
}
} 错误如下2010-6-16 15:13:56 de.innosystec.unrar.Archive setFile
警告: exception in archive constructor maybe file is encrypted or currupt
java.lang.NullPointerException
at de.innosystec.unrar.Archive.readHeaders(Archive.java:233)
at de.innosystec.unrar.Archive.setFile(Archive.java:122)
at de.innosystec.unrar.Archive.<init>(Archive.java:106)
at de.innosystec.unrar.Archive.<init>(Archive.java:96)
at ZipManager.unRarFile(ZipManager.java:371)
at ZipManager.main(ZipManager.java:490)
调试的时候出现下面这个是什么
[code=Java][
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6da669a2, pid=1752, tid=3944
#
# Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)
# Problematic frame:
# V [jvm.dll+0x1b69a2]
#
# An error report file with more information is saved as:
# E:\exercise\zip\hs_err_pid1752.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
/code]
先前在别的地方用都好的 不知道什么原因 大侠请帮忙啊
{
Archive archive = null;
File out = null;
File file = null;
File dir = null;
FileOutputStream os = null;
FileHeader fh = null;
String path, dirPath = "";
try
{
file = new File(rarFileName);
System.out.println("file.getName = "+file.getName());
archive = new Archive(file);
}
catch (RarException e1)
{
e1.printStackTrace();
}
catch (IOException e1)
{
e1.printStackTrace();
}
finally
{
if (file != null)
{
file = null;
}
}
if (archive != null)
{
try
{
fh = archive.nextFileHeader();
while (fh != null)
{
path = (extPlace + fh.getFileNameString().trim()).replaceAll("\\\\", "/");
int end = path.lastIndexOf("/");
if (end != -1)
{
dirPath = path.substring(0, end);
}
try
{
dir = new File(dirPath);
if (!dir.exists())
{
dir.mkdirs();
}
}
catch (RuntimeException e1)
{
e1.printStackTrace();
}
finally
{
if (dir != null)
{
dir = null;
}
}
if (fh.isDirectory())
{
fh = archive.nextFileHeader();
continue;
}
out = new File(extPlace + fh.getFileNameString().trim());
try
{
os = new FileOutputStream(out);
archive.extractFile(fh, os);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (RarException e)
{
e.printStackTrace();
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
if (out != null)
{
out = null;
}
}
fh = archive.nextFileHeader();
}
}
catch (RuntimeException e)
{
e.printStackTrace();
}
finally
{
fh = null;
if (archive != null)
{
try
{
archive.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
}
} 错误如下2010-6-16 15:13:56 de.innosystec.unrar.Archive setFile
警告: exception in archive constructor maybe file is encrypted or currupt
java.lang.NullPointerException
at de.innosystec.unrar.Archive.readHeaders(Archive.java:233)
at de.innosystec.unrar.Archive.setFile(Archive.java:122)
at de.innosystec.unrar.Archive.<init>(Archive.java:106)
at de.innosystec.unrar.Archive.<init>(Archive.java:96)
at ZipManager.unRarFile(ZipManager.java:371)
at ZipManager.main(ZipManager.java:490)
调试的时候出现下面这个是什么
[code=Java][
#
# An unexpected error has been detected by Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6da669a2, pid=1752, tid=3944
#
# Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)
# Problematic frame:
# V [jvm.dll+0x1b69a2]
#
# An error report file with more information is saved as:
# E:\exercise\zip\hs_err_pid1752.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
/code]
先前在别的地方用都好的 不知道什么原因 大侠请帮忙啊
解决方案 »
- 访问首页,要求地址栏里不变化
- 求J精通AVA热心者带我做课程设计
- Hibernate
- ibatis动态查询
- Struct关于FORMBEAN没赋值请高手指点
- action实现ServletRequestAware接口导致java.lang.NoSuchMethodException
- 请问如在一行文字 ?中获的想要字符串????????
- Eclipse+Lomboz+tomcat 配置问题..请帮帮我
- 新手50分问一些办公室系统的入门问题(TOMCAT5.0+SQL SERVER 2000+JDK 1.4.2)
- 如何在JBuiulder中实现一个菜单的功能
- 这个进度条怎么做
- JDBC连接sqlserver2005报错
at ZipManager.unRarFile(ZipManager.java:371)archive = new Archive(file); //这行
E:\exercise\zip\hs_err_pid1752.log
在这个地方可以看到错误日志么,你先去查查看啊~
Java VM: Java HotSpot(TM) Client VM (11.3-b02 mixed mode windows-x86)
貌似是平台有问题~