Advertisement
Guest User

Untitled

a guest
Sep 25th, 2020
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import java.rmi.*;
  2. import java.net.*;
  3. import java.io.*;
  4. import java.util.*;
  5. public class Client implements Runnable{
  6. private Scanner scanner;
  7. public static void main(String args[]) throws Exception {
  8. new Client().run();
  9. }
  10. public void run(){
  11. try{
  12. String host="localhost";
  13. System.out.println("Client running");
  14. System.out.println("Enter path: ");
  15. scanner = new Scanner(System.in);
  16. String directory=scanner.nextLine();
  17. long start = System.currentTimeMillis();
  18. ClientInterface remobj=(ClientInterface)Naming.lookup("rmi://"+host+"/ClientInterface");
  19. final File folder = new File(directory);
  20. List<String> result = new ArrayList<>();
  21. List<String> res=remobj.search(".*\\.*", folder, result);
  22. //for (String s : res) {
  23. // System.out.println("File:"+s);
  24. //}
  25. //C:\Program Files\Microsoft Office 15
  26. //C:\Program Files\R
  27. System.out.println("Count files in directory "+directory+": " + res.size());
  28. long end = System.currentTimeMillis();
  29. float sec = (end - start) / 1000F;
  30. System.out.println(sec + " seconds");
  31. }
  32. catch(RemoteException re){
  33. re.printStackTrace();
  34. }
  35. catch(NotBoundException nbe){
  36. nbe.printStackTrace();
  37. }
  38. catch(MalformedURLException mfe){
  39. mfe.printStackTrace();
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement