When AWK is used for data file detection, it is necessary to detect the data file. Check whether it meets the requirements. For example, the fields in the generated data file are separated by 0x06. Records are separated by line breaks (one record occupies one row ). A row contains 29 fields. Therefore, I only need to determine whether the field column is 29 after 0x06 is used in each row. If it is less than 29, the data is certainly faulty. Output the row number and column number of fields. After Online exploration, use the following statement: awk-F' [\ 06] ''{I = 1; while (I <NF) {I ++} if (I <29) {print FNR, NF;} '201301_152118_all1_info.txt use the preceding statement to detect the 201301_152118_all1_info.txt data file. If the data is incorrect, the row number and field column number are printed, and the bug is determined. Locate the bug. The bug can be solved. It's easy. Just filter out the carriage return and line feed. Use the following code to filter out null values: // block the null value and return the null String private String getString (String strInfo) {String result = ""; if (null! = StrInfo &&! "". Equals (strInfo) {Pattern p = Pattern. compile ("\ t | \ r | \ n"); Matcher m = p. matcher (strInfo); result = m. replaceAll (""); // filter the tab, press enter, and line feed} return result ;}