public class

SizeLimitedOutputStream

extends OutputStream
java.lang.Object
   ↳ java.io.OutputStream
     ↳ com.android.tradefed.util.SizeLimitedOutputStream

Class Overview

A thread safe file backed OutputStream that limits the maximum amount of data that can be written.

This is implemented by keeping a circular list of Files of fixed size. Once a File has reached a certain size, the class jumps to use the next File in the list. If the next File is non empty, it is deleted, and a new file created.

Summary

Public Constructors
SizeLimitedOutputStream(long maxDataSize, int numFiles, String tempFilePrefix, String tempFileSuffix)
SizeLimitedOutputStream(long maxDataSize, String tempFilePrefix, String tempFileSuffix)
Creates a SizeLimitedOutputStream with default number of backing files.
Public Methods
void close()
Closes the write stream
void delete()
Delete all accumulated data.
synchronized void flush()
synchronized InputStream getData()
Gets the collected output as a InputStream.
synchronized void write(int data)
[Expand]
Inherited Methods
From class java.io.OutputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.Flushable

Public Constructors

public SizeLimitedOutputStream (long maxDataSize, int numFiles, String tempFilePrefix, String tempFileSuffix)

Parameters
maxDataSize the approximate max size in bytes to keep in the output stream
numFiles the max number of backing files to use to store data. Higher values will mean max data kept will be close to maxDataSize, but with a possible performance penalty.
tempFilePrefix prefix to use for temporary files
tempFileSuffix suffix to use for temporary files

public SizeLimitedOutputStream (long maxDataSize, String tempFilePrefix, String tempFileSuffix)

Creates a SizeLimitedOutputStream with default number of backing files.

Parameters
maxDataSize the approximate max size to keep in the output stream
tempFilePrefix prefix to use for temporary files
tempFileSuffix suffix to use for temporary files

Public Methods

public void close ()

Closes the write stream

public void delete ()

Delete all accumulated data.

public synchronized void flush ()

public synchronized InputStream getData ()

Gets the collected output as a InputStream.

It is recommended to buffer returned stream before using.

Returns
Throws
IOException

public synchronized void write (int data)

Throws
IOException