3:50 pm - Tuesday February 19, 9304

Program to Rename the file denoted by abstract pathname

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

// Program to Rename the file denoted by abstract pathname.//

//Author: Candid Java//

//Description: This program Renames the file specified by us//

import java.io.*;

class renme

{

public static void main(String args[])throws Exception

{

InputStreamReader ir=new InputStreamReader(System.in);

BufferedReader br=new BufferedReader(ir);

System.out.println("Enter old file name:");

String s1=br.readLine();

File f2=new File(s1);

f2.createNewFile();

System.out.println("Enter name to be changed:");

String s2=br.readLine();

File f3=new File(s2);

boolean Rename=f2.renameTo(f3);

}

}

 

OUTPUT:

D:candidjava /io/file> javac  rename.java

D:candidjava /io/file> java rename

Enter old fie name:

Aaaa

Enter name to be changed:

Jjjjj

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply