-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient1.java
More file actions
40 lines (39 loc) · 1.45 KB
/
Client1.java
File metadata and controls
40 lines (39 loc) · 1.45 KB
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
import javax.swing.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.ArrayList;
public class Client1 {
public static void main(String[] args) throws
NotBoundException, MalformedURLException,
RemoteException, FileNotFoundException, IOException {
System.out.println("Client Started --> ");
String filename = "rights.txt";
String filePath = "D:\\Haresh729";
ArrayList<String> data = new ArrayList<String>();
RemoteInterface1 FileInterface = (RemoteInterface1)Naming.lookup("rmi://192.168.1.205:6002/Servant1");
if (FileInterface.CheckAvailability(filename)) {
data = FileInterface.DownloadFiledata();
}
if (data != null) {
String finalPath = filePath.concat(filename);
File file = new File(filePath);
file.createNewFile();
if (file.exists()) {
if (file.canRead()) {
FileWriter writer = new FileWriter(finalPath, true);
for (String line : data) {
writer.write(line);
}
System.out.println("Download Complete --> ");
writer.close();
}
}
}
}
}