出现这种情况是为什么(请高手指点)
import java.io.*;
class file{
public static void main(String args[])throws Exception {
System.out.println("enter directory");
char ch;
StringBuffer dirbuf= new StringBuffer();
while ((ch=(char)System.in.read())!='\n')
dirbuf.append(ch);
File dir=new File (dirbuf.toString());
System.out.println("enter file name");
StringBuffer filebuf= new StringBuffer ();
while ((ch=(char)System .in.read())!='\n')
filebuf.append(ch);
File input=new File(dir,filebuf.toString());
if (input.exists())
{
System.out.println("\nfile found");
System.out.println("\nfile name:"+input.getName());
System.out.println("\n file path:"+input.getPath());
System.out.println("\n abs path:"+input.getAbsolutePath());
System.out.println("\n readable?:"+input.canRead());
System.out.println("\n writeable?:"+input.canWrite());
System.out.println("\n directory listing:");
String listing[]=dir.list();
for (int i=0; i<listing.length; i++)
System.out.println(listing[i]);
}
else { System.out.println("file not found");}
}
}
我编译通过了
可是我却得不到结果
我输入的 信息是 目录c:\exemple
文件名 input.txt
在这个目录下我建了input.txt这个文件 为什么结果确实 file no found
请高手指点。。。。。。。。。。。。