Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.packagename
- import java.io.BufferedInputStream;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.net.InetAddress;
- import java.net.SocketException;
- import java.net.UnknownHostException;
- import org.apache.commons.net.ftp.*;
- import org.apache.commons.net.ftp.FTPClient;
- import org.apache.commons.net.ftp.FTPConnectionClosedException;
- import org.apache.commons.net.ftp.FTPReply;
- import android.content.Context;
- public class FTPz {
- String server = "xx.xx.xx.xx",
- user = "user",
- password = "pass",
- file = "schools",
- filepath = "/data/data/com.projectname/databases/";
- Context context;
- public FTPz(Context ctx){
- context = ctx;
- }
- FTPClient fc = new FTPClient();
- public void dothedamnthing() throws SocketException, UnknownHostException,
- IOException{
- fc.connect(server, 21);
- fc.login(user, password);
- fc.setFileType(FTP.BINARY_FILE_TYPE);
- BufferedInputStream buffIn = null;
- buffIn=new BufferedInputStream(new FileInputStream(filepath + file));
- fc.enterLocalPassiveMode();
- fc.storeFile("schools", buffIn);
- buffIn.close();
- fc.logout();
- fc.disconnect();
- }
- }
Add Comment
Please, Sign In to add comment