Java FTP ロジックのメモ

package xxxx.service;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

import java.io.File;
import java.io.FileOutputStream;

public class Ftp {

	private String user;
	private String password;
	private String host;
	private String inputPath;
	private String outputPath;

	public Ftp(
			String user,
			String password,
			String host
	){
		this.user = user;
		this.password = password;
		this.host = host;
	}

	public void FileGet(String inputPath, String outputPath) throws Exception{
		this.inputPath = inputPath;
		this.outputPath = outputPath;
		FileOutputStream ostream = null;
		FTPClient ftpclient = new FTPClient(); 
		try {
			ftpclient.connect(this.host);
			int reply = ftpclient.getReplyCode();
			if (!FTPReply.isPositiveCompletion(reply)){
				System.err.println("connect fail");
			}
			if (ftpclient.login(this.user, this.password) == false) {
				System.err.println("login fail");
			}
			ostream = new FileOutputStream(this.outputPath);
			ftpclient.retrieveFile(this.inputPath, ostream);
		}
		catch(Exception e){
			e.printStackTrace();
		}
		finally{
			if (ftpclient.isConnected()) ftpclient.disconnect();
			if (ostream != null) {
				try{
					ostream.close();
				} catch(Exception e){
					e.printStackTrace();
				}
			}
		}
	}
}