Below class Test have moveFile method to move file from d:\\temp\\server.txt" local path to shared folder path \\\\<shared_folder_path>\\<folder_name>\\
public class Test {
public static void main(String[] args) throws org.apache.commons.vfs2.FileSystemException {
moveFile("server", "d:\\temp\\server.txt");
}
public static void moveFile(String fileName, String inputFolder)
throws org.apache.commons.vfs2.FileSystemException
{
FileObject destn = VFS.getManager().resolveFile("\\\\<shared_folder_path>\\<folder_name>\\" + fileName + ".txt");
FileObject fo = VFS.getManager().resolveFile(inputFolder);
fo.moveTo(destn);
destn.close();
}
}
FileObject destn = VFS.getManager().resolveFile("\\\\<shared_folder_path>\\<folder_name>\\" + fileName + ".txt");
FileObject fo = VFS.getManager().resolveFile(inputFolder);
fo.moveTo(destn);
destn.close();
}
}
Note: server.txt and \\\\<serverIp>\\<folder_name>\\ should exist before executing above code.
Above code will move the file from source to destination. Better to use for synchronized operation in you application.
Above code will move the file from source to destination. Better to use for synchronized operation in you application.
No comments:
Post a Comment