我有一个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指向的代码。
最佳答案
您可以尝试this solution,调用VFSManager.waitForRequests();
。
关于java - JEdit宏-打开并保存文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/295956/