Java tutorial
/* * This file is part of VirtualFile. * * Copyright 2016 by Bernd Riedl <bernd.riedl@gmail.com> * * Licensed under GNU Lesser General Public License 3.0 or later. * Some rights reserved. See COPYING, AUTHORS. */ package at.beris.virtualfile.client.ftp; import org.apache.commons.net.ftp.FTPClient; import java.io.IOException; import java.io.InputStream; public class FtpInputStream extends InputStream { private InputStream inputStream; private FTPClient ftpClient; public FtpInputStream(InputStream inputStream, FTPClient ftpClient) { this.inputStream = inputStream; this.ftpClient = ftpClient; } @Override public int read() throws IOException { return inputStream.read(); } @Override public int read(byte[] b) throws IOException { return inputStream.read(b); } @Override public int read(byte[] b, int off, int len) throws IOException { return inputStream.read(b, off, len); } @Override public long skip(long n) throws IOException { return inputStream.skip(n); } @Override public int available() throws IOException { return inputStream.available(); } @Override public void close() throws IOException { inputStream.close(); ftpClient.completePendingCommand(); ftpClient = null; } @Override public void mark(int readlimit) { inputStream.mark(readlimit); } @Override public void reset() throws IOException { inputStream.reset(); } @Override public boolean markSupported() { return inputStream.markSupported(); } }