List of utility methods to do Path Create
String | ensureSlash(String dirPath) ensure Slash if (dirPath.endsWith(File.separator)) { return dirPath; return dirPath + File.separator; |
String | fileDir(String filename) file Dir String path = null; if (!FileUtil.isFileExist(filename)) { File f = new File(filename); f.mkdir(); path = f.getPath(); return path; |
String | fileDir(String folder, String folderName) file Dir String path = null; if (!FileUtil.isFileExist(folder, folderName)) { String fullPath = folder + folderName; File f = new File(fullPath); f.mkdir(); path = f.getPath(); return path; ... |
File | getAbsoluteFile(String filename, String basedir) Gets an absolute file from a filename. if (filename == null) { return null; File file = new File(filename); if (file.isAbsolute()) { return file; } else { return new File(basedir, file.getPath()); ... |
String | getAbsolutePath(String strCurrenDir, String strFileName) get Absolute Path if (!strFileName.startsWith("/") && !strFileName.startsWith("\\")) { if (!strCurrenDir.endsWith("/") && !strCurrenDir.endsWith("\\")) return strCurrenDir + "/" + strFileName; return strCurrenDir + strFileName; return strFileName; |
String | getAbsolutePathFromResource(Class reference, String resource) Returns the absolute path of the resource. URL urlResource = reference.getResource(resource); if (urlResource == null) return null; String urlString = URLDecoder.decode(urlResource.toString()); if (urlString.startsWith("jar:")) urlString = urlString.substring("jar:".length()); if (urlString.startsWith("file:")) urlString = urlString.substring("file:".length()); ... |
String | getAbsolutePathFromResource(String resource) Returns the absolute path of the resource. return getAbsolutePathFromResource(Object.class, resource); |
String | getCanonicalPath(File file) get Canonical Path try { return file.getCanonicalPath(); } catch (Exception e) { return null; |
String[] | getDirAndFullName(File f) get Dir And Full Name String path = f.getPath(); int index = path.lastIndexOf('/'); if (index == -1) { index = path.lastIndexOf('\\'); return new String[] { path.substring(0, index + 1), path.substring(index + 1) }; |
String | getDirName(String dir) get Dir Name if (dir.endsWith(separator)) { dir = dir.substring(0, dir.lastIndexOf(separator)); return dir.substring(dir.lastIndexOf(separator) + 1); |