标题:简单的io问题
取消只看楼主
越野骏驹
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-9-8
 问题点数:0 回复次数:0 
简单的io问题
先看程序:import
public class TestFile
{
    public static void main(String args[])
    {
        String dirname="\\java";
        File f = new File(dirname);
        
        if(f.isDirectory())
        {
            System.out.println("*****dirtory of "+dirname+"******");
            String s[] = f.list();
            System.out.println("-----The file under the directory of "+dirname+"-----");
            for(int i = 0; i<s.length; i++)
              {
                  File f1 = new File(s[i]);
                  
                  if(f1.isFile())
                  {
                      
                     System.out.println(s[i]+"   绝对路径:"+f1.getAbsolutePath(f1));
                }
                     
              }
             System.out.println("-----The directory under the directory of "+dirname+"-----");
            for(int j = 0 ;j<s.length;j++)
            {
                File f1 = new File(s[j]);
                if(f1.isDirectory())
                {
                    
                    System.out.println(s[j]);
                    }
            }
                
        }
        else
         System.out.println(dirname+"is a File");    
        
    }
    
}


果是这样的:
TestFile.java:21: 无法将 中的 getAbsolutePath() 应用于 (
e)
    System.out.println(s[i]+"   绝对路径:"+f1.getAbsolutePath(f1));
                                                                        ^
1 错误
这怎么解决???
搜索更多相关主题的帖子: public import java file 
2008-04-19 08:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-209873-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.998086 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved