jsp - how to get name of file using Index of command in java -
public class myclass { public static void main(string args[]) { string filepath = "e:\\sw\\eclipse-jee-helios-sr1-win32\\eclipse\\cbdtfiles\\circulars\\cbdtlaws\\htmlfiles\\file1.htm"; string w=filepath.replace("e:\\sw\\eclipse-jee-helios-sr1-win32\\eclipse\\cbdtfiles\\circulars\\cbdtlaws\\htmlfiles\\", ""); system.out.println(w); } } this code able display file name using replace of command want file using index of command how index of htmlfiles can file name because file comingdynamically
use string#lastindexof(string) string#substring(int):
string filename = filepath.substring(filepath.lastindexof("\\") + 1);
Comments
Post a Comment