profile string

Do you know profile string in VB ? I want to ask howto make a good class for GetProfileString and WriteProfileString method like in VB ?
ImeldaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadMikeCommented:
What about giving us an example of a ProfileString for us non-VB programmers?
0
ImeldaAuthor Commented:
There is .INI file that contained plain text that order like this :

[SectionName]
KeyName = stringValue
 .
 .
 .

Then I call getProfileString method like this :

String myProfile = getProfileString(INIfileName,SectionName,KeyName,defaultString);

it will retrieve stringValue or if there are no stringValue (keyName = <empty>), it will return the defaultString.

In another hand, I will use writeProfileString to update the stringValue of a KeyName in a Section.

writeProfileString(INIfileName,SectionName,KeyName,valueString)





0
heyhey_Commented:
java.util.Properties supports the same functionality.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

MadMikeCommented:
We use our own class to read and write Ini-Files where I work. But I can't send it to you because it's: 1. Not my code, 2. it's very bad written stuff 3. it's really easy to write your own parser/generator.

Additionaly as heyhey_ stated. java.util.Properties have similar functionality. But AFAIK it does *not* support sections like in .ini Files.

Hey, and when we are at it, how about using XML? ;) Like this can ride the latest hype-wave. Think about it :))
0
ImeldaAuthor Commented:
heyhey,could write for me any code how to use java.util.Properties. Because it is a new sintax for me.
0
heyhey_Commented:
something like ...

Properties props = new Properties();
props.put("key1", "val1");
FileOutputStream fos = new FileOutputStream("config.props");
props.save(fos);

......
later
.....
FileInputStream fis = new FileInputStream("config.props");
Properties props = new Properties();
props.load(fis);
String st = props.getProperty("key1");
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
heyhey_Commented:
btw. you can even simulate .ini file sections - just use composite names:

audio.driver = dami.drv
audio.default = hello.au
audio.lastchoice = 1
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.