I have problems when looking for the path, the extension does bring it to me, but since I have a space on my local disk, it has a space and that is generating errors like I did to consider it, this is my code!
--> I have problems with having the local disk with a spacing c:/Some/Folder withpaces/Or/Other.pdf
public class Exame{
public static void main(String[] args) throws URISyntaxException {
System.out.println(getRoute("c:/Some/Folder withpaces/Or/Other.pdf","xlsx"));
}
public static String getRoute(String router,String newExtension) throws URISyntaxException {
URI uri = new URI(router);
String path = uri.getPath();
String lastSegment = path.substring(path.lastIndexOf('/') + 1);
String newName=lastSegment.substring(0,lastSegment.lastIndexOf("."))+"."+newExtension;
return new File(path.substring(0,path.lastIndexOf('/')+1),newName).getPath();
}
}