| Author |
How to read a file, then select a line and use what comes after the selected characters.
|
matthew christensen
Greenhorn
Joined: Sep 14, 2010
Posts: 17
|
|
So I'm writing a simple event logging program for my game. But I have a problem. I have a .properties file. That contains 3 lines of text(lines of text below)
I want to scan the file, then somehow use the data darkened below to set the path, max file size, and the save path.
max-file-size=15
log-path=C:\LWLW\
log-file-name=LWLog.txt
How would I go about doing this? I tried google for answers but alas nothing came of my search. Thanks guys!
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
|
If you were going to describe the bolded part in English, how would you do that?
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
No, actually you said you have a .properties file. So you don't have to parse it yourself (which is what I was mistakenly getting at in my previous post). Just create a Properties object to read that file and extract the properties from it. (You'll have to format it correctly, though, I think the backslash has a special meaning in a .properties file, check that out.)
|
 |
matthew christensen
Greenhorn
Joined: Sep 14, 2010
Posts: 17
|
|
|
What do you mean by a properties object?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
|
Start here: Java Tutorials
|
 |
matthew christensen
Greenhorn
Joined: Sep 14, 2010
Posts: 17
|
|
Thanks! got it to work!
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
You’re welcome and well done.
|
 |
matthew christensen
Greenhorn
Joined: Sep 14, 2010
Posts: 17
|
|
Here's the code if anyone is interested!
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
|
Thank you for showing us that.
|
 |
 |
|
|
subject: How to read a file, then select a line and use what comes after the selected characters.
|
|
|