Package com.rtfparserkit.parser
Class RtfStringSource
- java.lang.Object
-
- com.rtfparserkit.parser.RtfStringSource
-
- All Implemented Interfaces:
IRtfSource
public class RtfStringSource extends java.lang.Object implements IRtfSource
This is a hack... as a convenience it allows RTF data held in a string to be parsed. The reason it's a hack is that RTF commands are used to manage character encoding, and it's unlikely that the caller handled this when they read the RTF in to the string from its original source. It is also possible for an RTF file to contain raw binary data, which this class will definitely not deal with. Having said all of that, in the vast majority of cases this approach will work fine. It's also more efficient than creating an InputStream from a String - which usually involves duplicating byte arrays.
-
-
Constructor Summary
Constructors Constructor Description RtfStringSource(java.lang.String data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intread()Read a single byte.intread(byte[] b)Read enough bytes to fill the array.voidunread(int c)Push back a single byte to allow it to be read again by the parser.
-
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionDescription copied from interface:IRtfSourceRead a single byte.- Specified by:
readin interfaceIRtfSource- Throws:
java.io.IOException
-
unread
public void unread(int c) throws java.io.IOExceptionDescription copied from interface:IRtfSourcePush back a single byte to allow it to be read again by the parser.- Specified by:
unreadin interfaceIRtfSource- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOExceptionDescription copied from interface:IRtfSourceRead enough bytes to fill the array.- Specified by:
readin interfaceIRtfSource- Throws:
java.io.IOException
-
-