Package com.sun.mail.util

# Class TraceOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.sun.mail.util.TraceOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

public class TraceOutputStream extends FilterOutputStream
This class is a subclass of DataOutputStream that copies the data being written into the DataOutputStream into another output stream. This class is used here to provide a debug trace of the stuff thats being written out into the DataOutputStream.

Author:
  John Mani

## Field Summary

### Fields inherited from class java.io.FilterOutputStream

`out`

## Constructor Summary

Constructors
Constructor
Description
`TraceOutputStream(OutputStream out, MailLogger logger)`
Creates an output stream filter built on top of the specified underlying output stream.
`TraceOutputStream(OutputStream out, OutputStream traceOut)`
Creates an output stream filter built on top of the specified underlying output stream.

## Method Summary

Modifier and Type
Method
Description
`void`
`setQuote(boolean quote)`
Set quote mode.
`void`
`setTrace(boolean trace)`
Set the trace mode.
`void`
`write(byte[] b, int off, int len)`
Writes `b.length` bytes to this output stream.
`void`
`write(int b)`
Writes the specified `byte` to this output stream.

### Methods inherited from class java.io.FilterOutputStream

`close, flush, write`

### Methods inherited from class java.io.OutputStream

`nullOutputStream`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### TraceOutputStream

public TraceOutputStream(OutputStream out, MailLogger logger)
Creates an output stream filter built on top of the specified underlying output stream.

Parameters:
  `out` - the underlying output stream.
  `logger` - log trace here

### TraceOutputStream

public TraceOutputStream(OutputStream out, OutputStream traceOut)
Creates an output stream filter built on top of the specified underlying output stream.

Parameters:
  `out` - the underlying output stream.
  `traceOut` - the trace stream.

## Method Details

### setTrace

public void setTrace(boolean trace)
Set the trace mode.

Parameters:
  `trace` - the trace mode

### setQuote

public void setQuote(boolean quote)
Set quote mode.

Parameters:
  `quote` - the quote mode

### write

public void write(int b) throws IOException
Writes the specified `byte` to this output stream. Writes out the byte into the trace stream if the trace mode is `true`

Overrides:
  `write` in class `FilterOutputStream`
Parameters:
  `b` - the byte to write
Throws:
  `IOException` - for I/O errors

### write

public void write(byte[] b, int off, int len) throws IOException
Writes `b.length` bytes to this output stream. Writes out the bytes into the trace stream if the trace mode is `true`

Overrides:
  `write` in class `FilterOutputStream`
Parameters:
  `b` - bytes to write
  `off` - offset in array
  `len` - number of bytes to write
Throws:
  `IOException` - for I/O errors