java - Set file path on FTPClient -


i'm new java programming , using apache commons net ftp upload text files ftp server.

however, seems can upload files on same directory program .. when set file path : "c:\users\packard\documents\projectsjava\fugelessons\outputfile.txt" , throws no errors, when check ftp, there nothing, has not been uploaded .

here code i'm using :

import org.apache.commons.net.ftp.ftpclient; import java.io.fileinputstream; import java.io.ioexception;  public class ftp{     private final string host = "ftp.address.com";     private final string user = "user";     private final string pass = "pass";      public static void main(string[] args) {         ftp client = new ftp();         client.ftpupload("c:\\users\\packard\\documents\\projectsjava\\fugelessons\\outputfile.txt");     }      public string ftpupload(string filename){        ftpclient client = new ftpclient();        fileinputstream fis = null;         try {            client.connect(this.host);            client.login(this.user, this.pass);            fis = new fileinputstream(filename);            client.storefile(filename, fis);            client.logout();            system.out.println("file " + filename + "\t uploaded successfully!");        } catch(ioexception e){            error error = new error();            error.setvisible(true);            e.printstacktrace();        } {            try {                if ( fis != null) {                    fis.close();                }                client.disconnect();            } catch(ioexception e){                e.printstacktrace();            }        }         string ret = "success";        return ret;     } } 

what doing wrong ? help!

you can use ftpclient method getreplystring() error message. below code can help.

boolean issendsucces = ftpclient.storefile(filename, input ); if( issendsuccess ) {     system.out.println("sent file: " + filename);                    } else {     system.out.println("problem sending file: " + ftpclient.getreplystring()); } 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -