I have demo.properties file from this I'm able to load file and iterate to get all values present in it.
hibernate.connection.username=jack
hibernate.connection.password=queen
hibernate.connection.url=jdbc:jtds:sqlserver://localhost/cabinet
But When i get Line 1(able to get line by line but unable to get specific string) and i want to populate jack and store into username String similarly queen into password String and localhost into database String.This is my code/logic to get values.
procedure InitializeWizard;
var
xmlInhalt: TArrayOfString;
k : Integer;
CurrentLine : String;
Uname : String;
Password : String;
HostName : String;
STR : String;
begin
LoadStringsFromFile('C:\demo.properties', xmlInhalt);
for k:=0 to GetArrayLength(xmlInhalt)<>-1 do
begin
CurrentLine := xmlInhalt[k];
MsgBox(CurrentLine, mbError, MB_OK);
if (Pos('hibernate.connection.username=', CurrentLine) <>-1 ) then
begin
MsgBox(CurrentLine, mbError, MB_OK);
Uname := Pos('://', CurrentLine);
STR :=IntToStr(Uname);
STR :=IntToStr(Length('://'));
Password := Pos(':1', CurrentLine);
HostName :=Password -Uname;
end;
end;
end;
please Help me to get my requirement.Your help will be appreciated.
If the
TStrings
class had publishedNameValueSeparator
andValues
properties, I would suggest using it. But it hasn't, so here's a code to workaround (it usesTArrayOfString
, but it would be easy to modify it for theTStrings
class):