Effective in 2026, to align with our trunk stable development model and ensure platform stability for the ecosystem, we will publish source code to AOSP in Q2 and Q4. For building and contributing to AOSP, use android-latest-release. The android-latest-release manifest branch will always reference the most recent release pushed to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
RemoteFileUtil
public
class
RemoteFileUtil
extends Object
| java.lang.Object
|
| ↳ |
com.android.tradefed.util.RemoteFileUtil
|
Utility class to handle file from a remote instance
Summary
Public methods |
static
boolean
|
doesRemoteFileExist(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remotePath)
Check if a file (or directory) exists on the remote instance
|
static
boolean
|
doesRemoteFileExist(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remotePath, String sshPortNumber)
Check if a file (or directory) exists on the remote instance
|
static
boolean
|
fetchRemoteDir(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteDirPath, File localDir)
Fetch a remote directory from the remote host.
|
static
File
|
fetchRemoteDir(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteDirPath)
Fetch a remote directory from the remote host.
|
static
File
|
fetchRemoteDir(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteDirPath)
Fetch a remote directory from the remote host.
|
static
boolean
|
fetchRemoteDir(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteDirPath, File localDir)
Fetch a remote directory from the remote host.
|
static
File
|
fetchRemoteFile(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath)
Fetch a remote file in the container instance.
|
static
File
|
fetchRemoteFile(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteFilePath)
Fetch a remote file in the container instance.
|
static
boolean
|
fetchRemoteFile(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)
Fetch a remote file in the device or container instance.
|
static
boolean
|
fetchRemoteFile(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)
Fetch a remote file in the device or container instance.
|
static
boolean
|
pushFileToRemote(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)
Push a File from the local host to the remote instance
|
Public constructors
RemoteFileUtil
public RemoteFileUtil ()
Public methods
doesRemoteFileExist
public static boolean doesRemoteFileExist (String host,
String user,
File sshPrivateKey,
IRunUtil runUtil,
long timeout,
String remotePath)
Check if a file (or directory) exists on the remote instance
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remotePath |
String: The remote path where to find the file. |
| Returns |
boolean |
whether the file exists or not |
doesRemoteFileExist
public static boolean doesRemoteFileExist (String host,
String user,
File sshPrivateKey,
IRunUtil runUtil,
long timeout,
String remotePath,
String sshPortNumber)
Check if a file (or directory) exists on the remote instance
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remotePath |
String: The remote path where to find the file. |
sshPortNumber |
String: port number for ssh. |
| Returns |
boolean |
whether the file exists or not |
fetchRemoteDir
public static boolean fetchRemoteDir (String host,
String user,
File sshPrivateKey,
IRunUtil runUtil,
long timeout,
String remoteDirPath,
File localDir)
Fetch a remote directory from the remote host.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteDirPath |
String: The remote path where to find the directory. |
localDir |
File: The local directory where to put the pulled files. |
| Returns |
boolean |
True if successful, False otherwise |
fetchRemoteDir
public static File fetchRemoteDir (String host,
String user,
File sshPrivateKey,
IRunUtil runUtil,
long timeout,
String remoteDirPath)
Fetch a remote directory from the remote host.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteDirPath |
String: The remote path where to find the directory. |
| Returns |
File |
The pulled directory File if successful, null otherwise |
fetchRemoteDir
public static File fetchRemoteDir (String host,
String user,
File sshPrivateKey,
List<String> scpArgs,
IRunUtil runUtil,
long timeout,
String remoteDirPath)
Fetch a remote directory from the remote host.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
scpArgs |
List: extra args to be passed to the scp command |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteDirPath |
String: The remote path where to find the directory. |
| Returns |
File |
The pulled directory File if successful, null otherwise |
fetchRemoteDir
public static boolean fetchRemoteDir (String host,
String user,
File sshPrivateKey,
List<String> scpArgs,
IRunUtil runUtil,
long timeout,
String remoteDirPath,
File localDir)
Fetch a remote directory from the remote host.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
scpArgs |
List: extra args to be passed to the scp command |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteDirPath |
String: The remote path where to find the directory. |
localDir |
File: The local directory where to put the pulled files. |
| Returns |
boolean |
True if successful, False otherwise |
fetchRemoteFile
public static File fetchRemoteFile (String host,
String user,
File sshPrivateKey,
List<String> scpArgs,
IRunUtil runUtil,
long timeout,
String remoteFilePath)
Fetch a remote file in the container instance.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
scpArgs |
List: extra args to be passed to the scp command |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteFilePath |
String: The remote path where to find the file. |
| Returns |
File |
The pulled filed if successful, null otherwise |
fetchRemoteFile
public static File fetchRemoteFile (String host,
String user,
File sshPrivateKey,
IRunUtil runUtil,
long timeout,
String remoteFilePath)
Fetch a remote file in the container instance.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteFilePath |
String: The remote path where to find the file. |
| Returns |
File |
The pulled filed if successful, null otherwise |
fetchRemoteFile
public static boolean fetchRemoteFile (String host,
String user,
File sshPrivateKey,
List<String> scpArgs,
IRunUtil runUtil,
long timeout,
String remoteFilePath,
File localFile)
Fetch a remote file in the device or container instance.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
scpArgs |
List: extra args to be passed to the scp command |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteFilePath |
String: The remote path where to find the file. |
localFile |
File: The local File where the remote file will be pulled |
| Returns |
boolean |
True if successful, False otherwise |
fetchRemoteFile
public static boolean fetchRemoteFile (String host,
String user,
File sshPrivateKey,
IRunUtil runUtil,
long timeout,
String remoteFilePath,
File localFile)
Fetch a remote file in the device or container instance.
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File: The file containing the ssh key to use. |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteFilePath |
String: The remote path where to find the file. |
localFile |
File: The local File where the remote file will be pulled |
| Returns |
boolean |
True if successful, False otherwise |
pushFileToRemote
public static boolean pushFileToRemote (String host,
String user,
File sshPrivateKey,
List<String> scpArgs,
IRunUtil runUtil,
long timeout,
String remoteFilePath,
File localFile)
Push a File from the local host to the remote instance
| Parameters |
host |
String: The remote host. |
user |
String: The user on the remote host |
sshPrivateKey |
File |
scpArgs |
List: extra args to be passed to the scp command |
runUtil |
IRunUtil: a IRunUtil to execute commands. |
timeout |
long: in millisecond for the fetch to complete |
remoteFilePath |
String: The remote path where to find the file. |
localFile |
File: The local File where the remote file will be pulled |
| Returns |
boolean |
True if successful, False otherwise |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-22 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-22 UTC."],[],[]]