Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

renaming image

 
pavan sharma
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is an image different from a file?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Jaime M. Tovar
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;

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

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic