Javafx程序没有响应? [英] Javafx program is not responding?

查看:99
本文介绍了Javafx程序没有响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行此代码时java不响应java结果:-805306369。



此代码尝试使用junrar取消rar文件。什么是java结果:-805306369?



这个内存不足的错误是什么?



我该怎么办?解决它?



谢谢。



我尝试了什么: < br $>


 String filename = importFile.getAbsolutePath(); 
文件f =新文件(文件名);
存档a = null;
尝试{
a = new Archive(f);
} catch(RarException | IOException e){
// TODO自动生成的catch块
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);
}
}否则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);
列表<卡> 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();

}否则{
继续;
}
} catch(RarException | IOException e){
e.printStackTrace();
}
fh = a.nextFileHeader();
}

}

zos.close();

解决方案

< blockquote>所有那些 try-catch 块阻止Java告诉你什么是问题。它们还会阻止您查看问题所在。

建议:删除 try-catch 块并让Java告诉您发生了什么。

由于问题可能与数据有关,因此无法帮助您。

使用调试器查看代码执行情况。



有一个工具可以让你看到代码在做什么,它的名字是调试器。它也是一个很好的学习工具,因为它向你展示了现实,你可以看到哪种期望与现实相符。

当你不明白你的代码在做什么或为什么它做它做的时候,答案就是答案是调试器

使用调试器查看代码正在执行的操作。只需设置断点并查看代码执行情况,调试器允许您逐行执行第1行并在执行时检查变量。



调试器 - 维基百科,免费的百科全书 [ ^ ]

http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html [ ^ ]

https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html [ ^ ]

调试器在这里向您展示你的代码正在做,你的任务是与它应该做的事情进行比较。

调试器中没有魔法,它没有找到错误,它只是帮助你。当代码没有达到预期的效果时,你就会接近一个错误。


when i run this code java not responding with java Result: -805306369 .

this code try to unrar a rar file with junrar. what is java Result: -805306369 ?

is this error for low memory?

how can i solve it?

thanks.

What I have tried:

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();

解决方案

All those try-catch blocks prevent Java from telling you what is the problem. They also prevent you from seeing where is the problem.
Advice: remove the try-catch blocks and let Java tell you what is going on.
Since the problem is probably data dependent, it is impossible to help you.
Use the debugger to see your code perform.

There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html[^]
https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.


这篇关于Javafx程序没有响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆