to foryouever(光速兔子) :
这个文件我有读的权限,没有写的权限可以吗。to zkhj(zkhj) :
内码不同?能不能讲的详细些?谢谢

解决方案 »

  1.   

    读取.properties文件,可以使用ResourceBundle类。一下代码是读取一个名为info.properties中的TEST属性。import java.util.ResourceBundle;public class EnvPara
    {
      private static ResourceBundle resources = null;
      public static void init()
      {
        if(resources == null)
        {
          resources = ResourceBundle.getBundle("info");
        }
      }
      public static String getString(String sName)
      {
        String sResult = null;
        try
        {
          init();
          sResult = resources.getString(sName);
          if(sResult != null)
          {
            sResult = new String(sResult.getBytes("ISO8859_1"),"GBK");
          }
        }
        catch(Exception e)
        {
          sResult = null;
        }
        return sResult;
      }
      public static void main(String[] args)
      {
        System.out.println("test:"+EnvPara.getString("TEST"));
      }
    }
      

  2.   

    to alphafish(alphafish) :
      我基本就是这样写的啊。
      

  3.   

    to helloqiner(小勤) :
      请注意你放置properties的路径。你好像用的是resin,请放在WEB-INF/classes目录下。并且注意一下文件名的大小写不要写错。