Here you can find the source of getRelativePath(File file, String xmlDirectoryPath)
Parameter | Description |
---|---|
file | a parameter |
xmlDirectoryPath | a parameter |
public static String getRelativePath(File file, String xmlDirectoryPath)
//package com.java2s; import java.io.File; public class Main { /**//from w w w .j av a 2 s .co m * Returns a part of absolute path that starts from the xml directory path (xml directory path is cut * off). * * @param file * @param xmlDirectoryPath * @return */ public static String getRelativePath(File file, String xmlDirectoryPath) { return removeLeadingSlashes(file.getAbsolutePath().substring(xmlDirectoryPath.length())); } /** * Removes leading slashs (one or more) if they are there. Leaves leading slash if link is only the * leading slash ("/"). * * @param link * @return */ public static String removeLeadingSlashes(String link) { if (link == null) return ""; if (link.equals("/")) return link; return link.startsWith("/") ? removeLeadingSlashes(link.substring(1)) : link; } }