打印

Android下读资源文件报错!

Android下读资源文件报错!

程序意图:
  通过读资源文件inputway.properties
   把里面的"username"字段对应的aaa提取出来
  然后显示在Android系统的屏幕上(就像helloworld一样)

程序运行以后报错:
          componentInfo{com...Android.InputWay.Inputway}:
                java.util.MissingResourceException
   

资源文件(inputway.properties):
driver=oracle.jdbc.driver.OracleDriver   
url=jdbc: oracle:thin@192.168.0.1:1521:db   
username=aaa   
password=aaa

屏幕:
public class InputWay extends Activity {
    final String inputway = "username";
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        ReadResouce resouce = new ReadResouce();
        String in =resouce.Readresouce(inputway);
        TextView tv = new TextView(this);
        tv.setText(in);
        setContentView(R.layout.main);
    }

读取资源文件的类及方法:
public class ReadResouce {
   public String Readresouce(String inputway){
                ResourceBundle bundle = ResourceBundle.getBundle("inputway.properties");
                String inputways = bundle.getString(inputway);
           return inputways;
   }

TOP