[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

profile string

Posted on 1999-12-10
7
Medium Priority
?
214 Views
Last Modified: 2010-05-18
Do you know profile string in VB ? I want to ask howto make a good class for GetProfileString and WriteProfileString method like in VB ?
0
Comment
Question by:Imelda
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Expert Comment

by:MadMike
ID: 2274512
What about giving us an example of a ProfileString for us non-VB programmers?
0
 

Author Comment

by:Imelda
ID: 2276025
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
 
LVL 16

Expert Comment

by:heyhey_
ID: 2276328
java.util.Properties supports the same functionality.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 2

Expert Comment

by:MadMike
ID: 2278155
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
 

Author Comment

by:Imelda
ID: 2278890
heyhey,could write for me any code how to use java.util.Properties. Because it is a new sintax for me.
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 200 total points
ID: 2279624
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
 
LVL 16

Expert Comment

by:heyhey_
ID: 2282726
btw. you can even simulate .ini file sections - just use composite names:

audio.driver = dami.drv
audio.default = hello.au
audio.lastchoice = 1
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question