Rename File

ตัวอย่าง code การเปลี่ยนชื่อไฟล์

/**
 * File Name : RenameFile.java
 * Created Date : Nov 12, 2009 : 10:27:25 AM
 * Copyright © 2009 www.fun4station.com
 */
package com.fun4station.example;

import java.io.File;

/**
 * @Author Supot Saelao
 * @Version 1.0
 */
public class RenameFile {

	public static void main(String[] args) {
		//Create old file
		File oldFile = new File("oldFile.txt");

		//Create new file object
		File newFile = new File("newFile.txt");
		//Rename old file to new file
		if(oldFile.renameTo(newFile)){
			System.out.println("Rename file success...");
		}else{
			System.out.println("Rename file fail...");
		}
	}

}

ข้อมูลจาก
Renaming a File or Directory

  1. No comments yet.

  1. No trackbacks yet.