Back to the RMI Plug-in for Eclipse

demo.rmi.filesystem.server
Class RemoteInputStreamImpl

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FileInputStream
          extended by demo.rmi.filesystem.server.RemoteInputStreamImpl
All Implemented Interfaces:
IRemoteInputStream, Closeable, Remote

public class RemoteInputStreamImpl
extends FileInputStream
implements IRemoteInputStream

Implementation of a remote input stream. It is created by the server using a local file as an argument. This class extends FileInputStream only as a convenience, we could extend UnicastRemoteObject and hold a reference to the FileInputStream in a field. Since RemoteException is a subclass of IOException the method declarations are compatible with their "super" implementations. However, all methods must catch the IOException returned by the super implementation and wrap it with a RemoteException.

Author:
Genady Beryozkin, rmi-info@genady.net
See Also:
IRemoteFile.getInputStream()

Constructor Summary
RemoteInputStreamImpl(File file)
          Create a new RemoteInputStream that reads from a local (server) file.
 
Method Summary
 int available()
           
 void close()
           
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
          Read a single byte from the stream.
 byte[] read(int count)
          Read count bytes from the stream.
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.io.FileInputStream
finalize, getChannel, getFD, read, read
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteInputStreamImpl

public RemoteInputStreamImpl(File file)
                      throws RemoteException,
                             FileNotFoundException
Create a new RemoteInputStream that reads from a local (server) file.

Throws:
RemoteException
FileNotFoundException
See Also:
IRemoteFile.getInputStream()
Method Detail

available

public int available()
              throws RemoteException
Specified by:
available in interface IRemoteInputStream
Overrides:
available in class FileInputStream
Throws:
RemoteException
See Also:
InputStream.available()

close

public void close()
           throws RemoteException
Specified by:
close in interface IRemoteInputStream
Specified by:
close in interface Closeable
Overrides:
close in class FileInputStream
Throws:
RemoteException
See Also:
InputStream.close()

mark

public void mark(int readlimit)
Specified by:
mark in interface IRemoteInputStream
Overrides:
mark in class InputStream
See Also:
InputStream.mark(int)

markSupported

public boolean markSupported()
Specified by:
markSupported in interface IRemoteInputStream
Overrides:
markSupported in class InputStream
See Also:
InputStream.markSupported()

read

public int read()
         throws RemoteException
Description copied from interface: IRemoteInputStream
Read a single byte from the stream. Returns -1 on EOF.

Specified by:
read in interface IRemoteInputStream
Overrides:
read in class FileInputStream
Throws:
RemoteException
See Also:
InputStream.read()

read

public byte[] read(int count)
            throws RemoteException
Description copied from interface: IRemoteInputStream
Read count bytes from the stream. We can't have the same signature as InputStream.read(byte[], int, int) because if the array is an argument it won't be copied back to the client.

Specified by:
read in interface IRemoteInputStream
Parameters:
count - the maximum number of bytes to read.
Returns:
the data that was read or null if EOF reached.
Throws:
RemoteException

reset

public void reset()
           throws RemoteException
Specified by:
reset in interface IRemoteInputStream
Overrides:
reset in class InputStream
Throws:
RemoteException
See Also:
InputStream.reset()

skip

public long skip(long n)
          throws RemoteException
Specified by:
skip in interface IRemoteInputStream
Overrides:
skip in class FileInputStream
Throws:
RemoteException
See Also:
InputStream.skip(long)

Back to the RMI Plug-in for Eclipse


© 2002-12 Genady Beryozkin, rmi-info@genady.net. Read our Privacy policy. Hosted on RimuHosting. Visit Javalobby.