private URL[] prepareJarFiles( FileObject zipFile ) throws Exception { // zip:file:///tmp/foo.zip FileInputList fileList = FileInputList.createFileList( this, new String[] { "zip:" + zipFile.toString(), }, new String[] { ".*\\.jar$", }, // Include mask: only jar files new String[] { ".*classpath\\.jar$", }, // Exclude mask: only jar files new String[] { "Y", }, // File required new boolean[] { true, } ); // Search sub-directories List<URL> files = new ArrayList<URL>(); // Copy the jar files in the temp folder... // for ( FileObject file : fileList.getFiles() ) { FileObject jarfilecopy = KettleVFS.createTempFile( file.getName().getBaseName(), ".jar", environmentSubstitute( "${java.io.tmpdir}" ) ); jarfilecopy.copyFrom( file, new AllFileSelector() ); files.add( jarfilecopy.getURL() ); } return files.toArray( new URL[files.size()] ); }
destinationfilefolder.copyFrom( sourcefilefolder.getParent(), new TextOneFileSelector( sourcefilefolder.getParent().toString(), sourcefilefolder.getName().getBaseName(), destinationfilefolder.toString() ) ); destinationfilefolder.copyFrom( sourcefilefolder, new TextOneToOneFileSelector( destinationfilefolder ) ); } else { new TextFileSelector( sourcefilefolder, destinationfilefolder, realWildcard, parentJob ); try { destinationfilefolder.copyFrom( sourcefilefolder, textFileSelector ); } finally { textFileSelector.shutdown();
@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "input files are specified by admin, not unchecked user input") @Override public File replicateFile(FileObject srcFile, FileSelector selector) throws FileSystemException { String baseName = srcFile.getName().getBaseName(); try { String safeBasename = UriParser.encode(baseName, TMP_RESERVED_CHARS).replace('%', '_'); File file = File.createTempFile("vfsr_", "_" + safeBasename, tempDir); file.deleteOnExit(); final FileObject destFile = context.toFileObject(file); destFile.copyFrom(srcFile, selector); return file; } catch (IOException e) { throw new FileSystemException(e); } }
remoteFile.copyFrom(localFile, Selectors.SELECT_SELF); System.out.println("File upload successful");
localFile.copyFrom(remoteFile, Selectors.SELECT_SELF); System.out.println("File download successful");
if ( ( ( meta.isOverwriteTargetFile() && data.targetFile.exists() ) || !data.targetFile.exists() ) && !meta.simulate ) { data.targetFile.copyFrom( data.sourceFile, new TextOneToOneFileSelector() ); if ( log.isDetailed() ) { logDetailed( BaseMessages.getString(
@Override public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException { decoratedFileObject.copyFrom(srcFile, selector); }
@Override public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException { decoratedFileObject.copyFrom(srcFile, selector); }
public void copyFrom(FileObject srcFile, FileSelector selector) throws FileSystemException { parent.copyFrom(srcFile, selector); }
@Override public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException { decoratedFileObject.copyFrom(srcFile, selector); }
@Override public void copyFrom(final FileObject srcFile, final FileSelector selector) throws FileSystemException { decoratedFileObject.copyFrom(srcFile, selector); }
@Override public void copyFrom(org.apache.commons.vfs2.FileObject srcFile, FileSelector selector) { try { this.fileObject.copyFrom(srcFile, selector); } catch (FileSystemException e) { throw new VFSFileSystemException(e); } }
@Override public void copyFrom(org.apache.commons.vfs2.FileObject srcFile, FileSelector selector) { try { this.fileObject.copyFrom(srcFile, selector); } catch (FileSystemException e) { throw new VFSFileSystemException(e); } }
File f=new File("abc.txt"); //Takes the default path, else, you can specify the required path if(f.exists()) { f.delete(); } f.createNewFile(); FileObject destn=VFS.getManager().resolveFile(f.getAbsolutePath()); UserAuthenticator auth=new StaticUserAuthenticator("", "myusername", "secret_password"); FileSystemOptions opts=new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); FileObject fo=VFS.getManager().resolveFile("\\\\192.168.0.1\\direcory\\to\\GetData\\sourceFile.txt",opts); destn.copyFrom(fo,Selectors.SELECT_SELF); destn.close();
public static void explode(FileObject archiveFile, File target, FileSelector fileSelector, String errorMessage) { try { FileSystemManager manager = VFS.getManager(); FileObject targetObject = manager.toFileObject(target); targetObject.copyFrom(archiveFile, fileSelector); } catch (IOException e) { throw new ApplicationTechnicalException(errorMessage, e); } }
@Override public File replicateFile(FileObject srcFile, FileSelector selector) throws FileSystemException { String baseName = srcFile.getName().getBaseName(); try { String safeBasename = UriParser.encode(baseName, TMP_RESERVED_CHARS).replace('%', '_'); File file = File.createTempFile("vfsr_", "_" + safeBasename, tempDir); file.deleteOnExit(); final FileObject destFile = context.toFileObject(file); destFile.copyFrom(srcFile, selector); return file; } catch (IOException e) { throw new FileSystemException(e); } }
StandardFileSystemManager manager = new StandardFileSystemManager(); FileObject target = manager.resolveFile("file://" + path + File.separator + filenameTarget); FileObject source = manager.resolveFile(sftpUri + path + File.separator + filenameSource, options); target.copyFrom(fichierSource, Selectors.SELECT_SELF);
/** * Does a 'cp' command. */ private void cp(final String[] cmd) throws Exception { if (cmd.length < 3) { throw new Exception("USAGE: cp <src> <dest>"); } final FileObject src = mgr.resolveFile(cwd, cmd[1]); FileObject dest = mgr.resolveFile(cwd, cmd[2]); if (dest.exists() && dest.getType() == FileType.FOLDER) { dest = dest.resolveFile(src.getName().getBaseName()); } dest.copyFrom(src, Selectors.SELECT_ALL); }
public void accept(FileObject fo) throws IOException { FileName name = fo.getName(); String localName = name.getBaseName(); File dest = child(localName); FileObject dfo = null; try { dfo = VFS.getManager().resolveFile(dest.getAbsolutePath()); dfo.copyFrom(fo, new AllFileSelector()); unpack(dest); } finally { if (dfo != null) { dfo.close(); } } }
/** * Handles an out-of-date file. * * @param srcFile The source FileObject. * @param destFile The destination FileObject. */ @Override protected void handleOutOfDateFile(final FileObject srcFile, final FileObject destFile) throws FileSystemException { log("Copying " + srcFile.getPublicURIString() + " to " + destFile.getPublicURIString()); destFile.copyFrom(srcFile, Selectors.SELECT_SELF); if (preserveLastModified && srcFile.getFileSystem().hasCapability(Capability.GET_LAST_MODIFIED) && destFile.getFileSystem().hasCapability(Capability.SET_LAST_MODIFIED_FILE)) { final long lastModTime = srcFile.getContent().getLastModifiedTime(); destFile.getContent().setLastModifiedTime(lastModTime); } }