2012-08-27 4 views
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 인 경우 다음 줄에 null 포인터 예외가 발생합니다. --->

URL helpDocument = NewCellTrenderGUILauncher.class.getClass(). getResource ("/ G1- G2Help.doc "); 오류를 해결하기 위해 도와주세요

..

답변

0

같이 getResourceAsStream 쉽게 일을 할 것입니다 .. 그것을

시도