处理TCP DUMP的时候 FileInputStream file = new FileInputStream(path1);
this.output = new BufferedWriter(new FileWriter(path2));
DataInputStream dis = new DataInputStream(file); for (int t = 0; t < 4; t++) {
if ((c = dis.read()) != -1) {
result = intToByteArray(c, 1);
temp = temp + getHex(result);
i++;
} else
return (0);
}总是提前就Return了 而且还每次都同一个位置停止
文件越大丢的越多

解决方案 »

  1.   

    for (int t = 0; t < 4; t++) {
    if ((c = dis.read()) != -1) {
    result = intToByteArray(c, 1);
    temp = temp + getHex(result);
    i++;
    } else
    return (0);
    }
    这里只进行4次循环
    试试while(true){
    if ((c = dis.read()) != -1) {
    result = intToByteArray(c, 1);
    temp = temp + getHex(result);
    i++;
    } else
    return (0);
    }
    试试看
      

  2.   

    for (int t = 0; t < 4; t++) {
    if ((c = dis.read()) != -1) {
    result = intToByteArray(c, 1);
    temp = temp + getHex(result);
    i++;
    } else
    return (0);
    }
    这里只进行4次循环
    试试while(true){
    if ((c = dis.read()) != -1) {
    result = intToByteArray(c, 1);
    temp = temp + getHex(result);
    i++;
    } else
    return (0);
    }
    试试看
      

  3.   

    噢 这个是分段处理
    4这个后面还有一个大循环的
    主要是dis.read()无故返回-1...