Mega Code Archive

 
Categories / Java Tutorial / Network
 

Returns the anchor value of the given URL

public class Utils {   public static final String ANCHOR_CHAR = "#"; //$NON-NLS-1$   /**    * Returns the anchor value of the given URL.    *     * @param url    *          URL    * @return anchor value, or null if none was defined    */   public static String getAnchor(String url) {     if (url != null) {       int anchorPosition = url.indexOf(ANCHOR_CHAR);       if (anchorPosition >= 0) {         return url.substring(anchorPosition + 1);       }     }     return null;   } }