http://p13.freep.cn/p.aspx?u=v20_p1大家帮我看看,谢谢了!!!

解决方案 »

  1.   

    CSDN弄个上传图片都这么难,哎,就是说我的java类在com.Config包下,然后这个properites文件在根目录下。
     InputStream in=Config.class.getResourceAsStream("config.properties");
    pro.load(in);返回的是空指针
      

  2.   

    String filePath = Thread.currentThread().getContextClassLoader().getResource("").getPath() + "\config.properties";
     filePath = filePath.replaceAll("%20", " ");
      

  3.   

    还是用绝对路径吧
    String path = Config.class.getProtectionDomain().getCodeSource().getLocation().getPath();
    int pos = path.indexOf("com/");

    if(pos != -1){
    path=path.substring(0,pos);
    }
    这个path就是根目录了
      

  4.   

    改成这个试试
    InputStream in=Config.class.getResourceAsStream("/config.properties");
      

  5.   

    相对路径是相对于你当前路径而言的,你当前路径在config包下,而你的properties文件是在config包的上一层也就是src目录下,你当然找不到文件了
      

  6.   

    这样,你把config.properties文件放到src下即可。
      

  7.   

    这样,你把config.properties文件放到src下即可。
      

  8.   

    如果你就想放在根目录,就这样写InputStream in=Config.class.getResourceAsStream("../config.properties");
      

  9.   

    直接用ClassLoader loader = Thread.currentThread().getContextClassLoader();
    InputStream is = loader.getResourceAsStream("config.properties");
    property.load(is);
    代码会自动搜索到config.properties文件,本人测试通过