Back to the RMI Plug-in for Eclipse

demo.rmi.filesystem.client
Class FileSystemClient

java.lang.Object
  extended by demo.rmi.filesystem.client.FileSystemClient

public class FileSystemClient
extends Object

A sample file system client. It performs several manipulations on the remote file system. The client can be used with Windows or Unix based server, and it tries to locate the WINDOWS directory (or the /usr directory) on the server and work inside that directory. It is possible to operate on the entire file system, but then this example would take many minutes (~20 mins) to complete, depending on the number of files on the server. See the methods of this class for more information.

Author:
Genady Beryozkin, rmi-info@genady.net

Nested Class Summary
private static class FileSystemClient.SemiPalindromeFilter
          A filter that accepts what can be called a "semi-palindromic" file names.
 
Constructor Summary
FileSystemClient()
           
 
Method Summary
private static void countFilesAndDirs(IRemoteFile root)
          Count the number of files and directories under the provided root.
private static void findSemiPalindromes(IRemoteFile root, boolean export)
          Find all semi-palindromic file names.
private static void findWindowsDlls(IRemoteFile root)
          Scan the directory tree for files that end with .dll.
private static IRemoteFile getSampleOSDir(IRemoteFileSystem fs)
          Return the "working" directory that will be used as a root for all other methods.
static void main(String[] args)
           
private static void printFirstLineOf(IRemoteFile file)
          Print the first line of a remote file.
private static void printTextFiles(IRemoteFile root)
          Print the first line of remote text files.
private static void scanByExtension(IRemoteFile parent, String ext)
          The actual implementation of findWindowsDlls(IRemoteFile)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemClient

public FileSystemClient()
Method Detail

countFilesAndDirs

private static void countFilesAndDirs(IRemoteFile root)
                               throws RemoteException
Count the number of files and directories under the provided root.

Parameters:
root - the root at which the scan is performed.
Throws:
RemoteException

findSemiPalindromes

private static void findSemiPalindromes(IRemoteFile root,
                                        boolean export)
                                 throws RemoteException
Find all semi-palindromic file names. It is of course possible to search for "full" palindromes but they are rare as filenames. If export is true, the method will export the file filter object and the server will make callbacks to our JVM when it calls FileSystemClient.SemiPalindromeFilter.accept(IRemoteFile, String). If export is false, then the FileSystemClient.SemiPalindromeFilter class itself (and not it's stub) will be loaded by the server and executed on the server.

Parameters:
root -
export -
Throws:
RemoteException

findWindowsDlls

private static void findWindowsDlls(IRemoteFile root)
                             throws RemoteException
Scan the directory tree for files that end with .dll. The (?i) prefix is used to make the regular expression case insensitive.

Throws:
RemoteException

getSampleOSDir

private static IRemoteFile getSampleOSDir(IRemoteFileSystem fs)
                                   throws RemoteException
Return the "working" directory that will be used as a root for all other methods. It is wither "WINDOWS", "WINNT", or "/usr".

Throws:
RemoteException

main

public static void main(String[] args)

printFirstLineOf

private static void printFirstLineOf(IRemoteFile file)
                              throws IOException
Print the first line of a remote file. This method tries to handle both Unicode UTF-16 and plain text files.

Throws:
IOException

printTextFiles

private static void printTextFiles(IRemoteFile root)
                            throws IOException
Print the first line of remote text files.

Throws:
IOException

scanByExtension

private static void scanByExtension(IRemoteFile parent,
                                    String ext)
                             throws RemoteException
The actual implementation of findWindowsDlls(IRemoteFile)

Throws:
RemoteException

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.