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

com.sshtools.jaul.Lang Maven / Gradle / Ivy

Go to download

A library used across several JAdpative applications, it provides some common features based on Install4J Runtime.

The newest version!
package com.sshtools.jaul;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Optional;

public class Lang {
	
	public static String filename(String path) {
		var idx = path.lastIndexOf('/');
		if(idx == -1)
			idx = path.lastIndexOf('\\');
		return idx == -1 ? path  : path.substring(idx + 1);
	}
	
	public static URL resolve(URL baseUrl, String rel) {
		try {
			return baseUrl.toURI().resolve(rel).toURL();
		} catch (MalformedURLException | URISyntaxException e) {
			throw new IllegalArgumentException(e);
		}
	}
	
	public static Optional optionalText(String txt) {
		return txt.equals("") ? Optional.empty() : Optional.of(txt);
	}

	public static String dirname(String path) {
		var idx = path.lastIndexOf('/');
		if(idx == -1)
			idx = path.lastIndexOf('\\');
		return idx == -1 ? path  : path.substring(0, idx);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy