Java File Rename renameFile(String fileFrom, String fileTo)

Here you can find the source of renameFile(String fileFrom, String fileTo)

Description

rename File

License

Open Source License

Declaration

public static void renameFile(String fileFrom, String fileTo) 

Method Source Code

//package com.java2s;
/*/* w w w  . j  ava 2  s .co m*/
* Argus Open Source
* Software to apply Statistical Disclosure Control techniques
* 
* Copyright 2014 Statistics Netherlands
* 
* This program is free software; you can redistribute it and/or 
* modify it under the terms of the European Union Public Licence 
* (EUPL) version 1.1, as published by the European Commission.
* 
* You can find the text of the EUPL v1.1 on
* https://joinup.ec.europa.eu/software/page/eupl/licence-eupl
* 
* This software is distributed on an "AS IS" basis without 
* warranties or conditions of any kind, either express or implied.
*/

import java.io.File;

public class Main {
    public static void renameFile(String fileFrom, String fileTo) {
        File fFrom = new File(fileFrom);
        File fTo = new File(fileTo);
        if (fTo.exists()) {
            fTo.delete();
        }
        fFrom.renameTo(new File(fileTo));
    }
}

Related

  1. renameFile(File srcFile, File renameToFile)
  2. renameFile(final File path, final String fname)
  3. renameFile(final String oldName, final String newName)
  4. renameFile(String currentPath, String newPath)
  5. renameFile(String file, String toFile)
  6. renameFile(String fileName, String destFilename)
  7. renameFile(String filePath, String descFilePath)
  8. renameFile(String from, String to, String baksuffix)
  9. renameFile(String fromFilename, String toFilename)