JEdit 宏 - 打开和保存文件
我有一个 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()
为 true,但这只是进入无限循环。
似乎有效的是弹出一个消息框(Macros.message
)。 不过,我真的不想进行这种不必要的对话。
我不太懂java,所以请告诉我我是否犯了菜鸟错误。
更新:
添加了我自己的答案,以显示 Serhii 的答案指向的代码。
I have a JEdit (BeanShell) macro which opens a specific file then immediately saves the file to my c:\temp folder (so that I don't accidentally update the real file).
Here is the bean shell code:
logFilePath = "c:\\temp\\aj.txt";
jEdit.openFile( view , logFilePath );
_buffer = jEdit.getBuffer(logFilePath);
_buffer.save(view,"c:\\temp\\backup.txt",true);
This gives me the following error:
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.
I have tried adding a while loop to wait until buffer.isLoaded()
is true, but that just goes into an infinite loop.
What does seem to work is popping up a message box (Macros.message
). However, I really don't want to have this unnecessary dialogue.
I don't know much java, so please tell me if I'm making a rookie mistake.
Update:
Added my own answer to show the code pointed to from Serhii's answer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试此解决方案,调用
VFSManager.waitForRequests() ;
。You can try this solution, calling
VFSManager.waitForRequests();
.这是有效的
这是上面 Serhii 的答案 指向的代码。
添加
VFSManager.waitForRequests();
在jEdit.openFile()
命令之后。完整代码
This Works
This is the code pointed to by Serhii's answer, above.
Add
VFSManager.waitForRequests();
after thejEdit.openFile()
command.Full Code
你也可以不那么大胆。
You can also do it less bold.