View Javadoc

1   /*
2    * Created on 27 styczeń 2006, 22:00
3    */
4   
5   package twcsckernel.clientKernel.utils.fileChooserClasses;
6   
7   import java.util.regex.Matcher;
8   import java.util.regex.Pattern;
9   
10  /***
11   * 
12   * @author VMD Group
13   */
14  public class FileSystemUtils {
15  
16  	public static String fileNameExt(String fileName) {
17  		int pointLastIdx = fileName.lastIndexOf(".");
18  		if ((pointLastIdx < fileName.length()) && (pointLastIdx > 0)) {
19  			return fileName.substring(pointLastIdx + 1);
20  		} else
21  			return "";
22  	}
23  
24  	public static String fileNameWhitoutExt(String fileName) {
25  		int pointLastIdx = fileName.lastIndexOf(".");
26  		if ((pointLastIdx < fileName.length()) && (pointLastIdx > 0)) {
27  			return fileName.substring(0, pointLastIdx);
28  		} else
29  			return fileName;
30  	}
31  
32  	public static String preparePath(String path) {
33  		String preparedPath="";
34  		Matcher matcher = Pattern.compile("/+").matcher(path);
35  		preparedPath = matcher.replaceAll("/");
36  		Matcher matcher1 = Pattern.compile("[^/]*///.//./?").matcher(preparedPath);
37  		preparedPath = matcher1.replaceAll("");
38  		return preparedPath;
39  	}
40  	
41  
42  }