如何在 Netbeans 中恢复 java 文件以前的格式

发布于 2024-11-26 03:36:04 字数 430 浏览 3 评论 0原文

我使用 BufferedWriter 将一些文本写入不同的文件,作为 Netbeans 中代码生成器框架的一部分。当我运行主类进行测试时,我在上一个包中找不到所有参与测试的类的文件。相反,它们位于默认包中,当我打开文件时,我无法看到正常的文本。我只看到一个格式化窗口,顶部有一条长水平线,显示错误; “非法字符\0”。

文件的大小仍然等于每个文件中的文本,我认为问题只是文本格式。我使用了“本地历史记录”>“反向删除”,但没有得到任何更改。有谁知道如何解决这个 pbm 吗?我使用的代码如下,我在代码中多次使用 call out.write("some text here") 来编写 gen 的文本。代码到输出文件。

    BufferedWriter out = new BufferedWriter(new FileWriter("MyClass.java"));

I was using BufferedWriter to write some text to different files as part of a code generator framework in Netbeans. when I ran the the main class for a test,I couldn't find the files of all the classes that were involved in the test in the previous package. Rather they are in the default package and when I opened the files, I was not able to see the normal text. I only see a formatted window with one long horizontal line at the top, displaying the error; "illegal character \0".

The size of the files is still equivalent to the text in each one of them, and I think the problem is only of format of text.I used Local History>Reverse deleted only to get no change. Does any one have an idea how to solve this pbm? The code I used is the following ,and I used the call out.write("some text here") quite many times in my code, to write texts of the gen. code to the output file.

    BufferedWriter out = new BufferedWriter(new FileWriter("MyClass.java"));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余罪 2024-12-03 03:36:04

是的,我尝试使用具有十六进制功能的编辑器...但我仍然得到一个空窗口。您可以建议什么最好的编辑器吗?

听起来除了 \000 字符之外,文件可能真的是空的;也就是说,你已经把它们彻底扔掉了。您可以通过查看操作系统报告的文件大小来确认这一点。

如果您已删除文件,NetBeans 不太可能取回旧内容。您将需要从版本控制(SVN、GIT,无论您使用什么)或文件系统备份中恢复文件的最新版本。如果这不起作用,您也许可以使用文件恢复工具来恢复它们,但我对此表示怀疑。


这些课程是确保您的源文件在使用某些代码生成器更新之前安全地处于版本控制或备份中。

yes, I tried with hex capable ones...but I m still getting an empty window.Is there any best editor u may suggest though?

It sounds like the files may really be empty apart from that \000 character; i.e. you've completely trashed them. You can confirm this by looking at the file sizes as reported by the operating system.

If you have trashed the files, and it is unlikely that NetBeans can get the old contents back. You will need to restore latest versions the files from version control (SVN, GIT, whatever you are using) or from a file system backup. If that doesn't work you might be able to recover them with a file recovery tool, but I doubt it.


The lessons is to make sure your source files are safely in version control or backed up before you use some code generator to update them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文