配置文件:
package api;import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;public class api
{ .... ....        Properties p = new Properties();
        try
        {
            FileInputStream propfile = new FileInputStream("config.ini");
            p.load(propfile);
            IcpId_cfg = p.getProperty("Id", "");
            IcpShareKey_cfg = p.getProperty("ShareKey", "");
        }
        catch(Exception ex)
        {
            err.SetErrorCodeString("读配置失败!");
            return 1;
        }
    }}

解决方案 »

  1.   

    package api;import java.io.*;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Properties;public class api
    { .... ....        Properties p = new Properties();
            try
            {
                InputStream propfile = this.getClass().getResourceAsStream( "/config.ini" );
                p.load(propfile);
                IcpId_cfg = p.getProperty("Id", "");
                IcpShareKey_cfg = p.getProperty("ShareKey", "");
            }
            catch(Exception ex)
            {
                err.SetErrorCodeString("读配置失败!");
                return 1;
            }
        }}
      

  2.   

    如果不改动源文件,能不能通过改变config.ini的位置来解决这个问题呢?
      

  3.   

    将它放在C:\tomcat4.1\bin中试试
      

  4.   

    多谢shenlang(沈浪) ,佩服。
    交个朋友吧
    online:84624889