Solved

How can I rename a file on a server?

Posted on 2003-12-04
5
196 Views
Last Modified: 2010-04-01
Well how can I rename a file on a server?
The file is allready been uploaded by the admin. And I would like to rename this file to, for example the old filename is "johnny.jpg" and by renaimng this file it should be: new filename "10.jpg".

Could anyone help me??

Many thanks!!!!!
0
Comment
Question by:jrbiemans
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
kennethxu earned 100 total points
ID: 9876742
import java.io.*;

File oldName = new File( "/path/to/yourfile/johnny.jpg" );
File newName = new File( "/path/to/newfile/10.jpg" );
oldName.renameTo( newName );

let me know if you have futher enquires.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9876746
and welcome to expert-exchange :-)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 9926300
Make sure its not read-only.

Mayank.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SimpleDateFormat.parse examples 19 87
grep code 4 175
struts exact match support 3 51
print map entry 34 54
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

21 Experts available now in Live!

Get 1:1 Help Now