import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.FileSystemManager;
import org.apache.commons.vfs2.VFS;
import org.junit.Test;

/**
 * Created by Administrator on 2015/5/25.
 */
public class FileObjectTest {

    @Test
    public void testFileObject() throws FileSystemException {
        FileSystemManager fileSystemManager = VFS.getManager();
        //Each file is represented by a FileObject instance. Using this interface you can create or delete the file, list its children, read or write its content, and so on
        FileObject jarFile = fileSystemManager.resolveFile("jar:f://commons-vfs2-examples-2.0-sources.jar");

        FileObject[] children = jarFile.getChildren();
        System.out.println("Children of " + jarFile.getName().getURI());
        for (FileObject fo : children) {
            System.out.println(fo.getName().getBaseName());
        }
    }
}

@@ -24,26 +24,17 @@
 ns.vfs2.
-FileObject
+*
 ;%0Aimport
@@ -62,136 +62,183 @@
 fs2.
-FileSystemException;%0Aimport org.apache.commons.vfs2.FileSystemManager;%0Aimport org.apache.commons.vfs2.VFS;%0Aimport org.junit.Test
+provider.zip.ZipFileObject;%0Aimport org.junit.Test;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.util.zip.ZipEntry;%0Aimport java.util.zip.ZipOutputStream
 ;%0A%0A/
@@ -367,26 +367,18 @@
  throws 
-FileSystem
+IO
 Exceptio
@@ -682,58 +682,162 @@
 le(%22
-jar:f://commons-vfs2-examples-2.0-sources.jar%22);%0A%0A
+file:///home/edgar/dev/test/TarenaBaiWenBaiDa.pdf%22);%0A//        System.out.println(jarFile.getClass());%0A//        System.out.println(jarFile.getType());%0A//
     
@@ -883,24 +883,26 @@
 Children();%0A
+//
         Syst
@@ -958,24 +958,26 @@
 .getURI());%0A
+//
         for 
@@ -1005,16 +1005,18 @@
 dren) %7B%0A
+//
         
@@ -1067,16 +1067,18 @@
 ame());%0A
+//
         
@@ -1078,16 +1078,1071 @@
        %7D
+%0A%0A        FileObject destFile = fileSystemManager.resolveFile(%22file:///home/edgar/dev/vfs/a%22);%0A        destFile.createFile();%0A//        ZipOutputStream zos = new ZipOutputStream(destFile.getContent().getOutputStream());%0A//        // add entry/-ies.%0A//        ZipEntry zipEntry = new ZipEntry(%22name_inside_zip%22);%0A//        InputStream is = jarFile.getContent().getInputStream();%0A//%0A//// Write to zip.%0A//        byte%5B%5D buf = new byte%5B1024%5D;%0A//        zos.putNextEntry(zipEntry);%0A//        for (int readNum; (readNum = is.read(buf)) != -1;) %7B%0A//            zos.write(buf, 0, readNum);%0A//        %7D%0A%0A//        destFile.createFolder();%0A//        System.out.println(destFile.getType());%0A//        if (destFile.exists()) %7B%0A//            System.out.println(destFile.getName().getURI());%0A//        %7D else %7B%0A//            destFile.createFile();%0A//            destFile.copyFrom(jarFile, Selectors.SELECT_SELF);%0A//        %7D%0A//        System.out.println(destFile.getType());%0A        destFile.copyFrom(jarFile, Selectors.SELECT_SELF);%0A//        jarFile.moveTo(destFile);
 %0A    %7D%0A%7D

copy file zip仍然有问题