Wednesday, December 22, 2010

Java-Renaming a file

import java.io.*;

class TestFile {
public static void main(String[] args) throws Exception {
File file = new File(args[0]);
System.out.println(file.getAbsolutePath());

File oldFile = new File("a.txt");
File newFile = new File("b.txt");
oldFile.renameTo(newFile);

if (new File("a.txt").renameTo(new File("b.txt"))) {
} else {
}

}
}

0 comments:

Post a Comment

Contact Form

Name

Email *

Message *

The Insane Techie - Android App

Launched an android app for the blog on 07th June 2016. Get it from google play store... Tips for using the app Use in landscape mo...