Here you can find the source of renameOldFile(final String fileName)
public static void renameOldFile(final String fileName)
//package com.java2s; import java.io.File; public class Main { public static void renameOldFile(final String fileName) { final File file = new File(fileName); if (file.exists()) { final File oldFile = new File(fileName + ".old"); if (oldFile.exists()) { oldFile.delete();/*www . j a v a2 s. c o m*/ } file.renameTo(oldFile); } } }