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

com.github.leeonky.dal.extensions.basic.sftp.util.SftpFileGroup Maven / Gradle / Ivy

There is a newer version: 0.7.4
Show newest version
package com.github.leeonky.dal.extensions.basic.sftp.util;

import com.github.leeonky.dal.extensions.basic.file.util.FileGroup;

import java.io.InputStream;
import java.util.stream.Stream;

public class SftpFileGroup extends FileGroup {
    private final SFtpFile sFtpFile;

    public SftpFileGroup(SFtpFile sFtpFile, String name) {
        super(name);
        this.sFtpFile = sFtpFile;
    }

    @Override
    protected InputStream open(SFtpFile subFile) {
        return subFile.download();
    }

    @Override
    protected SFtpFile createSubFile(String fileName) {
        return sFtpFile.access(fileName).orElseThrow(IllegalStateException::new);
    }

    @Override
    protected Stream listFileName() {
        return sFtpFile.ls().stream().map(SFtpFile::name).filter(n -> n.startsWith(name + "."));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy