fos = new FileOutputStream(new File("D:\\a.sql")); // If the current file type is ASCII, line separators in the file are converted to the local representation. // 如果当前的文件类型(ftpClient.setFileType)是ASCII,行分隔符将转化为本地的格式 ftpClient.retrieveFile(new String("相关脚本.sql".getBytes("GBK"), "ISO-8859-1"), fos); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } finally { // 关闭ftp连接 if (null != ftpClient) { try { ftpClient.disconnect(); } catch (IOException e) { logger.error("关闭FTP连接异常", e); } } // 关闭zip文件输出流 if (null != fos) { try { fos.close(); } catch (IOException e) { logger.error("IO异常", e); } } }