It's not a secret anymore!
The moose likes Beginning Java and the fly likes renaming image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "renaming image" Watch "renaming image" New topic

renaming image

pavan sharma

Joined: Dec 19, 2006
Posts: 21
how to rename an image.

i can rename a file but not image from this code...

File imgf=new File("c:\one.txt");
File renimgf=new File("c:\new.txt");
System.out.println("renameTo file: "+imgf.renameTo(renimgf));

How can i?

reply asap
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
How is an image different from a file?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jaime M. Tovar
Ranch Hand

Joined: Mar 28, 2005
Posts: 133

public class Rename {
public static void main(String [] args) {
File f = new File("hola.jpg");
File f2 = new File ("bye.jpg");

Has worked for me. The only thing I think can give you some trouble is you are working with the file, that it is open and so you can't change the name.

She will remember your heart when men are fairy tales in books written by rabbits.<br /> As long as there is duct tape... there is also hope.
I agree. Here's the link:
subject: renaming image
It's not a secret anymore!