How to used Ftp Connection

Confluence User - 08 Aug, 2020

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


ftp;support;connection;help;beanshell;server;packages;import

1


10 Aug, 2020
confluenceUser
confluenceUser

Hi, what is the package error that is returned? I am uncertain if BeanShell allows you use a "public static void main" method like that, perhaps you can bring the code out of the method. Alternatively, if you prefer to use full Java code then you can develop it as a plugin instead as in Developing Plugins.

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print