本文整理汇总了Java中org.openide.filesystems.FileObject.copy方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.copy方法的具体用法?Java FileObject.copy怎么用?Java FileObject.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFileCopied
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testFileCopied() throws IOException {
inteceptor.copyHandler = copyHandler;
FileObject fo = getVersionedFolder();
fo = fo.createData("copyme.txt");
logHandler.clear();
logHandler.ignoredMessages.add(createdExternalyFormat); // XXX
FileObject fto = fo.copy(fo.getParent(), "copymeto", "txt");
VCSFileProxy fromProxy = VCSFileProxy.createFileProxy(fo);
VCSFileProxy toProxy = VCSFileProxy.createFileProxy(fto);
assertTrue(inteceptor.getBeforeCopyFiles().contains(fromProxy));
assertTrue(inteceptor.getBeforeCopyFiles().contains(toProxy));
assertTrue(inteceptor.getDoCopyFiles().contains(fromProxy));
assertTrue(inteceptor.getDoCopyFiles().contains(toProxy));
assertTrue(inteceptor.getAfterCopyFiles().contains(fromProxy));
assertTrue(inteceptor.getAfterCopyFiles().contains(toProxy));
assertInterceptedCalls(
// f(fileLockedFormat, fromProxy); // XXX no lock before copy ???
f(getCopyHandlerFormat, fromProxy, toProxy),
f(copyHandleFormat, fromProxy, toProxy),
f(copySuccessFormat, fromProxy, toProxy)
// XXX and this doesnt invoke createdExternaly but move does?
);
}
示例2: testFolderTreeCopied
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testFolderTreeCopied() throws IOException {
inteceptor.copyHandler = copyHandler;
FileObject fo = getVersionedFolder();
FileObject fromFolder = fo.createFolder("fromFolder");
FileObject movedChild = fromFolder.createData("copiedChild");
FileObject targetFolder = fo.createFolder("targetFolder");
VCSFileProxy fromProxy = VCSFileProxy.createFileProxy(fromFolder);
logHandler.clear();
logHandler.ignoredMessages.add(createdExternalyFormat); // XXX
FileObject toFolder = fromFolder.copy(targetFolder, "copy", null);
VCSFileProxy toProxy = VCSFileProxy.createFileProxy(toFolder);
assertTrue(inteceptor.getBeforeCopyFiles().contains(fromProxy));
assertTrue(inteceptor.getBeforeCopyFiles().contains(toProxy));
assertTrue(inteceptor.getDoCopyFiles().contains(fromProxy));
assertTrue(inteceptor.getDoCopyFiles().contains(toProxy));
assertTrue(inteceptor.getAfterCopyFiles().contains(fromProxy));
assertTrue(inteceptor.getAfterCopyFiles().contains(toProxy));
assertInterceptedCalls(
f(getCopyHandlerFormat, fromProxy, toProxy),
f(copyHandleFormat, fromProxy, toProxy),
f(copySuccessFormat, fromProxy, toProxy)
);
}
示例3: copy
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Copies entry to folder. Overrides superclass method.
* @param folder folder where copy
* @param suffix suffix to use
* @exception IOException when error happens */
@Override
public FileObject copy(FileObject folder, String suffix) throws IOException {
if (LOG.isLoggable(FINER)) {
LOG.finer("copy(" //NOI18N
+ FileUtil.getFileDisplayName(folder) + ", " //NOI18N
+ (suffix != null ? '"' + suffix + '"' : "<null>")//NOI18N
+ ')');
}
String pasteSuffix = ((PropertiesDataObject)getDataObject()).getPasteSuffix();
if(pasteSuffix == null)
return super.copy(folder, suffix);
FileObject fileObject = getFile();
String basicName = getDataObject().getPrimaryFile().getName();
String newName = basicName + pasteSuffix + Util.getLocaleSuffix(this);
return fileObject.copy(folder, newName, fileObject.getExt());
}
示例4: setUp
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
clearWorkDir();
super.setUp();
System.setProperty("sync.project.execution", "true");
// MockLookup.setLayersAndInstances(cgpi);
InstalledFileLocatorImpl.registerDestDir(destDirF);
((DialogDisplayerImpl) Lookup.getDefault().lookup(DialogDisplayer.class)).reset();
DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION);
File prjDir = new File(new File(getDataDir(), "example-external-projects"), "html4j");
FileObject prj = FileUtil.toFileObject(prjDir);
FileObject wrk = FileUtil.toFileObject(getWorkDir());
dir = prj.copy(wrk, "html4j", null);
}
示例5: setUp
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
clearWorkDir();
super.setUp();
System.setProperty("sync.project.execution", "true");
// MockLookup.setLayersAndInstances(cgpi);
InstalledFileLocatorImpl.registerDestDir(destDirF);
((DialogDisplayerImpl) Lookup.getDefault().lookup(DialogDisplayer.class)).reset();
DialogDisplayerImpl.returnFromNotify(DialogDescriptor.NO_OPTION);
File prjDir = new File(new File(getDataDir(), "example-external-projects"), "javafx");
FileObject prj = FileUtil.toFileObject(prjDir);
FileObject wrk = FileUtil.toFileObject(getWorkDir());
dir = prj.copy(wrk, "javafx", null);
}
示例6: testCopyObjectAttrs
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testCopyObjectAttrs() throws Exception {
String someMethod = WritableXMLFileSystemTest.class.getName() + ".someMethod";
Layer l = new Layer(" <folder name=\"d\">\n <file name=\"f1\">\n <attr name=\"a\" methodvalue=\"" + someMethod + "\"/>\n </file>\n </folder>\n");
FileSystem fs = l.read();
FileObject f = fs.findResource("d/f1");
assertNotNull(f);
f.copy(f.getParent(), "f2", null);
assertEquals(" <folder name=\"d\">\n <file name=\"f1\">\n <attr name=\"a\" methodvalue=\"" + someMethod + "\"/>\n </file>\n <file name=\"f2\">\n <attr name=\"a\" methodvalue=\"" + someMethod + "\"/>\n </file>\n </folder>\n", l.write());
}
示例7: testDisableIBInFSEvents
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDisableIBInFSEvents () throws Exception {
File file = new File(repositoryLocation, "aaa");
file.createNewFile();
final GitClient client = Git.getInstance().getClient(repositoryLocation);
client.add(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR);
client.commit(new File[] { file }, "msg", null, null, GitUtils.NULL_PROGRESS_MONITOR);
FileObject fo = FileUtil.toFileObject(file);
Git.LOG.setLevel(Level.ALL);
LogHandler handler = new LogHandler();
Git.LOG.addHandler(handler);
assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_NORMAL);
fo.delete();
assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_REMOVED);
assertFalse(handler.indexingBridgeCalled);
fo.getParent().createData(file.getName());
assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_NORMAL);
assertFalse(handler.indexingBridgeCalled);
File copy = new File(repositoryLocation, "copy");
fo.copy(fo.getParent(), copy.getName(), "");
assertTrue(client.getStatus(new File[] { copy }, GitUtils.NULL_PROGRESS_MONITOR).get(copy).getStatusHeadIndex() == GitStatus.Status.STATUS_ADDED);
assertFalse(handler.indexingBridgeCalled);
File renamed = new File(repositoryLocation, "renamed");
FileLock lock = fo.lock();
fo.move(lock, fo.getParent(), renamed.getName(), "");
lock.releaseLock();
assertTrue(client.getStatus(new File[] { file }, GitUtils.NULL_PROGRESS_MONITOR).get(file).getStatusHeadIndex() == GitStatus.Status.STATUS_REMOVED);
assertTrue(client.getStatus(new File[] { renamed }, GitUtils.NULL_PROGRESS_MONITOR).get(renamed).getStatusHeadIndex() == GitStatus.Status.STATUS_ADDED);
assertFalse(handler.indexingBridgeCalled);
}
示例8: copyFO
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void copyFO(File from, File to) throws DataObjectNotFoundException, IOException {
FileObject foFrom = FileUtil.toFileObject(from);
assertNotNull(foFrom);
FileObject foTarget = FileUtil.toFileObject(to.getParentFile());
assertNotNull(foTarget);
FileLock lock = foFrom.lock();
try {
foFrom.copy(foTarget, getName(to), getExt(to));
} finally {
lock.releaseLock();
}
}
示例9: testFileCopied
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testFileCopied() throws IOException {
File f = new File(dataRootDir, "workdir/root-test-versioned");
FileObject fo = FileUtil.toFileObject(f);
fo = fo.createData("copyme.txt");
File from = FileUtil.toFile(fo);
FileObject fto = fo.copy(fo.getParent(), "copymeto", "txt");
assertTrue(inteceptor.getBeforeCopyFiles().contains(from));
assertTrue(inteceptor.getBeforeCopyFiles().contains(FileUtil.toFile(fo)));
assertTrue(inteceptor.getDoCopyFiles().contains(from));
assertTrue(inteceptor.getDoCopyFiles().contains(FileUtil.toFile(fo)));
assertTrue(inteceptor.getAfterCopyFiles().contains(from));
assertTrue(inteceptor.getAfterCopyFiles().contains(FileUtil.toFile(fo)));
}
示例10: copyAppletHTML
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private URL copyAppletHTML(FileObject file, String ext) {
URL url = null;
try {
String buildDirProp = evaluator.getProperty("build.dir"); //NOI18N
FileObject buildDir = buildDirProp != null ? updateHelper.getAntProjectHelper().resolveFileObject(buildDirProp) : null;
if (buildDir == null) {
buildDir = FileUtil.createFolder(project.getProjectDirectory(), buildDirProp);
}
FileObject htmlFile = file.getParent().getFileObject(file.getName(), "html"); //NOI18N
if (htmlFile == null) {
htmlFile = file.getParent().getFileObject(file.getName(), "HTML"); //NOI18N
}
if (htmlFile == null) {
return null;
}
FileObject existingFile = buildDir.getFileObject(htmlFile.getName(), htmlFile.getExt());
if (existingFile != null) {
existingFile.delete();
}
FileObject targetHtml = htmlFile.copy(buildDir, file.getName(), ext);
if (targetHtml != null) {
String activePlatformName = evaluator.getProperty("platform.active"); //NOI18N
url = AppletSupport.getHTMLPageURL(targetHtml, activePlatformName);
}
} catch (IOException ioe) {
ErrorManager.getDefault().notify(ioe);
return null;
}
return url;
}
示例11: testCopy_BeforeSuccessFailure
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testCopy_BeforeSuccessFailure() throws IOException {
FileObject fromFolder = FileUtil.toFileObject(getWorkDir()).createFolder("copyFrom");
FileObject toFolder = FileUtil.toFileObject(getWorkDir()).createFolder("copyTo");
assertNotNull(fromFolder);
assertNotNull(toFolder);
FileObject fromCopy = fromFolder.createData("aa");
assertNotNull(fromCopy);
iListener.clear();
assertNotNull(iListener);
assertEquals(0,iListener.beforeCopyCalls);
assertEquals(0,iListener.copySuccessCalls);
assertEquals(0,iListener.copyFailureCalls);
// copy
fromCopy.copy(toFolder, fromCopy.getName(), fromCopy.getExt());
assertTrue(fromCopy.isValid());
assertEquals(1,iListener.beforeCopyCalls);
assertEquals(1,iListener.copySuccessCalls);
iListener.clear();
try {
// success
assertEquals(0,iListener.copySuccessCalls);
assertEquals(0,iListener.copyFailureCalls);
// move to itself => failure
fromCopy.copy(toFolder, fromCopy.getName(), fromCopy.getExt());
fail();
} catch (IOException ex) {
// failure
assertEquals(0,iListener.copySuccessCalls);
assertEquals(1,iListener.copyFailureCalls);
}
}
示例12: copySettingsFile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Copy settings file from Module Components module folder (Windows2/Components)
* to Local Components folder (Windows2Local/Components). */
private void copySettingsFile (FileObject fo) throws IOException {
if (DEBUG) Debug.log(PersistenceManager.class, "copySettingsFile fo:" + fo);
FileObject destFolder = getComponentsLocalFolder();
try {
fo.copy(destFolder,fo.getName(),fo.getExt());
} catch (IOException exc) {
String annotation = NbBundle.getMessage(PersistenceManager.class,
"EXC_CopyFails", destFolder);
Exceptions.attachLocalizedMessage(exc, annotation);
LOG.log(Level.INFO, null, exc);
}
}
示例13: testDisableIBInFSEvents
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDisableIBInFSEvents () throws Exception {
CommandHandler handler = new CommandHandler();
Mercurial.LOG.addHandler(handler);
Mercurial.LOG.setLevel(Level.ALL);
File file = createFile(getWorkTreeDir(), "aaa");
commit(file);
FileObject fo = FileUtil.toFileObject(file);
fo.delete();
assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file).getStatus());
assertFalse(handler.commandInvoked);
fo.getParent().createData(file.getName());
assertNull(HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file));
assertFalse(handler.commandInvoked);
File copy = new File(file.getParentFile(), "copy");
fo.copy(fo.getParent(), copy.getName(), "");
assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(copy), null, null).get(copy).getStatus());
assertFalse(handler.commandInvoked);
File renamed = new File(file.getParentFile(), "renamed");
FileLock lock = fo.lock();
fo.move(lock, fo.getParent(), renamed.getName(), "");
lock.releaseLock();
assertEquals(FileInformation.STATUS_VERSIONED_ADDEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(renamed), null, null).get(renamed).getStatus());
assertEquals(FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY, HgCommand.getStatus(getWorkTreeDir(), Collections.<File>singletonList(file), null, null).get(file).getStatus());
assertFalse(handler.commandInvoked);
}
示例14: copyFO
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void copyFO (File from, File to) throws DataObjectNotFoundException, IOException {
FileObject foFrom = FileUtil.toFileObject(from);
assertNotNull(foFrom);
FileObject foTarget = FileUtil.toFileObject(to.getParentFile());
assertNotNull(foTarget);
FileLock lock = foFrom.lock();
try {
foFrom.copy(foTarget, getName(to), getExt(to));
} finally {
lock.releaseLock();
}
}
示例15: performAction
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected void performAction(Node[] activatedNodes) {
Node node = activatedNodes[0];
FileObject fo = node.getLookup().lookup(FileObject.class);
if (fo != null) {
FileChooserBuilder builder = new FileChooserBuilder(SaveAsAction.class);
builder.setDirectoriesOnly(false);
builder.setApproveText("Save");
builder.setControlButtonsAreShown(true);
builder.setTitle("Save As...");
builder.setFilesOnly(true);
builder.setFileFilter(new FileNameExtensionFilter(fo.getExt(), fo.getExt()));
JFileChooser chooser = builder.createFileChooser();
chooser.setSelectedFile(new File(fo.getNameExt()));
int resp = chooser.showSaveDialog(findDialogParent());
if (JFileChooser.APPROVE_OPTION == resp) {
File saveFile = chooser.getSelectedFile();
if (saveFile != null) {
try {
saveFile.getParentFile().mkdirs();
FileObject dfo = FileUtil.toFileObject(saveFile.getParentFile());
if (dfo == null) {
NotifyDescriptor nd = new NotifyDescriptor.Message("Unable to Save file!", NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notifyLater(nd);
return;
}
if (saveFile.exists()) {
saveFile.delete();
}
fo.copy(dfo, saveFile.getName(), "");
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
}