title: FTP file access - java
body: <p>I have written a simple program that access FTP file details in java </p>
  
  <p>package MyFTP;</p>
  
  <pre><code>import java.io.BufferedOutputStream;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.net.UnknownHostException;
  
  import org.apache.commons.net.ftp.FTP;
  import org.apache.commons.net.ftp.FTPClient;
  import org.apache.commons.net.ftp.FTPFile;
  
  public class TestClass2 {
  
      public static void main(String[] args) throws UnknownHostException {
  
          String server = "192.168.100.1";
          int port = 26;
          String user = "username";
          String pass = "password";
  
          FTPClient ftpClient = new FTPClient();
          try {
  
              ftpClient.connect(server, port);
              ftpClient.login(user, pass);
              ftpClient.enterLocalPassiveMode();
              //ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
  
              FTPFile[] files = null;
              try {
                  files = ftpClient.listFiles("/test"); ////**EXCEPTION**
              } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
              }
  
          } catch (IOException ex) {
              System.out.println("Error: " + ex.getMessage());
              ex.printStackTrace();
          } finally {
              try {
                  if (ftpClient.isConnected()) {
                      ftpClient.logout();
                      ftpClient.disconnect();
                  }
              } catch (IOException ex) {
                  ex.printStackTrace();
              }
          }
      }
  
  }
  </code></pre>
  
  <p>Here's the exception :</p>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
      The import org.apache.oro cannot be resolved
      The import org.apache.oro cannot be resolved
      The import org.apache.oro cannot be resolved
      The import org.apache.oro cannot be resolved
      The import org.apache.oro cannot be resolved
      The import org.apache.oro cannot be resolved
      Pattern cannot be resolved to a type
      MatchResult cannot be resolved to a type
      PatternMatcher cannot be resolved to a type
      _matcher_ cannot be resolved
      Perl5Matcher cannot be resolved to a type
      pattern cannot be resolved
      Perl5Compiler cannot be resolved to a type
      MalformedPatternException cannot be resolved to a type
      result cannot be resolved or is not a field
      _matcher_ cannot be resolved
      pattern cannot be resolved or is not a field
      result cannot be resolved or is not a field
      _matcher_ cannot be resolved
      result cannot be resolved or is not a field
      result cannot be resolved or is not a field
      result cannot be resolved or is not a field
      result cannot be resolved or is not a field
      result cannot be resolved or is not a field
      result cannot be resolved or is not a field
      result cannot be resolved or is not a field
  
      at org.apache.commons.net.ftp.parser.RegexFTPFileEntryParserImpl.&lt;init&gt;(RegexFTPFileEntryParserImpl.java:19)
      at org.apache.commons.net.ftp.parser.ConfigurableFTPFileEntryParserImpl.&lt;init&gt;(ConfigurableFTPFileEntryParserImpl.java:57)
      at org.apache.commons.net.ftp.parser.NTFTPEntryParser.&lt;init&gt;(NTFTPEntryParser.java:73)
      at org.apache.commons.net.ftp.parser.NTFTPEntryParser.&lt;init&gt;(NTFTPEntryParser.java:56)
      at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createNTFTPEntryParser(DefaultFTPFileEntryParserFactory.java:186)
      at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:102)
      at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2359)
      at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2142)
      at MyFTP.TestClass2.main(TestClass2.java:36)
  </code></pre>
  
  <p>Don't know what I have done wrong </p>
  
  <p>I have a file at </p>
  
  <blockquote>
    <p><a href="ftp://192.168.100.1:26/test/a.txt" rel="nofollow">ftp://192.168.100.1:26/test/a.txt</a></p>
  </blockquote>
  
  <p>Am I correct with the line </p>
  
  <blockquote>
    <p>files = ftpClient.listFiles("/test");</p>
  </blockquote>
  
  <p>Need help ,
  Thanks in advance</p>
  
  <p>jars used: </p>
  
  <blockquote>
    <p>commons-net-3.3.jar commons.io_2.0.1.jar apache-commons-net.jar</p>
  </blockquote>