How to used Ftp Connection
Hello Guys,
I want Ftp connection using the Bean Shellcode. I wrote code in Bean Shell Form Binder but its return package error so any other packages for FTP connection in joget?
Below the Code:
package net.codejava.ftp;
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.net.URL;import java.net.URLConnection;
public static void main(String[] args) { String ftpUrl = "ftp://%s:%s@%s/%s;type=d"; String host = "**************"; String user = "******"; String pass = "****"; String dirPath = "/****/******";
ftpUrl = String.format(ftpUrl, user, pass, host, dirPath); System.out.println("URL: " + ftpUrl);
try { URL url = new URL(ftpUrl); URLConnection conn = url.openConnection(); InputStream inputStream = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = null; System.out.println("--- START ---"); while ((line = reader.readLine()) != null) { System.out.println(line); } System.out.println("--- END ---");
inputStream.close(); } catch (IOException ex) { ex.printStackTrace(); } }
Please anyone assist me.
thank you in advance
Regards