Summary: Ctors | Methods | Inherited Methods | [Expand All]
public class

# FilterWriter

extends Object
implements AutoCloseable

java.lang.Object
↳ | com.pdftron.filters.FilterWriter

## Class Overview

FilterWriter is a utility class providing a convenient way to write data to an output filter (using Filter directly is not very intuitive). For example: `StdFile outfile=new StdFile("file.dat"), StdFile.e_write_mode); FilterWriter fwriter=new FilterWriter(outfile); byte[] buf=... fwriter.writeBuffer(buf); fwriter.flush();`

## Summary

Public Constructors
| FilterWriter() Instantiates a new filter writer.
| FilterWriter(Filter filter) Instantiates a new filter writer for specified Filter

Public Methods
long | __GetHandle()
void | attachFilter(Filter filter) Attaches a filter to the this FilterWriter.
void | close() Frees the native memory of the object.
long | count() Count number of bytes consumed since opening the filter or seek operation
void | destroy() Frees the native memory of the object.
void | flush() Forces any data remaining in the buffer to be written to input or output filter.
void | flushAll() Forces any data remaining in the filter chain to the source or destination.
Filter | getAttachedFilter() Get the attached filter.
void | seek(long offset, int origin) Set the position within the current stream.
long | tell() Reports the current read position in the stream relative to the stream origin.
long | writeBuffer(byte[] buf) Write buffer.
void | writeFilter(FilterReader reader) Write the entire input stream to the output stream (i.e.
void | writeInt(int num) Write an integer to the output stream.
void | writeLine(String line) Write out a null terminated 'line' followed by a end of line character default end of line character is carriage return.
void | writeString(String str) Write a string to the output stream.
void | writeUChar(byte ch) Write a single character to the output stream.

[Expand] Inherited Methods
From class java.lang.Object
boolean | equals(Object arg0)
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()
From interface java.lang.AutoCloseable
abstract void | close()

## Public Constructors

#### public FilterWriter ()

Instantiates a new filter writer.

##### Throws

PDFNetException |

#### public FilterWriter (Filter filter)

Instantiates a new filter writer for specified Filter

##### Parameters

filter | the filter

##### Throws

PDFNetException |

## Public Methods

#### public long __GetHandle ()

#### public void attachFilter (Filter filter)

Attaches a filter to the this FilterWriter.

##### Parameters

filter | the filter

##### Throws

PDFNetException |

#### public void close ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

##### Throws

PDFNetException |

#### public long count ()

Count number of bytes consumed since opening the filter or seek operation

##### Returns

- - the number of bytes consumed since opening the filter or since the last Seek operation.

##### Throws

PDFNetException |

#### public void destroy ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

##### Throws

PDFNetException |

#### public void flush ()

Forces any data remaining in the buffer to be written to input or output filter.

##### Throws

PDFNetException |

#### public void flushAll ()

Forces any data remaining in the filter chain to the source or destination.

##### Throws

PDFNetException |

#### public Filter getAttachedFilter ()

Get the attached filter.

##### Returns

- - The attached Filter or a NULL filter if no filter is attached.

##### Throws

PDFNetException |

#### public void seek (long offset, int origin)

Set the position within the current stream.

Note: - After each Seek() operation the number of consumed bytes (i.e. Count()) is set to 0.

##### Parameters

offset | - A byte offset relative to origin. If offset is negative, the new position will precede the position specified by origin by the number of bytes specified by offset. If offset is zero, the new position will be the position specified by origin. If offset is positive, the new position will follow the position specified by origin by the number of bytes specified by offset.
origin | - A value of type ReferencePos indicating the reference point used to obtain the new position

##### Throws

PDFNetException |

#### public long tell ()

Reports the current read position in the stream relative to the stream origin.

##### Returns

- - The current position in the stream

##### Throws

PDFNetException |

#### public long writeBuffer (byte[] buf)

Write buffer.

##### Parameters

buf | the buf

##### Returns

- - returns the number of bytes actually written to a stream. This number may less than buf_size if the stream is corrupted.

##### Throws

PDFNetException |

#### public void writeFilter (FilterReader reader)

Write the entire input stream to the output stream (i.e. to this FilterWriter).

##### Parameters

reader | A FilterReader attached to an input stream.

##### Throws

PDFNetException |

#### public void writeInt (int num)

Write an integer to the output stream.

##### Parameters

num | An integer to write to the output stream.

##### Throws

PDFNetException |

#### public void writeLine (String line)

Write out a null terminated 'line' followed by a end of line character default end of line character is carriage return.

##### Parameters

line | the line

##### Throws

PDFNetException |

#### public void writeString (String str)

Write a string to the output stream.

##### Parameters

str | A string to write to the output stream.

##### Throws

PDFNetException |

#### public void writeUChar (byte ch)

Write a single character to the output stream.

##### Parameters

ch | An unsigned character to write to the output stream.

##### Throws

PDFNetException |