Copyright © 1998 T. H. Merrett

Class FileClient

public  class  java.lang.FileClient
{
        // Constructors
    public FileClient(HostClient host, String filePath, String ranSeq, int blksize);  §FileClient

        // Methods
    public void close();  §close
    public int length();  §length
    public int read();  §read1
    public int read(byte[] b, int len);  §read2
    public boolean readBoolean();  §readBoolean
    public byte readByte();  §readByte
    public char readChar();  §readChar
    public double readDouble();  §readDouble
    public float readFloat();  §readFloat
    public int readFully(byte[] b);  §readFully1
    public int readFully(byte[] b, int off, int len);  §readFully2
    public int readInt();  §readInt
    public long readLong();  §readLong
    public String readLine();  §readLine
    public short readShort();  §readShort
    public String readUTF();  §readUTF
    public void seek(long pos);  §seek
}
This class is a collection of methods corresponding to the DataInputStream and RandomAccessFile methods which send appropriate syntax to FileServer, receive the results and convert them to the appropriate types. It manages a single file for a specific HostClient.


Constructors

FileClient

public FileClient(HostClient host, String filePath, String ranSeq, int blksize)
Constructs a newly allocated FileClient object for the specified file on the HostClient object.
Parameters:
host - the HostClient object for the host
filePath - the directory path, within /course/cs420/data/, for the file to be used
ranSeq - either "RAN" for RandomAccessFile or "SEQ"
blksize - the blocksize for the SEQuential file
Throws:
IOException (I-§2.29)
If an I/O error occurs.

Methods

close

public void close()
Closes the file (SEQ only).

length

public int length()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The number of bytes in the file (RAN only).

read

public int read()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The (integer) value of one byte read (SEQ and RAN).

read

public int read()
Parameters:
b - output: the byte array containing the result
len - the number of bytes requested to be read
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The number of bytes actually read (SEQ and RAN).

readBoolean

public boolean readBoolean()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the boolean read (SEQ and RAN).

readByte

public byte readByte()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the byte read (SEQ and RAN).

readChar

public char readChar()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the char read (SEQ and RAN).

readDouble

public double readDouble()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the double read (SEQ and RAN).

readFloat

public float readFloat()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the float read (SEQ and RAN).

readFully

public int readFully(byte[] b)
Parameters:
b - output: the byte array containing the result
Throws:
EOFException (I-§2.24)
If this input stream has reached the end.
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The number of bytes actually read (SEQ and RAN).

readFully

public int readFully(byte[] b, int off, int len)
Parameters:
b - output: the byte array containing the result
off - the offset in the file of the first byte to be read
len - the number of bytes requested to be read
Throws:
EOFException (I-§2.24)
If this input stream has reached the end.
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The number of bytes actually read (SEQ and RAN).

readInt

public int readInt()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the int read (SEQ and RAN).

readLong

public long readLong()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the long read (SEQ and RAN).

readLine

public String readLine()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the line read (SEQ only).

readShort

public short readShort()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the short read (SEQ and RAN).

readUTF

public String readUTF()
Throws:
IOException (I-§2.29)
If an I/O error occurs.
Returns:
The value of the UTF string read (SEQ and RAN).

seek

public void seek(long pos)
Parameters:
pos - the byte position in the file where the next I/O will start (RAN only).
Throws:
IOException (I-§2.29)
If an I/O error occurs.

Java API Document (HTML written by T. H. Merrett on August 26, 1998)
All rights reserved
Please send any comments or corrections to tim@cs.mcgill.ca