0

ディレクトリを Linux (リモート マシン) から Windows (ローカル マシン) にコピーしようとしています。そのためのコマンドを教えてください。

例:「/home/tmp」から「C:\TEMP」へ

4

3 に答える 3

4

1 つのオプションは、ssh サーバーを使用することです。そのためには、ssh サーバーを Linux システム (ubuntu の場合はopenssh ) とウィンドウ (例: winscp ) にもインストールする必要があります。その後、scp コマンドを使用してファイルを転送できます。詳しくは SSHでファイル転送

于 2013-06-13T09:53:09.447 に答える
1

以下を使用して、フォルダーを (Linux ノード上の) zip ファイルに圧縮するユーティリティを用意します。

zip -r temp.zip /home/tmp

その後、sftp を使用して単純な単一ファイルとしてローカルに転送します。最後に、Windows マシンで解凍します (java.util.zip を使用)。

 /**
 * Unzip it
 * @param zipFile input zip file
 * @param output zip file output folder
 */
public void unZipFolder(String zipFile, String outputFolder){

 byte[] buffer = new byte[1024];

 try{

    //create output directory is not exists
    File folder = new File(OUTPUT_FOLDER);
    if(!folder.exists()){
        folder.mkdir();
    }

    //get the zip file content
    ZipInputStream zis = 
        new ZipInputStream(new FileInputStream(zipFile));
    //get the zipped file list entry
    ZipEntry ze = zis.getNextEntry();

    while(ze!=null){

       String fileName = ze.getName();
       File newFile = new File(outputFolder + File.separator + fileName);

       System.out.println("file unzip : "+ newFile.getAbsoluteFile());

        //create all non exists folders
        //else you will hit FileNotFoundException for compressed folder
        new File(newFile.getParent()).mkdirs();

        FileOutputStream fos = new FileOutputStream(newFile);             

        int len;
        while ((len = zis.read(buffer)) > 0) {
        fos.write(buffer, 0, len);
        }

        fos.close();   
        ze = zis.getNextEntry();
    }

    zis.closeEntry();
    zis.close();

    System.out.println("Done");

}catch(IOException ex){
   ex.printStackTrace(); 
}
}
于 2013-06-13T10:56:56.733 に答える
0

http://openssh.en.softonic.com/のような sftp クライアントを使用します。まだ非常に基本的な質問です。質問する前に検索するべきでした

于 2013-06-13T09:47:41.367 に答える