0

When i try to list files from my location using ftpClient.listFiles("folder"); it shows

org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.

Can some one guide me what i am doing wrong.

I use apache-commons-net-3.3

My code is

FTPClientConfig ftpClientConfig = new FTPClientConfig(FTPClientConfig.SYST_NT);
FTPClient ftpClient = new FTPClient();
ftpClient.configure(ftpClientConfig);
ftpClient.connect(hostName, Integer.valueOf(portNumber));
ftpClient.enterLocalPassiveMode();
ftpClient.login(username, password);

// Error throws here
FTPFile[] files = ftpClient.listFiles("folder");
ashokramcse
  • 2,841
  • 2
  • 19
  • 41

2 Answers2

2

This Exception is thrown when a user gave a Wrong or Encrypted Username Or Password.

Apache is not throwing the correct exception.

ashokramcse
  • 2,841
  • 2
  • 19
  • 41
-1
   public void ConnectToFtp(String serverAdd,String username,String password){

       try {    

           ftpclient.connect(serverAdd);

           boolean login  =    ftpclient.login(username,password);

              reply = ftpclient.getReplyCode();


              if(FTPReply.isPositiveCompletion(reply)){

                  System.out.println("Connected Success");


              }else {

                  System.out.println("Connection Failed");

                  ftpclient.disconnect();

              }
              if (login) {  
                    System.out.println("Connection established...");  


                    FTPFile[] ftpFiles = ftpclient.listFiles();
                    for (FTPFile ftpFile : ftpFiles) {

                        if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) {
                            System.out.printf("FTPFile: %s; %s%n",
                                ftpFile.getName(),
                                FileUtils.byteCountToDisplaySize(ftpFile.getSize()));
                        }
                    }
                }
         boolean logout = ftpclient.logout();  
              if (logout) {  
               System.out.println("Connection close...");  
              }  else {  
              System.out.println("Connection fail...");  
             }  

         } catch (SocketException ex) {

           ex.printStackTrace();

       } catch (IOException ex) {

           ex.printStackTrace();
           } finally {  
           try {  
            ftpclient.disconnect();  
           } catch (IOException e) {  
            e.printStackTrace();  
             }  
          }  
       }
    }