為配合主幹穩定開發模型,並確保生態系統的平台穩定性,我們將自 2026 年起,在第 2 季和第 4 季將原始碼發布至 AOSP。如要建構及貢獻 AOSP,請使用 android-latest-release。android-latest-release 資訊清單分支版本一律會參照推送至 Android 開放原始碼計畫的最新版本。詳情請參閱「Android 開放原始碼計畫變更」。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
TarUtil
public
class
TarUtil
extends Object
| java.lang.Object
|
| ↳ |
com.android.tradefed.util.TarUtil
|
用於操作 tar 檔案的公用程式。這個程式庫會包裝 commons-compress,以提供 tar 支援。
摘要
公用方法 |
static
void
|
extractAndLog(ITestLogger listener, File targzFile, String baseName)
協助擷取 tar.gz 檔案及其內容,並記錄給記者
|
static
File
|
extractTarGzipToTemp(File targzFile, String nameHint)
將 tar.gz 檔案解壓縮至暫時目錄。
|
static
File
|
gzip(File inputFile)
Utility function to gzip (.gz) a file.
|
static
boolean
|
isGzip(File file)
判斷檔案是否為 gzip。
|
static
File
|
unGzip(File inputFile, File outputDir)
解壓縮檔案:tar.gz 或 tgz 檔案會變成 tar 檔案。
|
static
List<File>
|
unTar(File inputFile, File outputDir, Collection<String> fileNames)
將 tar 檔案解壓縮至目錄。
|
static
List<File>
|
unTar(File inputFile, File outputDir)
將 tar 檔案解壓縮至目錄。
|
公用建構函式
TarUtil
public TarUtil ()
公用方法
extractAndLog
public static void extractAndLog (ITestLogger listener,
File targzFile,
String baseName)
協助程式,可將 tar.gz 檔案及其內容擷取並記錄給記者
| 參數 |
listener |
ITestLogger:記錄檔案的 ITestLogger。 |
targzFile |
File:需要內容記錄的 tar.gz File。 |
baseName |
String:檔案所在的基底名稱。 |
| 擲回 |
FileNotFoundException |
|
IOException |
|
public static File extractTarGzipToTemp (File targzFile,
String nameHint)
將 tar.gz 檔案解壓縮至暫存目錄。
| 參數 |
targzFile |
File:要解壓縮的 tar.gz 檔案。 |
nameHint |
String:臨時目錄的前置字串。 |
| 擲回 |
|
java.io.FileNotFoundException |
|
java.io.IOException |
FileNotFoundException |
|
IOException |
|
gzip
public static File gzip (File inputFile)
將檔案壓縮為 gzip (.gz) 格式的公用程式函式,.gz 副檔名會加到基本檔案名稱。
| 參數 |
inputFile |
File:要以 gzip 壓縮的 File。 |
| 擲回 |
|
java.io.IOException |
IOException |
|
isGzip
public static boolean isGzip (File file)
判斷檔案是否為 gzip。
unGzip
public static File unGzip (File inputFile,
File outputDir)
解壓縮檔案:tar.gz 或 tgz 檔案會變成 tar 檔案。
| 參數 |
inputFile |
File:要解壓縮的 File |
outputDir |
File:要放置解壓縮檔案的目錄。 |
| 傳回 |
File |
指向未經 Gzip 壓縮檔案的 File。 |
| 擲回 |
|
java.io.FileNotFoundException |
|
java.io.IOException |
FileNotFoundException |
|
IOException |
|
unTar
public static List<File> unTar (File inputFile,
File outputDir,
Collection<String> fileNames)
將 tar 檔案解壓縮至目錄。tar.gz 檔案必須先 unGzip(File,File)。
| 參數 |
inputFile |
File:要解壓縮的 tar 檔案 |
outputDir |
File:要放置解壓縮檔案的目錄。 |
fileNames |
Collection:要從 tar 檔案解壓縮的檔案。 |
| 擲回 |
|
java.io.FileNotFoundException |
|
java.io.IOException |
FileNotFoundException |
|
IOException |
|
unTar
public static List<File> unTar (File inputFile,
File outputDir)
將 tar 檔案解壓縮至目錄。tar.gz 檔案必須先 unGzip(File,File)。
| 參數 |
inputFile |
File:要解壓縮的 tar 檔案 |
outputDir |
File:要放置解壓縮檔案的目錄。 |
| 擲回 |
|
java.io.FileNotFoundException |
|
java.io.IOException |
FileNotFoundException |
|
IOException |
|
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2026-06-22 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-06-22 (世界標準時間)。"],[],[]]