package util; import java.io.File; import org.apache.log4j.Logger; public class FileSystem { private static final Logger LOGGER = Logger.getLogger(FileSystem.class); public static String getRelativePath(File absolutePath, File parentDir) { String file; String dir; try { file = absolutePath.getCanonicalPath(); dir = parentDir.getCanonicalPath() + File.separator; } catch (Exception e) { LOGGER.error("Could not get relative path for " + absolutePath.toString(), e); return null; } if (!file.startsWith(dir)) return null; return file.substring(dir.length()); } }