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

it.eng.spago.util.GeneralUtilities Maven / Gradle / Ivy

/**

    Copyright 2004, 2007 Engineering Ingegneria Informatica S.p.A.

    This file is part of Spago.

    Spago is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2.1 of the License, or
    any later version.

    Spago is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Spago; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

**/
package it.eng.spago.util;



public class GeneralUtilities {


	/**
	 * From a String identifying the complete name for a file, gets the relative file names, 
	 * which are substrings of the starting String, according to the java separator "/".
	 * 
	 * @param completeFileName The string representing the file name 
	 * @return	relative names substring
	 */
	public static String getRelativeFileNames(String completeFileName){
		String fileSeparator = System.getProperty("file.separator");
		String javaSeparator = "/";
		if (completeFileName.indexOf(fileSeparator) < 0){
			if (completeFileName.indexOf(javaSeparator) < 0){ 
				return completeFileName;
			}else{
				int lastIndexOf = completeFileName.lastIndexOf(javaSeparator);
				return completeFileName.substring(lastIndexOf+1);
			}		
		}else{
			int lastIndexOf = completeFileName.lastIndexOf(fileSeparator);
			return completeFileName.substring(lastIndexOf+1);
		}
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy