Solved

re-naming a file

Posted on 2013-11-08
2
92 Views
Last Modified: 2013-11-14
hi guys

I want to rename a file , so the new file will have the new name and all contents from old file
Is there a simple way to do this?

is this correct?

for (final File fileEntry : folder.listFiles()) {
String newFileName = fileEntry.getName()+".RENAMED";
File newFile = new File(fileEntry.getParent(), newFileName);
}

Open in new window

0
Comment
Question by:royjayd
  • 2
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 400 total points
ID: 39633500
That's ok
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39648470
:)
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now