var F: TFileStream; FSize, Index: Integer; Data: Array[1..1000] of Single; begin F := TFileStream.Create('F:\aa.data', fmOpenRead); FSize := F.Size; Index := 0; while F.Position < FSize do begin Inc(Index); F.Read(Data[Index], 4); F.Seek(16-4+2, soCurrent); //2表示回车换行符号#13#10 end; F.Free; end;———————————————————————————————————— 宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。 ————————————————————————————————————
>>一个二进制文件中,共有n行, 二進制好象沒有換行的啊!!>>每一行有16个字节,要将第3、5、7、9、11……行 修改故國的代碼:var F: TFileStream; FSize, Index: Integer; Data: Array[1..1000] of Single; begin F := TFileStream.Create('F:\aa.data', fmOpenRead); FSize := F.Size; Index := 0; while F.Position < FSize do begin Inc(Index); F.Read(Data[Index], 4); F.Seek(16-4, soCurrent); //如果沒有 回车换行符号#13#10 就不用 + 2 了 end; F.Free; end;
F: TFileStream;
FSize, Index: Integer;
Data: Array[1..1000] of Single;
begin
F := TFileStream.Create('F:\aa.data', fmOpenRead);
FSize := F.Size;
Index := 0;
while F.Position < FSize do
begin
Inc(Index);
F.Read(Data[Index], 4);
F.Seek(16-4+2, soCurrent); //2表示回车换行符号#13#10
end;
F.Free;
end;————————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
————————————————————————————————————
二進制好象沒有換行的啊!!>>每一行有16个字节,要将第3、5、7、9、11……行
修改故國的代碼:var
F: TFileStream;
FSize, Index: Integer;
Data: Array[1..1000] of Single;
begin
F := TFileStream.Create('F:\aa.data', fmOpenRead);
FSize := F.Size;
Index := 0;
while F.Position < FSize do
begin
Inc(Index);
F.Read(Data[Index], 4);
F.Seek(16-4, soCurrent); //如果沒有 回车换行符号#13#10 就不用 + 2 了
end;
F.Free;
end;