Link to home
Start Free TrialLog in
Avatar of jcorbin
jcorbin

asked on

Ftp'ing files

Can someone gimme some code or a nudge in the direction on how I can get a directory list from a Unix machine and then transfer files from it?? I have done this with VB and the WinInet.dll but need a COM interface and would like to do it in Java.
Avatar of jpk041897
jpk041897

To get the directory tree only, you can use the FileDialog() method.

This method will display a modal dialog box with a tree you can navigate on.

Note, this method will not transfer the files, it will only give you a path from which you can either build a URL and trasfer the file via HTTP or UDP; or give you a full path for an FTP class to transfer the files (for which you would need FTP privilages).


 Class java.awt.FileDialog  



java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Window
                           |
                           +----java.awt.Dialog
                                   |
                                   +----java.awt.FileDialog
 
______________________________________________________________________________
 

 public class FileDialog  
 extends Dialog  

The File Dialog class displays a file selection dialog. It is a  modal dialog and will block the calling thread when the show method  is called to display it, until the user has chosen a file.  

   
See Also:  

show  

______________________________________________________________________________
 
     

   
       LOAD  

 The file load variable.  
       SAVE  

 The file save variable.  

 
     

   
       FileDialog(Frame)  

 Creates a file dialog for loading a file.  
       FileDialog(Frame, String)  

 Creates a file dialog for loading a file.  
       FileDialog(Frame, String, int)  

 Creates a file dialog with the specified title and mode.  

 
     

   
       addNotify()  

 Creates the file dialog's peer.  
       getDirectory()  

 Gets the directory of the Dialog.  
       getFile()  

 Gets the file of the Dialog.  
       getFilenameFilter()  

 Gets the filter.  
       getMode()  

 Gets the mode of the file dialog.  
       paramString()  

 Returns the parameter String of this file dialog.  
       setDirectory(String)  

 Set the directory of the Dialog to the specified directory.  
       setFile(String)  

 Sets the file for this dialog to the specified file.  
       setFilenameFilter(FilenameFilter)  

 Sets the filter for this dialog to the specified filter.  
       setMode(int)  

 Sets the mode of the file dialog.  

 
     

 LOAD

  public final static int LOAD
 
 

 The file load variable.  


 

 SAVE

  public final static int SAVE
 
 

 The file save variable.  


Hope this helps.
 There is yet another approach. You can connect to this machine through FTP, using an ftp class, and navigating through the remote machine's directory, FTPing, etc. (the credits to this idea should also go to jpk). You'd perfer this approach if you want to do it non interactivly. If you want to go this direction, you can find ftp code at
http://www.oroinc.com/downloads/index.html

Avatar of jcorbin

ASKER

I really want to know HOW to transfer files, do I use an InputStream, a BufferedStream?? As text or binary?? using char mode or byte?? I dont care about using the dialog boxes, I am not going to use an interface, I need to build a COM component. Any help is appreciated.

 
ASKER CERTIFIED SOLUTION
Avatar of jpk041897
jpk041897

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial