Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tdgunes
Created March 11, 2014 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdgunes/9491925 to your computer and use it in GitHub Desktop.
Save tdgunes/9491925 to your computer and use it in GitHub Desktop.
import java.io.File;
class Untitled {
public static void main(String[] args) {
String absolutePath = "/Hello/AnotherFolder/The File Name.PDF";
File file = new File(absolutePath);
String fname = file.getName();
int pos = fname.lastIndexOf(".");
if (pos > 0) {
fname = fname.substring(0, pos);
}
String filePath = absolutePath.substring(0,absolutePath.lastIndexOf(File.separator));
filePath = filePath + File.separator;
System.out.println(filePath+fname+".png");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment