Garbage characters in Documentation accessed from menu
Brought to you by:
olsonw
When you read documentation from the Help menu, there are sometimes garbage characters at the end of the document (more specifically, portions of the text are repeated). This appears to be an artifact from the code I use to read the text files from .jar; I will look into it, but since a) it is only a formatting bug, and b) the entire text is there anyway; there is just some more at the end, I don't think I will spend too much time on this one.
Logged In: YES
user_id=1714576
Originator: NO
This has to do with the FileFunctions.readTextStream method. The method in question uses hard coded values for StringBuilder and char[] array. Below is a reworked method for DocumentFactory.getDocumentText which does not have a problem with repeating text. I have tested this running from source on a Windows XP machine.
private static String getDocumentText(String documentName) {
try{
File f = new File(JarLoader.getSystemResource(documentName).toURI());
FileReader reader = new FileReader(f);
int fileSize = (int)f.length();
char[] chars = new char[fileSize];
StringBuilder sb = new StringBuilder(fileSize);
while(reader.read(chars) > -1) {
sb.append(String.valueOf(chars));
}
reader.close();
return sb.toString();
} catch (Exception e) {
return "Cannot open file" + documentName + ".\n\nIf you are running from source, this is normal.\n" +
"If you are running from a compiled version, this is not - please contact " +
"Wyatt Olson <wyatt.olson@gmail.com>.";
}
}
Hope it helps. I also hope that the comment box does not mangle the sample code too bad.
Regards,
-J
Logged In: YES
user_id=1200533
Originator: YES
Fixed in 2.1.12. Many thanks to JST for pointing out the source of the bug.
Logged In: YES
user_id=1200533
Originator: YES
Closing. I have confirmed the fix on multiple platforms (Windows and OS X).