public static void ftpConn(String filePath, String uploadPath) {
String ftpUrl = "ftp://%s:%s@%s/%s;type=i";
String host = "ip";
String user = "login";
String pass = "pass";
ftpUrl = String.format(ftpUrl, user, pass, host, uploadPath);
try {
URL url = new URL(ftpUrl);
URLConnection conn = url.openConnection();
OutputStream outputStream = conn.getOutputStream();
FileInputStream inputStream = new FileInputStream(filePath);
byte[] buffer = new byte[2048];
int bytesRead = -1;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
inputStream.close();
outputStream.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}