@Test public void RebaseFileTest() throws IllegalArgumentException, IOException{ File rebased=Path.rebaseFile(srcMountPnt, dstMountPnt, pathTest); Assert.assertTrue(rebased.isAbsolute()); Assert.assertTrue(rebased.getAbsolutePath().equals(dstMountPnt.getAbsolutePath()+File.separator+"inner"+File.separator+"PathTest.txt")); }
public static File rebaseFile(final File srcMountPoint, final File destMountPoint, final File file) throws IOException, IllegalArgumentException { final StringBuffer buf = new StringBuffer(file.getCanonicalPath()); String srcMountPointFilePath = srcMountPoint.getCanonicalPath(); if (buf.toString().equals(srcMountPointFilePath)) { return destMountPoint; } return new File(destMountPoint, toRelativeFile(srcMountPoint, file).getPath()); }
Path { public static File rebaseFile(final File srcMountPoint, final File destMountPoint, final File file) throws IOException, IllegalArgumentException { final StringBuffer buf = new StringBuffer(file.getCanonicalPath()); String srcMountPointFilePath = srcMountPoint.getCanonicalPath(); if (buf.toString().equals(srcMountPointFilePath)) { return destMountPoint; } return new File(destMountPoint, toRelativeFile(srcMountPoint, file).getPath()); } }
Path { public static File rebaseFile(final File srcMountPoint, final File destMountPoint, final File file) throws IOException, IllegalArgumentException { final StringBuffer buf = new StringBuffer(file.getCanonicalPath()); String srcMountPointFilePath = srcMountPoint.getCanonicalPath(); if (buf.toString().equals(srcMountPointFilePath)) { return destMountPoint; } return new File(destMountPoint, toRelativeFile(srcMountPoint, file).getPath()); }  }
Path { public static File rebaseFile(final File srcMountPoint, final File destMountPoint, final File file) throws IOException, IllegalArgumentException { final StringBuffer buf = new StringBuffer(file.getCanonicalPath()); String srcMountPointFilePath = srcMountPoint.getCanonicalPath(); if (buf.toString().equals(srcMountPointFilePath)) { return destMountPoint; } return new File(destMountPoint, toRelativeFile(srcMountPoint, file).getPath()); }  static File findLocation(String location, File directory); static File findLocation(File location, File directory); static String findLocation(String location, String directory); static File createFile(String location, File directory); static File createDirectory(String location, File directory); static File rebaseFile(final File srcMountPoint, final File destMountPoint, final File file); static File toRelativeFile(final File srcMountPoint, final File file); final static File createTodayDirectory(File destDir, String inputFileName, final boolean withTime); final static File createTodayDirectory(File destDir, String inputFileName); }
Path { public static File rebaseFile(final File srcMountPoint, final File destMountPoint, final File file) throws IOException, IllegalArgumentException { final StringBuffer buf = new StringBuffer(file.getCanonicalPath()); String srcMountPointFilePath = srcMountPoint.getCanonicalPath(); if (buf.toString().equals(srcMountPointFilePath)) { return destMountPoint; } return new File(destMountPoint, toRelativeFile(srcMountPoint, file).getPath()); }  static File findLocation(String location, File directory); static File findLocation(File location, File directory); static String findLocation(String location, String directory); static File createFile(String location, File directory); static File createDirectory(String location, File directory); static File rebaseFile(final File srcMountPoint, final File destMountPoint, final File file); static File toRelativeFile(final File srcMountPoint, final File file); final static File createTodayDirectory(File destDir, String inputFileName, final boolean withTime); final static File createTodayDirectory(File destDir, String inputFileName);  }