Java Randomness Test Suite

JRandTest at SourceForge

com.fasteasytrade.JRandTest.IO
Class FileRandomStream

java.lang.Object
  extended bycom.fasteasytrade.JRandTest.IO.FileRandomStream
All Implemented Interfaces:
RandomStream
Direct Known Subclasses:
FileAlgoRandomStream

public class FileRandomStream
extends Object
implements RandomStream

This class represents an encrypted or random source file. Data, bytes or int32, are read from file.

Author:
Zur Aougav

Field Summary
 int actualSize
           
 byte[] buffer
           
 int count
           
 int countLastRead
           
 String filename
           
(package private)  BufferedInputStream infile
           
 boolean open
           
 int SIZE
           
 
Constructor Summary
FileRandomStream()
           
FileRandomStream(String s)
           
 
Method Summary
 boolean closeInputStream()
          close the input stream.
 void finalize()
          Be sure to close input file at end of processing.
 String getFilename()
          get the file name to be processed. this file is the raw data to be read, or the input file processed by algorithm.
 boolean isOpen()
          check if RandomStream is open
 boolean openInputStream()
          open the input stream.
 byte readByte()
          read one byte from a file.
 int readInt()
          Processing is similar to readByte.
 long readLong()
          Processing is similar to readByte.
 void setFilename(String s)
          set file name to be processed. this file is the raw data to be read, or the input file processed by algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

open

public boolean open

infile

BufferedInputStream infile

filename

public String filename

count

public int count

SIZE

public int SIZE

countLastRead

public int countLastRead

actualSize

public int actualSize

buffer

public byte[] buffer
Constructor Detail

FileRandomStream

public FileRandomStream()

FileRandomStream

public FileRandomStream(String s)
Method Detail

getFilename

public String getFilename()
Description copied from interface: RandomStream
get the file name to be processed. this file is the raw data to be read, or the input file processed by algorithm.

Specified by:
getFilename in interface RandomStream
Returns:
string null if missing, else the filename from setFilename.
See Also:
RandomStream.getFilename()

setFilename

public void setFilename(String s)
Description copied from interface: RandomStream
set file name to be processed. this file is the raw data to be read, or the input file processed by algorithm.

Specified by:
setFilename in interface RandomStream
Returns:
true if open (still data in stream), else flase
See Also:
RandomStream.setFilename(java.lang.String)

isOpen

public boolean isOpen()
Description copied from interface: RandomStream
check if RandomStream is open

Specified by:
isOpen in interface RandomStream
Returns:
true if open (still data in stream), else flase
See Also:
RandomStream.isOpen()

openInputStream

public boolean openInputStream()
                        throws Exception
Description copied from interface: RandomStream
open the input stream.

Specified by:
openInputStream in interface RandomStream
Returns:
boolean true for success, else false.
Throws:
Exception - - Usually IOException.
See Also:
RandomStream.openInputStream()

closeInputStream

public boolean closeInputStream()
Description copied from interface: RandomStream
close the input stream.

Specified by:
closeInputStream in interface RandomStream
Returns:
boolean true for success, else false.
See Also:
RandomStream.closeInputStream()

readByte

public byte readByte()
              throws Exception
Description copied from interface: RandomStream
read one byte from a file.

first time ( if !isOpen() ) open file/stream, and return byte

at end of file close stream and returns -1

Specified by:
readByte in interface RandomStream
Returns:
byte read form stream, -1 if passed end of file
Throws:
Exception
See Also:
RandomStream.readByte()

readInt

public int readInt()
            throws Exception
Description copied from interface: RandomStream
Processing is similar to readByte.

Specified by:
readInt in interface RandomStream
Returns:
int (32 bits, 4 bytes) read form stream, -1 if passed end of file
Throws:
Exception
See Also:
RandomStream.readInt()

readLong

public long readLong()
              throws Exception
Description copied from interface: RandomStream
Processing is similar to readByte.

Specified by:
readLong in interface RandomStream
Returns:
long (64 bits, 8 bytes) read form stream, -1 if passed end of file
Throws:
Exception
See Also:
RandomStream.readLong()

finalize

public void finalize()
Be sure to close input file at end of processing.


Java Randomness Test Suite

JRandTest at SourceForge

JRandTest at SourceForge
Copyright © 2005 Zur Aougav. All Rights Reserved.