当我运行此代码时java不响应java结果:-805306369。
此代码尝试使用junrar取消rar文件。 什么是java结果:-805306369?
是低内存的错误吗?
我该如何解决?
感谢。
String filename = importFile.getAbsolutePath();
File f = new File(filename);
Archive a = null;
try {
a = new Archive(f);
} catch (RarException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (a != null) {
FileHeader fh = a.nextFileHeader();
while (fh != null) {
try {
if(fh.getFileNameString().endsWith(".jml")){
Path tempJml=Files.createTempFile("jml",".jml");
FileOutputStream outJml=new FileOutputStream(tempJml.toFile());
InputStream in=a.getInputStream(fh);
int lenj;
while ((lenj = in.read(buffer))>0 ) {
outJml.write(buffer, 0, lenj);
}
outJml.close();
in.close();
ZipFile zpjml=new ZipFile(tempJml.toFile());
zpjml.stream().forEach((jmlEntry)->{
System.out.println(jmlEntry.getName());
if(jmlEntry.getName().endsWith(".xml")){
try {
InputStream x = null;
try {
x = zpjml.getInputStream(jmlEntry);
} catch (IOException ex) {
Logger.getLogger(ConvertController.class.getName()).log(Level.SEVERE, null, ex);
}
List<Card> xml = convertXml(x);
if(xml!=null){
xmlPat = createNewXml(xml,jmlEntry.getName());
}
ZipEntry newZe=new ZipEntry(jmlEntry.getName().substring(0,jmlEntry.getName().lastIndexOf("."))+".xml");
zos.putNextEntry(newZe);
InputStream inXml=new FileInputStream(xmlPat);
int len;
while ((len = inXml.read(buffer))>0 ) {
zos.write(buffer, 0, len);
}
zos.closeEntry();
inXml.close();
x.close();
Path temp=Paths.get(xmlPat);
Files.deleteIfExists(temp);
} catch (DocumentException ex) {
Logger.getLogger(ConvertController.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ConvertController.class.getName()).log(Level.SEVERE, null, ex);
}
}else if(jmlEntry.getName().startsWith("images")){
try (InputStream inImag = zpjml.getInputStream(jmlEntry)) {
ZipEntry newZe=new ZipEntry(jmlEntry.getName());
zos.putNextEntry(newZe);
int len;
while ((len = inImag.read(buffer)) > 0) {
zos.write(buffer, 0, len);
}
zos.closeEntry();
inImag.close();
} catch (IOException ex) {
Logger.getLogger(ConvertController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
else if(fh.getFileNameString().endsWith(".xml")){
InputStream in=a.getInputStream(fh);
List<Card> xml = convertXml(in);
if(xml!=null){
xmlPath = createNewXml(xml,fh.getFileNameString());
}
ZipEntry newZe=new ZipEntry(fh.getFileNameString().substring(0,fh.getFileNameString().lastIndexOf("."))+".xml");
zos.putNextEntry(newZe);
InputStream inXml = new FileInputStream(xmlPath);
int len;
while ((len = inXml.read(buffer))>0 ) {
zos.write(buffer, 0, len);
}
in.close();
zos.closeEntry();
inXml.close();
}
else if(fh.getFileNameString().startsWith("images")){
ZipEntry newZe=new ZipEntry(fh.getFileNameString());
zos.putNextEntry(newZe);
InputStream inFile=a.getInputStream(fh);
int len;
while ((len = inFile.read(buffer))>0 ) {
zos.write(buffer, 0, len);
}
inFile.close();
zos.closeEntry();
}else{
continue;
}
}catch(RarException | IOException e){
e.printStackTrace();
}
fh = a.nextFileHeader();
}
}
zos.close();