我想把一个文件重命名,代码如下:
File   file   =   new   File( "f://pictures//37.jpg"); 
File newfile = new   File( "f://pictures//137.jpg");
file.renameTo(newfile);
运行后文件名仍为f://pictures//37.jpg
如果输出file.renameTo(newfile)的值为false
希望各位大虾指点一下 不胜感激~~~

解决方案 »

  1.   

    File  file  =  new  File( "f://pictures//37.jpg"); 
    你这里的时候,已经把37.jpg给占用了。
      

  2.   

    第一次读入后需要romove掉,在重新读入一次,就可以改变了
      

  3.   

    右击要重命名的文件,点击refactor----->rename----->在新的对话框里输入新的命名就行了
      

  4.   

    一般是
    1 源文件不存在
    2 目标文件已经存在测试方法
        File  file  =  new  File( "f://pictures//37.jpg");
        File newfile = new  File( "f://pictures//137.jpg"); 
        System.out.println(file.exists());
        System.out.println(newfile.exists());