L
L.Q
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠!
现在遇到一个技术难题,需要大家帮助,根据系统需求,我们目前正在开发的项目用java写webservices,Delphi7写客户端,数据以WideString类型传输,由于数据量大时,传输的速度会变慢,所以我们对数据进行特别处理,如下:
1、字符串java)压缩->编码(code64)->传输->解码(code64)->解压 (delphi)
这个从java 到 Delphi 的传输已经解决.
2、字符串Delphi)压缩->编码(code64)->传输->解码(code64)->解压 (java)
这个从Delphi到 Java 的传输解决不了.
请问,谁能帮助我们,非常感激!
下面,我再把我写的Delphi压缩解压两个函数贴出来,请大家指点.谢谢!
function MyCompressToJava(V: string): string;
var
Mysize: integer;
MyCompression: TCompressionStream;
temp, temp2: Tmemorystream;
begin
Mysize := length(v);
temp := Tmemorystream.Create;
MyCompression := TCompressionStream.Create(cldefault, temp);
MyCompression.Write(v[1], Mysize);
freeandnil(MyCompression);
temp.Position := 0;
temp2 := Tmemorystream.Create;
temp2.WriteBuffer(Mysize, sizeof(Mysize));
temp.SaveToStream(temp2);
freeandnil(temp);
temp2.Position := 0;
setlength(result, temp2.Size);
temp2.Read(result[1], temp2.Size);
freeandnil(temp2);
end;
function MyunCompressFormJava(V: string): string;
var
Mysize: integer;
MyUNCompression: TDeCompressionStream;
MemStream: Tmemorystream;
Buf: array[0..BufSize] of byte;
tmpStr :string ;
begin
try
//新创建MemStream
MemStream := Tmemorystream.Create;
//读取字符串v的第一个字符到length(v)到MemStream内存流中
MemStream.Write(v[1], length(v));
//设置指针的位置为开始位置
MemStream.Position := 0;
//MemStream.ReadBuffer(Buf,B
MyUNCompression := TDeCompressionStream.Create(MemStream);
//setlength(result, Mysize);
//从解压对象里读取Mysize长度的字符串
//MyUNCompression.ReadBuffer(result[1], Mysize);
MyUNCompression.Read(Buf, BufSize);
setlength(tmpStr,Length(Buf));
move(Buf[0],tmpStr[1],Length(Buf));
result:=tmpStr;
//释放资源
freeandnil(MyUNCompression);
freeandnil(MemStream);
except
on E :Exception do
begin
ShowMessage(E.Message);
end ;
end ;
end ;
现在遇到一个技术难题,需要大家帮助,根据系统需求,我们目前正在开发的项目用java写webservices,Delphi7写客户端,数据以WideString类型传输,由于数据量大时,传输的速度会变慢,所以我们对数据进行特别处理,如下:
1、字符串java)压缩->编码(code64)->传输->解码(code64)->解压 (delphi)
这个从java 到 Delphi 的传输已经解决.
2、字符串Delphi)压缩->编码(code64)->传输->解码(code64)->解压 (java)
这个从Delphi到 Java 的传输解决不了.
请问,谁能帮助我们,非常感激!
下面,我再把我写的Delphi压缩解压两个函数贴出来,请大家指点.谢谢!
function MyCompressToJava(V: string): string;
var
Mysize: integer;
MyCompression: TCompressionStream;
temp, temp2: Tmemorystream;
begin
Mysize := length(v);
temp := Tmemorystream.Create;
MyCompression := TCompressionStream.Create(cldefault, temp);
MyCompression.Write(v[1], Mysize);
freeandnil(MyCompression);
temp.Position := 0;
temp2 := Tmemorystream.Create;
temp2.WriteBuffer(Mysize, sizeof(Mysize));
temp.SaveToStream(temp2);
freeandnil(temp);
temp2.Position := 0;
setlength(result, temp2.Size);
temp2.Read(result[1], temp2.Size);
freeandnil(temp2);
end;
function MyunCompressFormJava(V: string): string;
var
Mysize: integer;
MyUNCompression: TDeCompressionStream;
MemStream: Tmemorystream;
Buf: array[0..BufSize] of byte;
tmpStr :string ;
begin
try
//新创建MemStream
MemStream := Tmemorystream.Create;
//读取字符串v的第一个字符到length(v)到MemStream内存流中
MemStream.Write(v[1], length(v));
//设置指针的位置为开始位置
MemStream.Position := 0;
//MemStream.ReadBuffer(Buf,B
MyUNCompression := TDeCompressionStream.Create(MemStream);
//setlength(result, Mysize);
//从解压对象里读取Mysize长度的字符串
//MyUNCompression.ReadBuffer(result[1], Mysize);
MyUNCompression.Read(Buf, BufSize);
setlength(tmpStr,Length(Buf));
move(Buf[0],tmpStr[1],Length(Buf));
result:=tmpStr;
//释放资源
freeandnil(MyUNCompression);
freeandnil(MemStream);
except
on E :Exception do
begin
ShowMessage(E.Message);
end ;
end ;
end ;