KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > rmi > server > RmiInputStreamServerSide


1 package com.daffodilwoods.rmi.server;
2
3 import com.daffodilwoods.rmi.interfaces.*;
4 import com.daffodilwoods.database.resource.*;
5 import java.rmi.server.UnicastRemoteObject JavaDoc;
6 import java.io.*;
7 import java.rmi.RemoteException JavaDoc;
8 public class RmiInputStreamServerSide extends UnicastRemoteObject JavaDoc implements _RmiInputStream {
9   InputStream inputStream;
10   public RmiInputStreamServerSide(InputStream inputStream) throws RemoteException JavaDoc {
11     this.inputStream = inputStream;
12   }
13
14   public long skip(long n) throws IOException, RemoteException JavaDoc {
15     return inputStream.skip(n);
16   }
17
18   public int available() throws IOException, RemoteException JavaDoc {
19     return inputStream.available();
20   }
21
22   public void close() throws IOException, RemoteException JavaDoc {
23     inputStream.close();
24   }
25
26   public void mark(int readlimit) throws RemoteException JavaDoc {
27       inputStream.mark(readlimit);
28   }
29
30   public void reset() throws IOException, RemoteException JavaDoc {
31       inputStream.reset();
32   }
33
34   public boolean markSupported() throws RemoteException JavaDoc {
35       return inputStream.markSupported();
36   }
37
38    public byte[] getBytes(int off, int len) throws RemoteException JavaDoc {
39       try {
40          byte[] b = new byte[len];
41          int i = inputStream.read(b,0,len);
42          if(i<0)
43             return null;
44          byte[] b1 = new byte[i];
45          System.arraycopy(b,0,b1,0,i);
46          return b1;
47
48       } catch (java.io.IOException JavaDoc e ) {
49             throw new RemoteException JavaDoc(e.getMessage());
50       }
51    }
52 }
53
Popular Tags