How to pump/rename folder/file on the FTP server by means of Java?

0 like 0 dislike
25 views
Hello. Found online code to upload the files using Java FTP server. The catch is that there are no examples to rename folders and files. How can I do that?
Code below, exclusively confined to the uploading of files to an FTP server.
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(); } }
asked by | 25 views

1 Answer

0 like 0 dislike
answered by

Related questions

0 like 0 dislike
2 answers
asked Oct 17, 2018 by KateM93
0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
0 like 0 dislike
2 answers
24,509 questions
45,932 answers
0 comments
345 users