【发布时间】:2015-08-17 10:57:05
【问题描述】:
我有 demo.properties 文件,我可以加载文件并迭代以获取其中存在的所有值。
hibernate.connection.username=jack
hibernate.connection.password=queen
hibernate.connection.url=jdbc:jtds:sqlserver://localhost/cabinet
但是当我得到第 1 行(能够逐行获取但无法获取特定字符串)并且我想填充 jack 并将其存储到用户名字符串中,类似地,queen 到密码字符串和本地主机到数据库字符串。这是我的代码/获取值的逻辑。
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;
请帮助我满足我的要求。我们将不胜感激。
【问题讨论】:
标签: arrays string inno-setup pascalscript