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

org.kefirsf.bb.util.Utils Maven / Gradle / Ivy

Go to download

KefirBB is a Java-library for text processing. Initially it was developed for BB2HTML translation. But flexible configuration allows to use it in different cases. For example for parsing Markdown, Textile, and for HTML filtration.

The newest version!
package org.kefirsf.bb.util;

import java.io.InputStream;
import java.util.UUID;

/**
 * Utils class
 *
 * @author Vitaliy Samolovskih aka Kefir
 */
public final class Utils {
    private Utils() {
    }

    /**
     * Open the resource stream for named resource.
     * Stream must be closed by user after usage.
     *
     * @param resourceName resource name
     * @return input stream
     */
    public static InputStream openResourceStream(String resourceName) {
        InputStream stream = null;
        ClassLoader classLoader = Utils.class.getClassLoader();
        if (classLoader != null) {
            stream = classLoader.getResourceAsStream(resourceName);
        }

        if (stream == null) {
            stream = ClassLoader.getSystemResourceAsStream(resourceName);
        }
        return stream;
    }

    public static String generateRandomName() {
        return UUID.randomUUID().toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy