StringEscapeUtils

public class StringEscapeUtils
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.StringEscapeUtils


用于针对特定格式转义字符串的实用程序类。 添加了用于转义传递给 Android Shell 的字符串的方法。

摘要

公共构造函数

StringEscapeUtils()

公共方法

static String escapeShell(String str)

对 String 进行转义,以便在 Android shell 命令中使用。

static paramsToArgs( params)

通过选项将提供的参数转换为命令行参数,以便传递给子进程

此方法将对列表中的每个参数执行简单的通用转义。

公共构造函数

StringEscapeUtils

public StringEscapeUtils ()

公共方法

escapeShell

public static String escapeShell (String str)

对 String 进行转义,以便在 Android shell 命令中使用。

参数
str String:要转义的 String

返回
String Android shell 转义了 String

paramsToArgs

public static  paramsToArgs ( params)

通过选项将提供的参数转换为命令行参数,以便传递给子进程

此方法将对列表中的每个参数执行简单的通用转义。它会将 \[char] 替换为 [char]。例如,\" 会转换为 "。这样,经过 QuotationAwareTokenizer 解析后,带有转义双引号的字符串仍会保持字符串形式。如果没有此标志,QuotationAwareTokenizer 会将字符串拆分为多个部分(如果字符串中包含空格)。

参数
params :通过选项接收的参数

返回
表示命令行参数的字符串列表