ftp 方式複製檔案到本地

2021-09-24 09:08:50 字數 1007 閱讀 8585

public static byte copyfile(string filename) throws exception 

return_arraybyte = byteout.tobytearray();

//file localfile = new file(local_path +file.separator+ f);

//outputstream is = new fileoutputstream(localfile);

is);

localfile);

byteout.close();

ins.close();

ftpclient.completependingcommand();

break;}}

} catch (exception e) finally

} bytearrayinputstream bts = new bytearrayinputstream(return_arraybyte);

file localfile = new file(local_path +file.separator+ filename);

fileutils.copyinputstreamtofile(bts, localfile);

return return_arraybyte;

}

關閉輸入流之後返回的inputstream物件為空,用bytes儲存後返回出去再new bytearrayinputstream(bytes); 方法可以獲得輸入流

為什麼要執行inputstream.close();再執行ftp.completependingcommand()

commons-net的ftpclient,在使用public inputstream retrievefilestream(string remote)

方法時需要特別注意,在呼叫這個介面後,一定要手動close掉返回的inputstream,然後再呼叫completependingcommand方法

同步檔案到本地FTP指令碼

同步公網兩台資料庫伺服器的備份包回到本地的ftp伺服器上面,本地伺服器具備免金鑰登入公網的兩台伺服器。bin bash creation date 2011 07 06 auther wubolu rq date y m d scp root 61.45.18.103 home databack 1...

Oracle遠端複製表到本地

問題2 sql plus copy命令 問題描述 怎樣在sql plus中實現不同的表之間的資料複製,不論是本地的還是遠端的?問題分析 在sql plus中的copy命令,可以完成遠端資料庫 本地資料庫或oracle資料庫與非oracle資料庫之間的資料複製。其效能與匯入 匯出相同。copy的基本命...

批處理 複製共享資料夾檔案到本地目錄

echo off set now date 0,4 date 5,2 date 8,2 echo start pause md f a xcopy y 10.10.108.21 報表彙總 f a s e c program files putty pscp.exe pw test f a 產品資訊....