Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean upload(String url, String username, String password, File file) {
- FTPClient client = new FTPClient();
- FileInputStream fis = null;
- try {
- client.connect(url);
- client.login(username, password);
- fis = new FileInputStream(file);
- // Store file on server and logout
- boolean uploaded = client.storeFile(file.getName(), fis);
- client.logout();
- return uploaded;
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- if (fis != null) {
- fis.close();
- }
- client.disconnect();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement