04-11-29 19:54 These days focus on 388 backup file format research, the tools used are mainly NetBeans, 010 Editor, Excel. NetBeans used to test the law of the analysis office, implement it with Java language; 010 Editor is mainly in the form of binary or hexadecimal display of the analysis file, strong function, mainly in display and combination; Excel is used to format the display Hexadecimal blocks show the corresponding text or values, and you can add a comment, labeled unknown areas, and leave traces for the next step and prepare. The Java language is far from cooked, and it is very sufficient and sweat from the operational operation of this application level. The following records that some of the errors made in Java use and the individual think that you need a focus, you are small things, but ME thinks that you will have this low-level mistake in the future ^ _ ^
First, the value in Byte [].
Read 512 bytes from the file to Byte [] ba; BYTE should be 0 to 255, but the negative value appears directly to the int type. The ME wolf, which was just started, and later found this reason. Use I = ba [1] & 0xFF;
Second, String and StringBuffer.
The former is not changeable, the latter is variable. I have wanted to re-value the String type variable, huh, huh, unfired. Later, StringBuffer will be used for possible strings. One point is the string of the incoming function. If you want to pass the result, the latter must be used, that is, StringBuffer.
Third, the SWTICH CASE statement forgets the BREAK termination in CASE.
This is really damaging. At that time, it was not in the format, which was not very certain, reported a bunch of errors, but I had to analyze, analyze and analyze it. I feel that there is no problem. I look back, I am, I have forgotten BREAK. The program will be executed. The result of the original branch is all implemented, it is not bad.
Fourth, the use of global variables.
If the memory is not very good, the use of global variables must be cautious, so afraid that it is just a longer function. The program is to accept command line parameters. If there is no parameter specifying all files in the current directory as parameters by default. Because the function of the default file list is later added, the debug is unsuccessful ME to find a new code to find, find it, no found. ME even found DOCS carefully to check the file instruction gear, and wrote a lot of system.out.println (); to gradually determine the process, and then unexpectedly found that the use of Args [i]. Oh, there is no command line parameter, and it is natural to have no worse, change it to file [] fa; fa [i] to solve the problem. Temporary variables with the declaration, throw it out, do not do global design. Int filelen; It is not as fast as file.length () to accurate.
5. Hashcode and equals.
When adding an object to a collection, the object will call the method that has existed. At this time, the corresponding method is to call the corresponding method, and the order of calls of HashCode and Equals is the previous person, then the latter. Override These methods can define their own objects that show their ideas in comparison.
6. Expression of Unicode.
Direct char c = / uf099; is not, the correct way is Char C = '/ uf099';
Seven, display a value of the HEX value.
INT corresponds to Integer, and lon corresponds to long. In order to see some, the idea will continue TouchPercaration.
Eight, Continue in the for statement is the meaning of continuing, and there is While. Terminate this operation and continue the next loop.
Nine, using Calendar instead of DATE while adding or subtraction, formatting DateFormat. The use of Locale is formatted.
10. If you don't want to identify E text, don't miss the system.out used by catch.