-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImplementation_class.java
50 lines (46 loc) · 1.08 KB
/
Implementation_class.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.rmi.*;
import java.rmi.server.*;
import java.io.*;
//Remote Implementation class
public class Implementation_class extends UnicastRemoteObject implements Remote_interface {
String path;
public String[] filename(String path) throws RemoteException
{
System.out.println("###remote method###");
File file=new File(path);
this.path=path;
File[] files=file.listFiles();
String str="";
for(File i : files) {
String name=i.getName();
if(i.isFile()) {
str=str+name+":";
}
}
return str.split(":");
}
public byte[] filedata(String filename) throws RemoteException
{
byte[] buffer=null;
try {
System.out.println("###remote method2###");
String fullpath=path+"/"+filename;
FileInputStream fis=new FileInputStream(fullpath);
buffer=new byte[fis.available()];
int index=0;
while(true) {
int var=fis.read();
if(var==-1) break;
buffer[index]=(byte)var;
index++;
}
}
catch(Throwable t) {
System.out.println("error in Implementation_class "+t);
}
return buffer;
}
public Implementation_class() throws RemoteException
{
}
}