Guest User

Untitled

a guest
Feb 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. package com.packagename
  2. import java.io.BufferedInputStream;
  3. import java.io.FileInputStream;
  4. import java.io.FileNotFoundException;
  5. import java.io.IOException;
  6. import java.net.InetAddress;
  7. import java.net.SocketException;
  8. import java.net.UnknownHostException;
  9.  
  10. import org.apache.commons.net.ftp.*;
  11.  
  12. import org.apache.commons.net.ftp.FTPClient;
  13. import org.apache.commons.net.ftp.FTPConnectionClosedException;
  14. import org.apache.commons.net.ftp.FTPReply;
  15. import android.content.Context;
  16.  
  17. public class FTPz {
  18.     String server = "xx.xx.xx.xx",
  19.     user = "user",
  20.     password = "pass",
  21.     file = "schools",
  22.     filepath = "/data/data/com.projectname/databases/";
  23.    
  24.     Context context;
  25.     public FTPz(Context ctx){
  26.         context = ctx;
  27.     }
  28.     FTPClient fc = new  FTPClient();
  29.  
  30.     public void dothedamnthing() throws SocketException, UnknownHostException,         
  31.             IOException{
  32.        
  33.         fc.connect(server, 21);
  34.         fc.login(user, password);
  35.         fc.setFileType(FTP.BINARY_FILE_TYPE);
  36.         BufferedInputStream buffIn = null;
  37.         buffIn=new BufferedInputStream(new FileInputStream(filepath + file));
  38.         fc.enterLocalPassiveMode();
  39.         fc.storeFile("schools", buffIn);
  40.         buffIn.close();
  41.         fc.logout();
  42.         fc.disconnect();
  43.     }
  44.  
  45. }
Add Comment
Please, Sign In to add comment