Hi.
I´m trying to change a file-extension, but it doesn´t seem to work.
When i use System.out.print() it says the new name, but the file in my computer doesn´t change.
My code:

public String changefileextension(String filename)
  {
 
    int lastDot = filename.lastIndexOf(".");
    if (lastDot != -1) {
  
        filename= filename.substring(0, lastDot) + ".xml";
    } else {
        filename=filename + ".xml";
    }
    
    return filename;

  }

All you are doing here is changing a String within your program. Where does this connect with the actual filesystem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.