Download a set of files from the remote server to a local directory.

@param remoteFiles          Paths and names of the remote files.
@param localTargetDirectory Local directory to put the downloaded files.
@throws IOException
197328
public void get(String remoteFiles[], String localTargetDirectory) throws IOException {
        Session sess = null;

        if ((remoteFiles == null) || (localTargetDirectory == null))
            throw new IllegalArgumentException("Null argument.");

        if (remoteFiles.length == 0)
            return;

//        String cmd = "scp -f -r";
        String cmd = "scp -f ";

        for (int i = 0; i < remoteFiles.length; i++) {
            if (remoteFiles[i] == null)
                throw new IllegalArgumentException("Cannot accept null filename.");

            cmd += (" " + remoteFiles[i]);
        }

        try {
            sess = conn.openSession();
            sess.execCommand(cmd);
            receiveFiles(sess, remoteFiles, localTargetDirectory);
            sess.close();
        } catch (IOException e) {
            if (sess != null)
                sess.close();

            throw (IOException) new IOException("Error during SCP transfer.").initCause(e);
        }
    }
135199
public List<Path> download(List<URI> srcs) {
    try {
      return paths.getAll(srcs).values().asList();
    } catch (ExecutionException e) {
      throw new RuntimeException(e);
    }
  }
118570
public void get(String remoteFileName,
                    DataSink sink,
                    MarkerListener mListener)
        throws IOException, ClientException, ServerException {
        checkTransferParamsGet();

        localServer.store(sink);
        controlChannel.write(new Command("RETR", remoteFileName));

        transferRunSingleThread(localServer.getControlChannel(), mListener);
    }
466584
private AFTPClient actionPutFile() throws IOException, PageException {
	required("remotefile", remotefile);
	required("localfile", localfile);

	AFTPClient client = getClient();
	Resource local = ResourceUtil.toResourceExisting(pageContext, localfile);// new File(localfile);
	// if(failifexists && local.exists()) throw new ApplicationException("File ["+local+"] already
	// exist, if you want to overwrite, set attribute
	// failIfExists to false");
	InputStream is = null;

	try {
	    is = IOUtil.toBufferedInputStream(local.getInputStream());
	    client.setFileType(getType(local));
	    client.storeFile(remotefile, is);
	}
	finally {
	    IOUtil.closeEL(is);
	}
	writeCfftp(client);

	return client;
    }
671784
public static void zip(File[] sources, File target) throws IOException {
		zip(sources, target, null);
	}
126126
public void setMountTargets(java.util.Collection<MountTargetDescription> mountTargets) {
        if (mountTargets == null) {
            this.mountTargets = null;
            return;
        }

        this.mountTargets = new com.amazonaws.internal.SdkInternalList<MountTargetDescription>(mountTargets);
    }
1250749
public void copyFrom(String remotePath, String localPath) throws Exception {
        FileOutputStream fos = null;
        String rfile = remotePath;
        String lfile = localPath;

        // If localPath is a directory, create it if it does not exist
        String prefix = null;
        File local = new File(lfile);
        if (!local.exists()) {
            local.mkdir();
            prefix = lfile + File.separator;
        } else {
            if (local.isDirectory()) {
                prefix = lfile + File.separator;
            }
        }

        // exec 'scp -f rfile' remotely
        String command = "scp -f " + remotePath;
        Channel channel = this.session.openChannel("exec");
        ((ChannelExec) channel).setCommand(command);

        // get I/O streams for remote scp
        OutputStream out = channel.getOutputStream();
        InputStream in = channel.getInputStream();

        channel.connect();

        byte[] buf = new byte[1024];

        // send '\0'
        buf[0] = 0;
        out.write(buf, 0, 1);
        out.flush();

        while (true) {
            int c = checkAck(in);
            if (c != 'C') {
                break;
            }

            // read '0644 '
            in.read(buf, 0, 5);

            long filesize = 0L;
            while (true) {
                if (in.read(buf, 0, 1) < 0) {
                    // error
                    break;
                }
                if (buf[0] == ' ') {
                    break;
                }
                filesize = filesize * 10L + (long) (buf[0] - '0');
            }

            String file = null;
            for (int i = 0;; i++) {
                in.read(buf, i, 1);
                if (buf[i] == (byte) 0x0a) {
                    file = new String(buf, 0, i);
                    break;
                }
            }

            // send '\0'
            buf[0] = 0;
            out.write(buf, 0, 1);
            out.flush();

            // read a content of lfile
            fos = new FileOutputStream(prefix == null ? lfile : prefix + file);
            int foo;
            while (true) {
                if (buf.length < filesize) {
                    foo = buf.length;
                } else {
                    foo = (int) filesize;
                }
                foo = in.read(buf, 0, foo);
                if (foo < 0) {
                    // error
                    break;
                }
                fos.write(buf, 0, foo);
                filesize -= foo;
                if (filesize == 0L) {
                    break;
                }
            }
            fos.close();
            fos = null;

            if (checkAck(in) != 0) {
                throw new RuntimeException("Read error on inputstream");
            }

            // send '\0'
            buf[0] = 0;
            out.write(buf, 0, 1);
            out.flush();
        }
        channel.disconnect();
    }
706304
public function get($remoteFile = null, $localFile = null, $mode = FTP_ASCII)
        {
            // attempt download
            if(ftp_get(static::$_stream, $localFile, $remoteFile, $mode)) {
                // success
                return true;
            // download failed
            } else {
                static::$error = "Failed to download file \"{$remoteFile}\"";
                return false;
            }
        }
640324
public static void copyFiles(File[] files, File[] destinationFiles) throws IOException {
        int length = Integer.min(files.length, destinationFiles.length);
        for (int i = 0; i < length; i++) {
            copyFile(files[i], destinationFiles[i]);
        }
    }
897496
public static void copyFiles(String[] files, String storageFolder) throws IOException {
        copyFiles(getFiles(files), storageFolder);
    }
1100736
def download_file(self, remote, local):
        
        file = open(local, 'wb')
        try:
            self.download(remote, file)
        finally:
            file.close()
1122627
public void copyToLocalFile(boolean delSrc, boolean validate,
      Path src, Path dst)
  throws IOException {
    FileUtil.copy(this, src, getLocal(getConf()), dst, delSrc,
        validate, getConf());
  }
773832
public void downloadFileUsingRequesterPays(
      String projectId, String bucketName, String srcFilename, Path destFilePath)
      throws IOException {
    // [START storage_download_file_requester_pays]
    // The project ID to bill
    // String projectId = "my-billable-project-id";

    // The name of the bucket to access
    // String bucketName = "my-bucket";

    // The name of the remote file to download
    // String srcFilename = "file.txt";

    // The path to which the file should be downloaded
    // Path destFilePath = Paths.get("/local/path/to/file.txt");

    // Instantiate a Google Cloud Storage client
    Storage storage = StorageOptions.getDefaultInstance().getService();

    // Get specific file from specified bucket
    Blob blob = storage.get(BlobId.of(bucketName, srcFilename));

    // Download file to specified path
    blob.downloadTo(destFilePath, Blob.BlobSourceOption.userProject(projectId));
    // [END storage_download_file_requester_pays]
  }
1274061
@SuppressWarnings("deprecation")
  private void addLocalFiles(Path jobFileDir, String jobFileList, Configuration conf) throws IOException {
    DistributedCache.createSymlink(conf);
    for (String jobFile : SPLITTER.split(jobFileList)) {
      Path srcJobFile = new Path(jobFile);
      // DistributedCache requires absolute path, so we need to use makeQualified.
      Path destJobFile = new Path(this.fs.makeQualified(jobFileDir), srcJobFile.getName());
      // Copy the file from local file system to HDFS
      this.fs.copyFromLocalFile(srcJobFile, destJobFile);
      // Create a URI that is in the form path#symlink
      URI destFileUri = URI.create(destJobFile.toUri().getPath() + "#" + destJobFile.getName());
      LOG.info(String.format("Adding %s to DistributedCache", destFileUri));
      // Finally add the file to DistributedCache with a symlink named after the file name
      DistributedCache.addCacheFile(destFileUri, conf);
    }
  }
1084478
@Given("^I outbound copy '(.+?)' through a ssh connection to '(.+?)'$")
    public void copyToRemoteFile(String localPath, String remotePath) throws Exception {
        commonspec.getRemoteSSHConnection().copyTo(localPath, remotePath);
    }
1043076
File getTargetDirectory( File sourceFile, File sourceBaseDir, File targetBaseDir )
        throws MojoExecutionException, MojoFailureException
    {
        String filePath;
        String tempPath;
        try
        {
            filePath = sourceFile.getParentFile().getCanonicalPath();
            tempPath = sourceBaseDir.getCanonicalPath();
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "Error getting canonical path", e );
        }

        if ( !filePath.startsWith( tempPath ) )
        {
            throw new MojoFailureException( "File " + sourceFile
                + " is expected to be somewhere under the following directory: " + tempPath );
        }

        File targetDir = new File( targetBaseDir, filePath.substring( tempPath.length() ) );
        return targetDir;
    }
458425
def download_files(file_urls, target_path):
        
        os.makedirs(target_path, exist_ok=True)
        downloaded_files = []

        for file_url in file_urls:
            req = requests.get(file_url)

            if req.status_code != 200:
                raise base.FailedDownloadException('Failed to download file {} (status {})!'.format(req.status_code,
                                                                                                    file_url))

            file_name = os.path.basename(file_url)
            target_file_path = os.path.join(target_path, file_name)

            with open(target_file_path, 'wb') as f:
                f.write(req.content)

            downloaded_files.append(target_file_path)

        return downloaded_files