Here you can find the source of rename(File src, String name)
Parameter | Description |
---|---|
src | The file to rename. |
name | The new name of the file. |
public static File rename(File src, String name)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { /**/*w w w . ja va2 s .c o m*/ * Renames a file using a string. * * @param src The file to rename. * @param name The new name of the file. * @return the new file or null if it failed. */ public static File rename(File src, String name) { File ret = new File(src.getParentFile(), name); if (src.renameTo(ret)) return ret; else return null; } }