简单的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 错误
这怎么解决???