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

com.aeontronix.enhancedmule.tools.util.ClassPathStreamSource Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha4
Show newest version
/*
 * Copyright (c) Aeontronix 2019
 */

package com.aeontronix.enhancedmule.tools.util;

import java.io.InputStream;

public class ClassPathStreamSource implements StreamSource {
    private String filename;
    private Class classSource;
    private String path;

    public ClassPathStreamSource(Class classSource, String path) {
        this(classSource, path.contains("/") ? path.substring(path.indexOf("/") + 1) : path, path);
    }

    public ClassPathStreamSource(Class classSource, String filename, String path) {
        this.classSource = classSource;
        this.filename = filename;
        this.path = path;
    }

    @Override
    public String getFileName() {
        return filename;
    }

    @Override
    public InputStream createInputStream() {
        return getClass().getResourceAsStream(path);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy