Here you can find the source of renameFile(String oldname, String newone)
Parameter | Description |
---|---|
oldname | The name of the file to be renamed. |
newone | The new file name. |
public static boolean renameFile(String oldname, String newone)
//package com.java2s; import java.io.File; public class Main { /**// w w w.j av a 2 s.com * Renames a file from oldname to newone. * * @param oldname The name of the file to be renamed. * @param newone The new file name. * @return <i>True</ib> if everything went fine and <i>false</i> otherwise. */ public static boolean renameFile(String oldname, String newone) { boolean result = false; File file = new File(oldname); if (file.exists()) { result = file.renameTo(new File(newone)); } return result; } }