All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jpattern.core.util.FileUtil Maven / Gradle / Ivy

There is a newer version: 3.6.2
Show newest version
package com.jpattern.core.util;

import java.io.File;

/**
 * 
 * @author Francesco Cina'
 * 
 *         21/lug/2010
 */
public abstract class FileUtil {

	/**
	 * Restituisce il nome del file privo del path
	 * @param fName il nome completo del file (comprendente il path)
	 * @return il nome del file privo del path
	 */
	public static String removePath(String filename) {
		int pos = filename.lastIndexOf(File.separatorChar);
		if (pos > -1) {
			filename = filename.substring(pos + 1);
		}
		return filename;
	}

	public static String removeExtension(String filename) {
		int lastindex = filename.lastIndexOf('.');
		if ( lastindex != -1 ) {
			return filename.substring(0, lastindex);
		}
		return filename;
	}
	
	public static String getExtension(String filename) {
		int lastindex = filename.lastIndexOf('.');
		if ( lastindex != -1 && lastindex




© 2015 - 2025 Weber Informatics LLC | Privacy Policy