Reputation: 29
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"));
Upvotes: 0
Views: 706
Reputation: 719336
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.
Upvotes: 3