我翻遍我手边的一本java书和一本jsp书了
都没有对file遍历目录的描述
能否详细点啊
我加送80分啊

解决方案 »

  1.   

    相关方法: 
    String[] list() 
              Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname. 
     String[] list(FilenameFilter filter) 
              Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. 
     File[] listFiles() 
              Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname. 
     File[] listFiles(FileFilter filter) 
              Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. 
     File[] listFiles(FilenameFilter filter) 
              Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter. 
      

  2.   

    你用的是JBUILDER吗?可以直接浏览FILE这个类啊,或者JDK DOC文档
      

  3.   

    海风老大
    虽然我看不太懂
    但是分送你吧
    jbuilder我有的~~~~~~~~
      

  4.   

    File dir = new File("\path");
    string [] filename = dir.list();
    就可以了!
      

  5.   

    倒~~~`又错了,listFiles()返回的是File对象。就用list()吧。如果不许要子目录名字可以判断一下。
      

  6.   

    后面这个我看的懂~
    呵呵
    那得到的string [] filename
    如何逐个得到文件名的值?
      

  7.   

    你会访问数组吗?循环啊。
    for(int i=0;i<filename.length;i++)
       filename[i]....//里面就是文件名字呀注意会包含两个这样的值:"." 和 ".."
    把它门去了
      

  8.   


    只是不知道返回的filename[]中的参数是数字逐个递增还是其他的办法~~~~~~~~~现在全明白了
    谢谢海风老大
    这个是我第一次在csdn提问
    满意~