commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zoran Jeremic <jeremic1...@yahoo.com>
Subject problem to create FTP client
Date Sat, 19 Apr 2008 12:05:55 GMT
Hi,
   
  I'm using a commons-net to upload an ArgoUML project (archive with extension .zargo) and
its class diagram as picture (.png) to the remote FTP server. Its works fine in case FTP client
and FTP server are on the same PC. However, if the FTP client is on other PC it also upload
both files picture and project to the FTP repository but those files has only 1 kb instead
of 5 or more and are unreadable. 
Here is the code:
   
  public void createConnectionToFTPServer(String host,String username, String password){
 
 try{
 ftp.connect(host);
 ftp.login(username, password);
 int reply=ftp.getReplyCode();
  if(FTPReply.isPositiveCompletion(reply)){
      LOG.info("Connected Successfully to the FTP server");
  }else{
      LOG.info("Connection to the FTP server Failed");
      ftp.disconnect();
  }
  ...
  public void uploadFileToRepository(File file,String filename){
    try{
 ftp.setFileType(FTP.IMAGE_FILE_TYPE);
 LOG.info("uploadFileToRepository");
    InputStream fis = new FileInputStream(file);
 OutputStream os = ftp.storeFileStream(filename);
 int t=0;
        while( (t=fis.read()) >=0){
            os.write(t);
        }
 }catch(IOException ioe){
 ...
 
 public void closeConnection(){
    try{
    ftp.disconnect();
....
  I hope that somebody has an idea what can be problem.
   
  Thanks
Zoran

       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message