core/src/main/java/org/apache/commons/vfs2/provider/ram/RamFileSystem.java
/**
     * Import the given file with the name relative to the given root
     *
     * @param fo
     * @param root
     * @throws FileSystemException
     */
Import the given file with the name relative to the given root
@param fo
@param root
@throws FileSystemException
Import the given file with the name relative to the given root @param fo @param root @throws FileSystemException
void toRamFileObject(FileObject fo, FileObject root)
            throws FileSystemException
    {
        RamFileObject memFo = (RamFileObject) this.resolveFile(fo.getName()
                .getPath().substring(root.getName().getPath().length()));
        if (fo.getType().hasChildren())
        {
            memFo.createFolder();
            FileObject[] fos = fo.getChildren();
            for (int i = 0; i < fos.length; i++)
            {
                FileObject child = fos[i];
                this.toRamFileObject(child, root);
            }
        }
        else if (fo.getType().equals(FileType.FILE))
        {
            try
            {
                InputStream is = fo.getContent().getInputStream();
                try
                {
                    OutputStream os = new BufferedOutputStream(memFo
                            .getOutputStream(), 512);
                    int i;
                    while ((i = is.read()) != -1)
                    {
                        os.write(i);
                    }
                    os.flush();
                    os.close();
                }
                finally
                {
                    try
                    {
                        is.close();
                    }
                    catch (IOException e)
                    {
                    }
                }
            }
            catch (IOException e)
            {
                throw new FileSystemException(e.getClass().getName() + " "
                        + e.getMessage());
            }
        }
        else
        {
            throw new FileSystemException("File is not a folder nor a file "
                    + memFo);
        }
    }
void toRamFileObject ( FileObject fo , FileObject root ) throws FileSystemException { RamFileObject memFo = ( RamFileObject ) this . resolveFile ( fo . getName ( ) . getPath ( ) . substring ( root . getName ( ) . getPath ( ) . length ( ) ) ) ; if ( fo . getType ( ) . hasChildren ( ) ) { memFo . createFolder ( ) ; FileObject [ ] fos = fo . getChildren ( ) ; for ( int i = 0 ; i < fos . length ; i ++ ) { FileObject child = fos [ i ] ; this . toRamFileObject ( child , root ) ; } } else if ( fo . getType ( ) . equals ( FileType . FILE ) ) { try { InputStream is = fo . getContent ( ) . getInputStream ( ) ; try { OutputStream os = new BufferedOutputStream ( memFo . getOutputStream ( ) , 512 ) ; int i ; while ( ( i = is . read ( ) ) != - 1 ) { os . write ( i ) ; } os . flush ( ) ; os . close ( ) ; } finally { try { is . close ( ) ; } catch ( IOException e ) { } } } catch ( IOException e ) { throw new FileSystemException ( e . getClass ( ) . getName ( ) + " " + e . getMessage ( ) ) ; } } else { throw new FileSystemException ( "File is not a folder nor a file " + memFo ) ; } }
Import the given file with the name relative to the given root
 @param fo
 @param root
 @throws FileSystemException
Import the given file with the name relative to the given root @param fo @param root @throws FileSystemException
// Create Folder // Import recursively // Read bytes // ignore on close exception