filenames - Java - Getting file name without extension from a folder -


i'm using code absolute path of files inside folder

public void addfiles(string filefolder){         arraylist<string> files = new arraylist<string>();              fileop.getfiles(filefolder, files); } 

but want file name of files (without extension). how can this?

this code work of removing extension , printing name of file:

      public static void main(string[] args) {         string path = "c:\\users\\abc\\some";         file folder = new file(path);         file[] files = folder.listfiles();         string filename;         int lastperiodpos;         (int = 0; < files.length; i++) {             if (files[i].isfile()) {                 filename = files[i].getname();                 lastperiodpos = filename.lastindexof('.');                 if (lastperiodpos > 0)                 filename = filename.substring(0, lastperiodpos);                 system.out.println("file name " + filename);             }         }     } 

if ok standard libraries use apache common has ready-made method that.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -