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

# FilterReader

extends Object
implements AutoCloseable

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

## Class Overview

FilterReader is a utility class providing a convenient way to read data from an input filter (using Filter directly is not very intuitive). For example:

     StdFile file=new StdFile("my_stream.txt"), StdFile.e_read_mode );
       FilterReader reader=new FilterReader(file);
       while (reader.Read(...)) ...

## Summary

Public Constructors
| FilterReader() Instantiates a new filter reader.
| FilterReader(Filter filter) Instantiates a new filter reader for the specified Filter

Public Methods
long | __GetHandle()
void | attachFilter(Filter filter) Attaches a filter to the this FilterReader.
void | close() Frees the native memory of the object.
long | count() Count number of bytes consume since last seek opertion or opening filter
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.
int | get() Get the next character from stream
Filter | getAttachedFilter() Get the attached filter.
int | peek() Get the next character without extracting it
long | read(byte[] buf)
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.

[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 FilterReader ()

Instantiates a new filter reader.

##### Throws

PDFNetException |

#### public FilterReader (Filter filter)

Instantiates a new filter reader for the specified Filter

##### Parameters

filter | the filter

##### Throws

PDFNetException |

## Public Methods

#### public long __GetHandle ()

#### public void attachFilter (Filter filter)

Attaches a filter to the this FilterReader.

##### 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 consume since last seek opertion or opening filter

##### 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 int get ()

Get the next character from stream

##### Returns

- - the next character from the stream or EOF (-1) if the end of file is reached.

##### 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 int peek ()

Get the next character without extracting it

##### Returns

- - the next character without extracting it from the stream or or EOF (-1) if the end of file is reached.

##### Throws

PDFNetException |

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

##### Parameters

buf | the buffer to read

##### Returns

- - returns the number of bytes actually read and stored in buffer (buf), which may be less than buf.length if the end of the stream is encountered before reaching count.

##### 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 |