关于java.io.File重命名

package cn.mldn.com;

import java.io.File;

public class TestAllRename
{

	public static void main(String[] args) 
	{
		File file=new File("D:"+File.separator+"src");
		long start=System.currentTimeMillis();
		fileRename(file);
		long end=System.currentTimeMillis();
		System.out.println("运行时间"+(end-start));

	}
	public static void fileRename(File file)
	{                                            
		if(file.isDirectory())
		{
			File results[]=file.listFiles();
			if(results!=null)
			{
				for(int x=0;x<results.length;x++)
				{
					if(results[x].isDirectory())
					{
						fileRename(results[x]);
					}
					else
					{
						if(file.isFile())//如果是文件进行重命名
						{
							String fileName=null;
							
							if(file.getName().contains("."))
							{
								fileName=file.getName().substring(0,file.getName().lastIndexOf("."))+".txt";
							}
							else
							{
								fileName=file.getName()+".txt";
							}
							
							File newFile=new File(file.getParentFile(),fileName);//新文件的名称
							file.renameTo(newFile);//重命名
							
						}
						//System.out.println("***");
						
					}
					
					
					
				}
			}
			
		}
	}

}

这段程序,但是文件没有重命名。有人能够解答一下吗?

import java.io.File;


public class TestAllRename
{
 
	public static void main(String[] args) 
	{
		File file=new File("D:"+File.separator+"src");
		long start=System.currentTimeMillis();
		fileRename(file);
		long end=System.currentTimeMillis();
		System.out.println("运行时间"+(end-start));
 
	}
	public static void fileRename(File file)
	{                                            
		if(file.isDirectory())
		{
			File results[]=file.listFiles();
			if(results!=null)
			{
				for(int x=0;x<results.length;x++)
				{
					File result = results[x];

					if(result.isDirectory())
					{
						fileRename(result);
					}
					else
					{
						if(result.isFile())//如果是文件进行重命名
						{
							String fileName=null;
							
							if(result.getName().contains("."))
							{
								fileName=result.getName().substring(0,result.getName().lastIndexOf("."))+".txt";
							}
							else
							{
								fileName=result.getName()+".txt";
							}
							
							File newFile=new File(result.getParentFile(),fileName);//新文件的名称
							result.renameTo(newFile);//重命名
							
						}
						//System.out.println("***");
						
					}
					
					
					
				}
			}
			
		}
	}
 
}