I have the following code for a series of file drawdowns using IDHttp.Get, the contents of the files
procedure Tform1.GetData;
{***************************}
var
fs2 : tfilestream;
s : char;
begin
Sleep(1000);
idhttp1.HandleRedirects := TRUE;
fsjson2 := tfilestream.Create((GstrPath+GstrRep+'-'+GstrHome+'.json'),fmcreate);;
idhttp1.IOHandler := idssl;
IdSSL.SSLOptions.SSLVersions := [sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2];
IdSSL.SSLOptions.Mode := sslmUnassigned;
try
idhttp1.Get(GstrURL,fs2);
except
on E: Exception do
begin
rememo1.Lines.Add('Seems to be an issue, trying again...');
Sleep(500);
idhttp1.Get(GstrURL,fs2);
end;
end;
I would like there to be a method of either trimming the first character although I don't think this is possible, or replacing the first character (which comes with the info by default) with a blank character. I think it's a little out of my skillset at the moment to do, and so would appreciate any help someone can give.
Thanks
Ant
There are several possible solutions:
You are receiving data into a stream. If you want to trim the first character, you could, at the place you handle the stream, skip reading the first character and throw it away.
If you have no control on where the receiving stream is handled, then you may simply create a new stream and loop reading all characters from the receiving stream and write them into the destination stream. Then throw away the received stream and keep the one you created.
If the data received (currently the stream) is not too big, you could receive it into a string instead of a stream, then you can trim/delete/insert anything with simple string manipulation, and finally write the modified string back to a stream for later use.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.