4 Mayıs 2020 Pazartesi

VFS FileObject Arayüzü

Giriş
Virtual File System projesine aittir. Şu satırı dahil ederiz
import org.apache.commons.vfs2.FileObject;
copyFrom metodu
Örnek
Şöyle yaparız.
FileObject localFile = fsManager.resolveFile(file.getAbsolutePath());
FileObject remote = fsManager.resolveFile(
        "sftp://<USERNAME>:<PASSWORD>@<DOMAINNAME>.com/tmp1.zip");

remote.copyFrom(localFile, Selectors.SELECT_SELF);
remote.close();
Örnek
Şöyle yaparız. Hedef dizine bir dosyayı kopyalar
FileSystemManager fileSystemManager = VFS.getManager();
FileObject fileToCopy = fileSystemManager.resolveFile("/tmp/submission");
FileObject destinationDirectory = fileSystemManager.resolveFile("/tmp/test");

NameFileFilter nameFileFilter = new NameFileFilter(Arrays.asList("2004220.csv"));
FileSelector fileSelector = new FileFilterSelector(nameFileFilter);
destinationDirectory.copyFrom(fileToCopy,fileSelector);
delete metodu
Örnek ver

exist metodu
Örnek ver

getContent metodu
Şöyle yaparız
FileObject fileObject = ...;
InputStream inputStream = fileObject.getContent().getInputStream();



Hiç yorum yok:

Yorum Gönder