com.pega.pegarules.pub.util
Class PRReader

java.lang.Object
  extended by java.io.Reader
      extended by com.pega.pegarules.pub.util.PRReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class PRReader
extends java.io.Reader

PRReader is a thin wrapper around java.io.Reader that ALWAYS uses an encoding instead of relying on the platform default.

Version:
$Revision: 2 $
Author:
dassu

Field Summary
static java.lang.String COPYRIGHT
          copyright
static java.lang.String VERSION
          version id
 
Constructor Summary
PRReader(java.io.File aFile, java.lang.String aEncoding)
          Deprecated.  
PRReader(java.io.InputStream aInStream, java.lang.String aEncoding)
          Creates a new PRReader from the specified aInStream.
PRReader(PRFile aFile, java.lang.String aEncoding)
           
PRReader(java.lang.String aFileSpec, java.lang.String aEncoding)
          Creates a new PRReader from the specified aFilePathName
 
Method Summary
 long byteLength()
          Returns the number of bytes (not characters) in the underlying stream that will be processed and returned by this reader.
 void close()
          Close the stream.
 int read(char[] aCbuf, int aOff, int aLen)
          Read characters into a portion of an array.
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
copyright

See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
version id

Constructor Detail

PRReader

public PRReader(java.io.InputStream aInStream,
                java.lang.String aEncoding)
         throws java.io.IOException,
                java.io.UnsupportedEncodingException
Creates a new PRReader from the specified aInStream.

Parameters:
aInStream - a InputStream
aEncoding - The encoding type to use. See PRFileUtil.ENCODING_* types
Throws:
java.io.IOException
java.io.UnsupportedEncodingException

PRReader

public PRReader(java.io.File aFile,
                java.lang.String aEncoding)
         throws java.io.FileNotFoundException,
                java.io.UnsupportedEncodingException,
                java.io.IOException
Deprecated. 

Creates a new PRReader from the specified File.

Parameters:
aFile - a File
aEncoding - The encoding type to use. See PRFileUtil.ENCODING_* types
Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException
java.io.IOException

PRReader

public PRReader(PRFile aFile,
                java.lang.String aEncoding)
         throws java.io.FileNotFoundException,
                java.io.UnsupportedEncodingException,
                java.io.IOException
Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException
java.io.IOException

PRReader

public PRReader(java.lang.String aFileSpec,
                java.lang.String aEncoding)
         throws java.io.FileNotFoundException,
                java.io.UnsupportedEncodingException,
                java.io.IOException
Creates a new PRReader from the specified aFilePathName

Parameters:
aFileSpec - The URL specification for the file
aEncoding - The encoding type to use. See PRFileUtil.ENCODING_* types
Throws:
java.io.FileNotFoundException
java.io.UnsupportedEncodingException
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Close the stream. Behaviour is identical to InputStreamReader.close()

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException
See Also:
InputStreamReader.close()

read

public int read(char[] aCbuf,
                int aOff,
                int aLen)
         throws java.io.IOException
Read characters into a portion of an array. Identical to InputStreamReader.read(char[], int, int)

Specified by:
read in class java.io.Reader
Parameters:
aCbuf - Destination buffer
aOff - Offset at which to start storing characters
aLen - Maximum number of characters to read
Returns:
The number of characters read, or -1 if the end of the stream has been reached
Throws:
java.io.IOException - If an I/O error occurs
See Also:
InputStreamReader.read(char[], int, int)

byteLength

public long byteLength()
Returns the number of bytes (not characters) in the underlying stream that will be processed and returned by this reader. (Works best with files)

Returns:
file size minus the size of the byte order mark that is removed internally


Copyright © 2012 Pegasystems Inc. All Rights Reserved.