java - JSch sftp job summary -
private final string host; private final string useraccount; private final string keydir; private channelsftp sftpchannel; private session session; private channel channel public void send(list<path> filestosend, string destination) throws sftpexception, ioexception { if (sftpchannel == null) { logger.error("failed create sftp channel"); } (path file : filestosend) { send(file, destination); } //summary of sent files on sftpchannel } public void send(path file, string destination) throws sftpexception, ioexception { if (sftpchannel == null) { logger.error("failed create sftp channel"); } sftpchannel.put(files.newinputstream(file), destination + file.separator + file.getfilename()); } //end send }//end class
after files have been sent, can show me how can count of how many number of files have been sent. not of import if failed or kind of monitoring. how can jsch library.
i in log such :
preparing send [14] files
number of files sent [14]...
public void send(list<path> filestosend, string destination) { logger.debug("preparing send ["+filestosend.size()+"] files"); if (sftpchannel == null) { logger.error("failed create sftp channel"); } int successcount = 0; int failedcount = 0; (path file : filestosend) { seek { send(file, destination); successcount++; } grab (exception e) { failedcount++; } } //summary of sent files on sftpchannel logger.debug("successfully sent " + successcount); logger.debug("failed sent " + failedcount); }
java sftp jsch
No comments:
Post a Comment