Created
March 11, 2014 18:25
-
-
Save tdgunes/9491925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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