Here you can find the source of rename(File file, String prefix, String name, HashMap
public static void rename(File file, String prefix, String name, HashMap<String, String> optional)
//package com.java2s; /**//from w w w . j av a 2s . co m * Copyright (c) 2013, Robert Cherry * All rights reserved. * * This file is part of the Faust Engine. * * The Faust Engine is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * The Faust Engine is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * the Faust Engine. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.util.HashMap; public class Main { public static void rename(File file, String prefix, String name, HashMap<String, String> optional) { // @note This will not rename directories if (file.isFile()) { // final String before = file.getName(); final String shortName = prefix + file.getName(); // Store it here optional.put(before, shortName); // file.renameTo(new File(name)); } } }