2013-04-19 28 views
0

我再次向Java學習。不能說我記得使用ResourceBundle。我收到異常無法找到包「ExceptionMessages_en_US」,密鑰的資源。找不到捆綁'ExceptionMessages_en_US'的資源,Android中的鍵

這裏是我的了ListResourceBundle類:

(我接過例如直接從JavaDoc中,並用自己的字符串修改了它)

public class ExceptionMessages extends ListResourceBundle { 

@Override 
protected Object[][] getContents() { 
    return new Object[][] { 

      {"interfaceCount", "Device should have 1 interface."}, 
      {"epCount", "Device should have 3 endpoints."}, 
      {"noIntrIn", "Device does not have an interrupt input endpoint."}, 
      {"noBulkIn", "Device does not have a bulk input endpoint."}, 
      {"noBulkOut", "Device does not have a bulk output endpoint."}, 
      {"openFailed", "A call to deviceOpen has failed."}, 
      {"claimFailed", "A call to claimInterface has failed."}, 
      {"startSessionFailed", "Start USB Session has failed."}, 
      {"sessionNotStarted", "USB Session not started."}, 
      {"bulkTxError", "Bulk endpoint transmit error."}, 
      {"intrRxError", "Interrupt endpoint recieve error."}, 


     }; 
} 

} 

我也試過,沒有運氣命名類ExceptionMessages_en_US

我得到如下資源包:

public void Test() 
{ 
    try 
    { 
     ResourceBundle rb = ResourceBundle.getBundle("ExceptionMessages"); 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 


    } 

    int i = 0; 
    i++; 


} 

我也累了:

public void Test() 
{ 
    try 
    { 
     ResourceBundle rb = ResourceBundle.getBundle("ExceptionMessages",new Locale("en", "US")); 
    } 
    catch (Exception e) 
    { 
     e.printStackTrace(); 


    } 

    int i = 0; 
    i++; 


} 

但仍然得到例外。

我錯過了什麼?我相信這是愚蠢的。

回答

0

我需要添加包含ExceptionMessages的完整軟件包。

實施例:

 ResourceBundle rb = ResourceBundle.getBundle("com.mycomp.ExceptionMessages");