On Fri, Nov 5, 2010 at 12:10 PM, sebb <seb...@gmail.com> wrote:
> If so, what about someone using Java 1.4 - can they update to VFS 2.0,
> but keep the FTP support from NET 1.4?
> Or will they lose FTP support entirely?
>

FTP support works without Net at all.  I just ran a test client and
excluded anything but the "core" from the classpath.  It used the
org.apache.commons.vfs.provider.url.UrlFileSystem to handle FTP URLs.
Here's the code (from a user's question posted a while back):

        String fileName = "CBCP.TXT";
        FileSystemManager fsManager;
        fsManager = VFS.getManager();
        UserAuthenticator auth = new StaticUserAuthenticator(null,
                "anonymous", "");
        FileSystemOptions srcOpts = new FileSystemOptions();
        String sourceDirAsString = "ftp://ftp.microsoft.com:21/MISC";;
        
DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(srcOpts,
                auth);
        FileObject sourceDir = fsManager.resolveFile(sourceDirAsString,
                srcOpts); // HERE IS A HANG UP


        FileObject neededFile = sourceDir.resolveFile(fileName);
        System.out.println("Using file system type " +
neededFile.getFileSystem().getClass().getName() + "...");
        FileContent content = neededFile.getContent();
        byte[] buffer = new byte[1024];
        final InputStream in = content.getInputStream();
        int totalBytes = 0;
        int bytesRead;
        while((bytesRead = in.read(buffer)) != -1)
        {
            totalBytes += bytesRead;
        }
        System.out.println("Read " + totalBytes + " bytes from file of
size " + content.getSize());

Here's my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.carmanconsulting.vfs</groupId>
  <artifactId>vfs-ftp</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
      <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-vfs</artifactId>
          <version>2.0-SNAPSHOT</version>
      </dependency>
      <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>1.2.16</version>
      </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to