Here you can find the source of getBase(final URI uri)
Parameter | Description |
---|---|
uri | The URI from which to get the base. |
public static String getBase(final URI uri)
//package com.java2s; /*/*from w w w . j a v a 2s .c om*/ * Copyright (c) 2014 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial concept and implementation */ import java.net.URI; import java.util.StringTokenizer; public class Main { /** * Get the base name of a URI (e.g. no path or extension) * * <p>Returns "index" from "http:\\projects\src\index.html".</p> * * @param uri The URI from which to get the base. * * @return The base file name */ public static String getBase(final URI uri) { if (uri != null) { String tempName = new String(""); final StringTokenizer stk1 = new StringTokenizer(uri.toString(), "/\\"); // Cruise through the string and eat up all the tokens before the last // directory delimiter while (stk1.hasMoreTokens()) { tempName = stk1.nextToken(); } final StringTokenizer stk = new StringTokenizer(tempName, "."); return stk.nextToken(); } return null; } }