Here you can find the source of getFileExtension(File file)
Parameter | Description |
---|---|
file | The file object to get the extension for. |
private static String getFileExtension(File file)
//package com.java2s; /******************************************************************************* * Copyright (c) 2013//from w w w . j a v a2s .c om * * 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: * Benjamin Klatt - initial API and implementation and/or initial documentation *******************************************************************************/ import java.io.File; public class Main { /** * Get the file extension of a file. * * @param file * The file object to get the extension for. * @return The file extension or null if none found. */ private static String getFileExtension(File file) { String path = file.toString(); if (path == null) { return null; } String fileExtension = path.substring(path.lastIndexOf('.') + 1); return fileExtension; } }