0
The Following Code is throwing the above warning:
警告:無法從javaldx讀取路徑錯誤:警告:無法從javaldx讀取路徑
if((JButton)e.getSource()==helpButton)
{
System.out.println("-------------Help Button is pressed..----------------------");
URL helpDocument=NewCellTrenderGUILauncher.class.getClass().getResource("/G1-G2Help.doc");
System.out.println("URL Constructed-->"+helpDocument.toString());
File helpDocPath=null;
try
{
System.out.println("URI constructed from URL="+helpDocument.toURI());
helpDocPath = new File(helpDocument.toURI());
System.out.println("File Path Constructed from URI="+helpDocPath.toString());
} catch (URISyntaxException e2)
{
// TODO Auto-generated catch block
System.err.println("\n\t***********************EXCEPTION*****************");
System.err.println("\tDue to--->"+e2);
System.err.println("\tExceptionType--->"+e2.getMessage());
e2.printStackTrace();
System.err.println("\t**************************************************");
}
if(Desktop.isDesktopSupported())
{
System.out.println("DesktopSupported is TRUE..!!");
try
{
Desktop.getDesktop().open(helpDocPath);
System.out.println("FileOpened From Desktop..!!");
} catch (IOException e1)
{
// TODO Auto-generated catch block
System.err.println("\n\t***********************EXCEPTION*****************");
System.err.println("\tDue to--->"+e1);
System.err.println("\tExceptionType--->"+e1.getMessage());
e1.printStackTrace();
System.err.println("\t**************************************************");
FileRenderer.openFile(helpDocPath.toString());
System.out.println("File opened from FileReneder..!!");
}
}
else
{
System.out.println("Desptop is Not Supported..!!!");
FileRenderer.openFile(helpDocPath.toString());
System.out.println("File opened from FileReneder..!!");
}
}
上面的代碼拋出的開發機器上的警告,但它創造了正確的路徑和最終會正確打開文件。但是,對於平臺操作系統爲Windows的生產環境,它會在以下行中引發空指針異常--->
URL helpDocument = NewCellTrenderGUILauncher.class.getClass()。getResource(「/ G1- G2Help.doc「);
請幫忙糾正錯誤..