代码如下:
import java.io.*;
class ch1
{
public static void main(String[] args)
{
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入任何一个路径");
String a=buf.readLine();
File path=new File("buf");
if(path.isDirectory())
{
System.out.println(path.getName()+"为一个目录");
System.out.println("----------------");
File FileList[]=path.listFiles();
for(int i=0;i<FileList.length();i++)
{
if(FileList[i].isHidden()==false)
{
System.out.println(FileList[i].getName());
}
}
}
else
{
System.out.println(path.getName()+"是一个文件");
System.out.println("----------------");
System.out.println("其绝对路径是"+path.getAbsolutePath());
System.out.println(path.canRead()?"可读取":"不可读取");
System.out.println(path.canWrite()?"可写":"不可写");
System.out.println(path.isHidden()?"这是隐藏文件":"不是隐藏文件");
}
}
}
报错如下:
E:\Java\jdk1.4.2\create\file>javac ch1.java
ch1.java:16: cannot resolve symbol
symbol : method length ()
location: class java.io.File[]
for(int i=0;i<FileList.length();i++)
^
1 error |
|