Package org.apache.commons.vfs

Examples of org.apache.commons.vfs.FileObject.copyFrom()


 
  public File getResourceAsFile(String path) throws IOException {
    FileObject unpackedResource = _work.resolveFile(path);
    if (!unpackedResource.exists()) {
      FileObject sourceFile = _source.resolveFile(path);
      sourceFile.copyFrom(unpackedResource, new FileSelector() {

        public boolean includeFile(FileSelectInfo arg0) throws Exception {
          return true;
        }
View Full Code Here


        if (dest.exists() && dest.getType() == FileType.FOLDER)
        {
            dest = dest.resolveFile(src.getName().getBaseName());
        }

        dest.copyFrom(src, Selectors.SELECT_ALL);
    }

    /**
     * Does a 'cat' command.
     */
 
View Full Code Here

        final String basename = srcFile.getName().getBaseName();
        final File file = allocateFile(basename);

        // Copy from the source file
        final FileObject destFile = getContext().toFileObject(file);
        destFile.copyFrom(srcFile, selector);

        return file;
    }
}
View Full Code Here

        assertSameContent(content, file);

        // Make sure we can copy the new file to another file on the same filesystem
        FileObject fileCopy = scratchFolder.resolveFile("file1copy.txt");
        assertTrue(!fileCopy.exists());
        fileCopy.copyFrom(file, Selectors.SELECT_SELF);

        assertSameContent(content, fileCopy);
    }

    /**
 
View Full Code Here

        assertSameContent(content, file);

        // Make sure we can copy the new file to another file on the same filesystem
        FileObject fileCopy = scratchFolder.resolveFile("file1copy.txt");
        assertTrue(!fileCopy.exists());
        fileCopy.copyFrom(file, Selectors.SELECT_SELF);

        assertSameContent(content, fileCopy);
       
        // Make sure we can copy the same new file to the same target file on the same filesystem
        assertTrue(fileCopy.exists());
View Full Code Here

        assertSameContent(content, fileCopy);
       
        // Make sure we can copy the same new file to the same target file on the same filesystem
        assertTrue(fileCopy.exists());
        fileCopy.copyFrom(file, Selectors.SELECT_SELF);

        assertSameContent(content, fileCopy);
    }

    /**
 
View Full Code Here

        assertSameContent(content, file);

        // Make sure we can copy the new file to another file on the same filesystem
        FileObject fileCopy = scratchFolder.resolveFile("file1copy.txt");
        assertTrue(!fileCopy.exists());
        fileCopy.copyFrom(file, Selectors.SELECT_SELF);

        assertSameContent(content, fileCopy);

        // Delete the file.
        assertTrue(fileCopy.exists());
View Full Code Here

        assertTrue(fileCopy.exists());
        assertTrue(fileCopy.delete());
       
        // Make sure we can copy the same new file to the same target file on the same filesystem
        assertTrue(!fileCopy.exists());
        fileCopy.copyFrom(file, Selectors.SELECT_SELF);

        assertSameContent(content, fileCopy);
    }

    /**
 
View Full Code Here

        assertSameContent(contentAppend, file);

        // Make sure we can copy the new file to another file on the same filesystem
        FileObject fileCopy = scratchFolder.resolveFile("file1copy.txt");
        assertTrue(!fileCopy.exists());
        fileCopy.copyFrom(file, Selectors.SELECT_SELF);

        assertSameContent(contentAppend, fileCopy);

        // Delete the file.
        assertTrue(fileCopy.exists());
View Full Code Here

        String fileName = destination.getName().getBaseName();
        destination = VFSUtils.resolveFile(cachef, fileName);
      }
      if (fileChanged(source, destination))
      {
        destination.copyFrom(source, new AllFileSelector());
        destination.getContent().setLastModifiedTime(source.getContent().getLastModifiedTime());
        System.out.println("file loaded " + source.getName() + " -> " + destination.getName());
      }
      return destination;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.