D:\temp\java>java ReadFile
Please input the directory name:
c:\Please input the file name:
auto.bat
can't find the file
/*
c:\auto.bat是存在的。如果我直接把"c:\\" 和 “auto.bat”作为参数放到
File input = new File(dir,fileBuf.toString());如
File input = new File("c:\\","auto.bat");
就一点问题没有。
*/

解决方案 »

  1.   

    我使用Sun One Studio+jdk 1.4编译通过,使用无误。但在命令行状态下确实是显示无法找到!
    -----------刚刚学习,无法回答你,抱歉!
      

  2.   

    是挺奇怪的,我试过,在File input = new File(dir,fileBuf.toString());前
    输出fileBuf的值为空,感觉象被丢掉了。
      

  3.   

    DataInputStream in =
          new DataInputStream(
            new BufferedInputStream(System.in));
        String s;
        try {
          while((s = in.readLine()).length() != 0)
            System.out.println(s);
          // An empty line terminates the program
        } catch(IOException e) {
          e.printStackTrace();
        }