You need to read every attribute in the file when you parse the PACP file. But each read the first character of each line of content is swallowed, looking for a long time do not know why, and then see the reading of the use of the Read () method, and the return value is type int, The default should be 0 when the variable is initialized, probably just swallowed the first one. (Still not quite clear) read reads only one byte and does not automatically read the next one only reads the first byte and the pointer is not the same thing, but if you use the ReadLine () function, this will not happen.
Of course, this is only the case when using InputStream, if the direct use of filereader this problem will not appear, using read will also read the first character, may be the buffer in the mischief, and the possibility is very large, If you do not use the buffer directly with FileReader can also be fully read, but if the use of buffer, and the use of int return the value of read, then will inevitably have to swallow the first character of the consequences, the specific code posted, as follows:
1 package Com.zaj;
2 3 Import Java.io.BufferedReader;
4 Import Java.io.BufferedWriter;
5 Import Java.io.FileReader;
6 Import Java.io.FileWriter;
7 Import java.io.IOException; 8 9 public class ReadLine {one public static void ReadLine (string file, String writerfile) {13
try {FileReader fr = new FileReader (file); BufferedReader br = new BufferedReader (FR); FileWriter FW = new FileWriter (writerfile);
Write file operations, the resulting file corresponding to the contents of the document written, Writerfile.
//system.out.println (Fw.getencoding ())//utf-8 default BufferedWriter bw = new BufferedWriter (FW);
Readoneline String;
int l; while ((L = br.read ())!=-1) {//This will result in swallowing the first character. Readoneline = new String (Br.readline (
). GetBytes (), "utf-8");
//system.out.println (Readoneline); /*string l;
while ((L = br.readline ())!= null) {//if readLine () is intact readoneline = new String (
Br.readline (). GetBytes (), "utf-8");
//system.out.println (Readoneline);
* * Bw.write (readoneline);
Bw.newline ();
System.out.println (Readoneline);
Bw.flush ();
Br.close ();
Panax Notoginseng bw.close ();
Br.close ();
Fw.close ();
Fr.close (); A/D catch (IOException e) {e.printstacktrace ();
ID Main (string[] args) {readline ("D:\\tddownload\\test\\packwifi.pcap", "d:\\tddownload\\test\\packwifi.txt"); 48} 49}