Here you can find the source of getFileExtension(final String fullName)
Parameter | Description |
---|---|
fullName | a parameter |
public static String getFileExtension(final String fullName)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2014 compeople AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* ww w.ja v a 2 s .c om*/ * compeople AG - initial API and implementation *******************************************************************************/ import java.io.File; import org.eclipse.core.runtime.Assert; public class Main { /** * Returns the file extension for the given file name, or the empty string if the file has no extension. The result does not include the '.'. * * @param fullName * @return file extension or empty string if the file has no extension */ public static String getFileExtension(final String fullName) { Assert.isNotNull(fullName, "fullName must be given!"); //$NON-NLS-1$ final String fileName = new File(fullName).getName(); final int dotIndex = fileName.lastIndexOf('.'); return (dotIndex == -1) ? "" : fileName.substring(dotIndex + 1); //$NON-NLS-1$ } }