Beispiel #1
0
  /** 파일다운로드 */
  private static boolean getDownloadFile(FTPClient ftp, String filename) throws Exception {
    boolean isreceive = false;

    FileOutputStream fos = null; // File Output Stream
    File downloadfile = new File(filename); // File 객체
    try {
      fos = new FileOutputStream(downloadfile); // 다운로드할 File 생성
      ftp.retrieveFile(downloadfile.getName(), fos);
      isreceive = true;
    } catch (Exception ex) {
      ex.printStackTrace();
      throw ex;
    } finally {
      if (fos != null) {
        try {
          fos.close(); // Stream 닫기
        } catch (IOException ex) {
          ex.printStackTrace();
        }
      }
    }
    try {
      ftp.logout(); // FTP Log Out
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (ftp != null && ftp.isConnected()) {
        try {
          ftp.disconnect(); // 접속 끊기
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
    return isreceive;
  }