static File dir=new File("file:/opt");这句话有问题,改一改就可以得出正确结果。
给他加上个正确的路径,比如c:/或者别的路径

解决方案 »

  1.   

    String fileList[]=dir.list(filter);引用为空~~~~
      

  2.   

    我可是在linux下,那么路径应该怎么设置呢?
      

  3.   

    static File dir=new File(".");
      

  4.   

    那就用LINUX下的相对路径来解决,设置为当前路径下测试
      

  5.   

    感谢楼上各位的积极指导!如果用"."号,确实可以获得当前目录下的所有指定扩展名的文件,但程序应该不局限于此.说到底是一个linux下的文件路径如何表示的问题.   "file:/root/"用来表示根目录,错在哪里呢?
      

  6.   

    感谢楼上各位的积极指导!如果用"."号,确实可以获得当前目录下的所有指定扩展名的文件,但程序应该不局限于此.说到底是一个linux下的文件路径如何表示的问题.   "file:/root/"用来表示根目录,错在哪里呢?
      

  7.   

    感谢楼上各位的积极指导!如果用"."号,确实可以获得当前目录下的所有指定扩展名的文件,但程序应该不局限于此.说到底是一个linux下的文件路径如何表示的问题.   "file:/root/"用来表示根目录,错在哪里呢?
      

  8.   

    The prefix concept is used to handle root directories on UNIX platforms, and drive specifiers, root directories and UNC pathnames on Microsoft Windows platforms, as follows: For UNIX platforms, the prefix of an absolute pathname is always "/". Relative pathnames have no prefix. The abstract pathname denoting the root directory has the prefix "/" and an empty name sequence. 
    For Microsoft Windows platforms, the prefix of a pathname that contains a drive specifier consists of the drive letter followed by ":" and possibly followed by "\" if the pathname is absolute. The prefix of a UNC pathname is "\\"; the hostname and the share name are the first two names in the name sequence. A relative pathname that does not specify a drive has no prefix. 
    Instances of the File class are immutable; that is, once created, the abstract pathname represented by a File object will never change. 
      

  9.   

    for more detail, read this page
    http://java.sun.com/j2se/1.4.1/docs/api/java/net/URI.html
      

  10.   

    问题解决了,真是一只菜鸟。
    yefc(yefc)说得好,将"file:/root/" 改成"/root"就行了。