ResourceUtil

public class ResourceUtil
extends Object

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


Utility for reading configuration resources.

Summary

Public constructors

ResourceUtil()

Public methods

static boolean extractResourceAsFile(String resource, File output)

DEPRECATED: Use extractResourceToFile Extracts a given resource to an output file.

static void extractResourceToFile(String resource, File output)

Extracts a given resource to an output file.

static boolean extractResourceWithAltAsFile(String resource, String altResourcePath, File output)

Extracts a given resource to an output file with fallback alternative path.

static Map<String, String> readConfigurationFromFile(File propertyFile)

Read a property configuration from a file.

static Map<String, String> readConfigurationFromResource(String resource)

Read a property configuration from the resources.

static Map<String, String> readConfigurationFromStream(InputStream propertyStream)

Read a property configuration from a stream.

Public constructors

ResourceUtil

public ResourceUtil ()

Public methods

extractResourceAsFile

public static boolean extractResourceAsFile (String resource, 
                File output)

DEPRECATED: Use extractResourceToFile Extracts a given resource to an output file.

Parameters
resource String

output File

Returns
boolean

extractResourceToFile

public static void extractResourceToFile (String resource, 
                File output)

Extracts a given resource to an output file.

Parameters
resource String

output File

Throws
IOException

extractResourceWithAltAsFile

public static boolean extractResourceWithAltAsFile (String resource, 
                String altResourcePath, 
                File output)

Extracts a given resource to an output file with fallback alternative path. Returns false if it fails.

Parameters
resource String

altResourcePath String

output File

Returns
boolean

readConfigurationFromFile

public static Map<String, String> readConfigurationFromFile (File propertyFile)

Read a property configuration from a file. Configuration must follow a "key=value" or "key:value" format. Method is safe and will return an empty map in case of error.

Parameters
propertyFile File: The path of the resource to read.

Returns
Map<String, String> a Map of the loaded resources.

See also:

readConfigurationFromResource

public static Map<String, String> readConfigurationFromResource (String resource)

Read a property configuration from the resources. Configuration must follow a "key=value" or "key:value" format. Method is safe and will return an empty map in case of error.

Parameters
resource String: The path of the resource to read.

Returns
Map<String, String> a Map of the loaded resources.

See also:

readConfigurationFromStream

public static Map<String, String> readConfigurationFromStream (InputStream propertyStream)

Read a property configuration from a stream. Configuration must follow a "key=value" or "key:value" format. Method is safe and will return an empty map in case of error.

Parameters
propertyStream InputStream: The path of the resource to read.

Returns
Map<String, String> a Map of the loaded resources.

See also: