FileInputStreamSource

public class FileInputStreamSource
extends Object implements Closeable, InputStreamSource

java.lang.Object
   ↳ com.android.tradefed.result.FileInputStreamSource


A InputStreamSource that takes an input file.

Caller is responsible for deleting the file

Summary

Public constructors

FileInputStreamSource(File file)
FileInputStreamSource(File file, boolean deleteFileOnCancel)

Ctor

Public methods

void cancel()

Do any required cleanup on the source of the InputStream.

void cleanFile()

Convenience method to delete the file associated with the FileInputStreamSource.

void close()
InputStream createInputStream()

Return a new clone of the InputStream, so that the caller can read the stream from the beginning.

long size()

Return the size in bytes of the source data.

Public constructors

FileInputStreamSource

FileInputStreamSource (File file)

Parameters
file File

FileInputStreamSource

FileInputStreamSource (File file, 
                boolean deleteFileOnCancel)

Ctor

Parameters
file File: File containing the data to be streamed
deleteFileOnCancel boolean: if true, the file associated will be deleted when cancel() is called

Public methods

cancel

void cancel ()

Do any required cleanup on the source of the InputStream. Calling this method essentially invalidates this InputStreamSource.

cleanFile

void cleanFile ()

Convenience method to delete the file associated with the FileInputStreamSource. Not safe.

close

void close ()

createInputStream

InputStream createInputStream ()

Return a new clone of the InputStream, so that the caller can read the stream from the beginning. Each invocation of this method (until cancel() is called) will return an identically-behaving InputStream -- the same contents will be returned.

Returns
InputStream An InputStream that the caller can use to read the data source from the beginning. May return null if this InputStreamSource has been invalidated by a prior call to cancel(), or if a new InputStream cannot be created for some other reason.

size

long size ()

Return the size in bytes of the source data.

Returns
long