この記事の例は、JavaのFTPブレークポイントの実装の方法を示しています。あなたの参照のために全員のためにそれを共有してください。特定の分析は次のとおりです。
ここでは、主にApacheのネットパッケージを使用しています。 url http://commons.apache.org/net/。特定のパッケージのダウンロードおよびAPIドキュメントについては、公式Webサイトをご覧ください。 ブレークポイントのアップロードは、アップロード中に送信の開始位置を設定することです。バイナリ伝送を設定します。
Import Java.io.io.io.ioxception; .commons.net.printcommandlistener class contionftp {private ftpclient ftpclient = new ftpclient();サーバー* @param hostname host* @paramポートポート* @paramユーザー名ユーザー名* @paramパスワードパスワード* @returnの接続が成功しているかどうか* @throws ioexception*/ public boolean connect(string hostname、int port、string username、文字列パスワード)IoException {ftpclien T.Connect(hostname、port); ;} / *** ftpサーバーからファイルをダウンロード* @paramリモートファイルパス* @returnは成功します* / public booleanダウンロード(文字列リモート、文字列ローカル)スローioException ode(); out.println( "リモートファイルは一意ではありません")。 「ローカルファイルサイズは "+f.length())); "); return; client.retrieveful(remote out); out.close();} else {outputStream out = new fileoutputStream(f); result = ftpclient.retrievefile(remote、out); out.close();} rn result;}/***ファイルファイルをftpサーバーに移動してブレークポイントをサポート* @paramローカルファイル名、絶対パス* @paramリモートファイルパス、/home/directory1/subdirectory/file.ext仕様を使用します。 Linuxのパスは、マルチレベルのディレクトリをサポートし、前例のないディレクトリ構造の再帰作成をサポートします。 assivemode ftpclient.enterlocalpassivemode() {remotefileName = remote.substring(remote.lastindexof( "/")+1);ディレクトリ){//リモートディレクトリが存在しない場合、リモートサーバーディレクトリint start = 0; ;} end = directory.indexof( "/"、strue); {ftpclient.changedirectory(subdirectory);すべてのディレクトリが作成されます(end <= start){break;}}} // ftpfile [] files = ftpclient.listfiles(remotefilename)がある場合は確認します[0] .getSize(); new file(local); .rmote_bigger_local;} // inputstreamのブレークポイントを達成するためにモバイルファイルのポインターを読み取ろうとします。 ; ftpclient.storefile(remote、is)){return afpload_from_break_success; .upload_new_new _file_success;} else {result = uploadstatus.upload_new_file_faled;} is.close();} else {inputstream is = new fileinputstream(local)if(ftpclient.storefile(rimefilename、is); lse {result = uploadstatus.upload_new_file_faird;} is.close();} return result;} / ** *リモートサーバーに接続して接続 * @throws ioexception * / public void disconnect()throws ioexception {if(ftpclient.isconnectonectinectionectionection ()){ftpclient.disconnect() .flv "); myftp.disconnect();} catch(ioexception e){system.out.println(" connect ftpエラー: "+e.getmessage());}}}}この記事がすべての人のJavaプログラムのデザインに役立つことが期待されています。