skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Sunday, October 21, 2012

Taking File name from Absolute Path

Posted by Raju Gupta at 1:10 AM – 0 comments
 
Exact file name extraction is required many times, when dealing with files

public static String extractFileName(String absoluteFileName) {  

 if (!isNullOrEmpty(absoluteFileName)) {  
  //File with the absolute path
  absoluteFileName = absoluteFileName.substring(absoluteFileName  
    .lastIndexOf(File.separatorChar) + 1, absoluteFileName.lastIndexOf("."));  
  //File name extracted the absolute path
 }  
 return absoluteFileName;  
}  

Labels: Java File Example

Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger