我有一个JEdit (BeanShell)宏,它打开一个特定的文件,然后立即将该文件保存到我的c:\temp文件夹中(这样我就不会意外地更新实际的文件)。
下面是bean shell代码:
logFilePath = "c:\\temp\\aj.txt";
jEdit.openFile( view , logFilePath );
_buffer = jEdit.getBuffer(logFilePath);
_buffer.save(view,"c:\\temp\\backup.txt",true);这会给我以下错误:
I/O Error
Each buffer can only execute one input/output operation at a time.
Please wait until the current operation finishes
(or abort it in the I/O progress monitor) before starting another one. 我曾尝试添加一个while循环来等待buffer.isLoaded()为真,但这只是进入了无限循环。
真正起作用的似乎是弹出一个消息框( Macros.message )。然而,我真的不想有这种不必要的对话。
我不太懂java,所以如果我犯了一个新手错误,请告诉我。
更新:
添加了我自己的答案,以显示从Serhii's answer指向的代码。
发布于 2008-11-17 18:04:16
您可以通过调用VFSManager.waitForRequests();来尝试this solution。
发布于 2008-11-18 09:54:02
这是可行的
这是上面Serhii's answer指向的代码。
在jEdit.openFile()命令后添加VFSManager.waitForRequests();。
完整代码
logFilePath = "c:\\temp\\aj.txt";
jEdit.openFile( view , logFilePath );
VFSManager.waitForRequests();
/*
VFSManager.waitForRequests();
jEdit waits then for the file to be completely loaded before continuing
... It's designed for waiting on all 'pending I/O requests'".
*/
_buffer = jEdit.getBuffer(logFilePath);
_buffer.save(view,"c:\\temp\\backup.txt",true);发布于 2013-09-28 00:38:15
你也可以不那么大胆地去做。
调用:-)
https://stackoverflow.com/questions/295956
复制相似问题