I'm using Apache Commons VFS2 API (version 2.0) for a generic implementation to FTP or SFTP files. It has been working great till we had Virtual Directories as FTP destinations. I get NullpointerException trying to obtain an OutputStream from the FileObject.
...
DefaultFileSystemManager fileSystemManager = new DefaultFileSystemManager();
fileSystemManager.addProvider("ftp", new FtpFileProvider());
FileObject remoteObject = fileSystemManager.resolveFile(<FTP_URL>, null);
FileObject tempObject = fileSystemManager.resolveFile(remoteObject, "ftpFile.txt");
if(!tempObject.exists()){
tempObject = fileSystemManager.createVirtualFileSystem(tempObject);
}
//No file created by above actions so below gives null
OutputStream outputStream = tempObject.getContent().getOutputStream();
IOUtils.copy(inputStream, outputStream);
...