Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript![ ? ]
How to pump/rename folder/file on the FTP server by means of Java? - Q&A

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

0 like 0 dislike
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 = != -1) { outputStream.write(buffer, 0, bytesRead); } inputStream.close(); outputStream.close(); } catch (IOException ex) { ex.printStackTrace(); } }
asked by | 32 views

1 Answer

0 like 0 dislike
answered by
Welcome to Bug-code Q&A, where you can ask questions and receive answers from other members of the community.

24.8k questions

46.2k answers


12.3k users

24,788 questions
46,220 answers
12,337 users