Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2007

Tip: Looking for answers? Try searching our database.

File Reading

Thread view: 
M. Hamzah Khan - 28 Jun 2007 15:03 GMT
Hi everyone,

I was just wondering what the class was called that allowed you to read
a file in the form:

[blehName]
blehMoo = Something
BlehMeow = SomethingElse
BlehWoff = SomethingElseAgain

[blehName2]
blehMoo = Something
BlehMeow = SomethingElse
BlehWoff = SomethingElseAgain

I remember seeing something that allowed you to do this, but i've
completely forgotten what it was.

Anyone know what it was?

Hamzah

Signature

M. Hamzah Khan
Website: http://www.hamzahkhan.com

Flo 'Irian' Schaetz - 28 Jun 2007 15:13 GMT
And thus spoke M. Hamzah Khan...

> I was just wondering what the class was called that allowed you to read
> a file in the form:

You probably want to use the java.util.Properties class:

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html

Flo
Real Gagnon - 28 Jun 2007 15:33 GMT
> I was just wondering what the class was called that allowed you to read
> a file in the form:
[quoted text clipped - 11 lines]
> I remember seeing something that allowed you to do this, but i've
> completely forgotten what it was.

That's an INI file. It' a common file structure in the Windows world.

In Java, the corresponding structure is a Properties file.

The main difference is that you can't group entries with [...] with
Properties, you need to add a prefix.

ex:

blehName.blehMoo = Something
blehName.BlehMeow = SomethingElse
blehName.BlehWoff = SomethingElseAgain

blehName2.blehMoo = Something
blehName2.BlehMeow = SomethingElse
blehName2.BlehWoff = SomethingElseAgain

See http://www.rgagnon.com/javadetails/java-0024.html

Bye.
Signature

Real Gagnon  from  Quebec, Canada
* Java, Javascript, VBScript and PowerBuilder code snippets
* http://www.rgagnon.com/howto.html
* http://www.rgagnon.com/bigindex.html

Roedy Green - 28 Jun 2007 19:54 GMT
On Thu, 28 Jun 2007 14:03:05 GMT, "M. Hamzah Khan"
<hamzah@hamzahkhan.com> wrote, quoted or indirectly quoted someone who
said :

>[blehName]
>blehMoo = Something
[quoted text clipped - 8 lines]
>I remember seeing something that allowed you to do this, but i've
>completely forgotten what it was.

I wrote a program called INI that reads such files into an internal
tree format then sorts and tidies them and writes them back.  You
could cannibalise it.  See http://mindprod.com/products.html#INI
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
M. Hamzah Khan - 29 Jun 2007 19:26 GMT
> On Thu, 28 Jun 2007 14:03:05 GMT, "M. Hamzah Khan"
> <hamzah@hamzahkhan.com> wrote, quoted or indirectly quoted someone who
[quoted text clipped - 20 lines]
> The Java Glossary
> http://mindprod.com

Oh great, I'll try that :D.
I think I was originally looking for the properties class, but I think
your program will work better.

Thanks

Hamzah

Signature

M. Hamzah Khan
Website: http://www.hamzahkhan.com

Arne Vajhøj - 01 Jul 2007 01:09 GMT
>> I wrote a program called INI that reads such files into an internal
>> tree format then sorts and tidies them and writes them back.  You
>> could cannibalise it.  See http://mindprod.com/products.html#INI
> Oh great, I'll try that :D.
> I think I was originally looking for the properties class, but I think
> your program will work better.

Even if it is technical better it would be a good thing to
do it the Java way. All java programmers knows properties
files.

Arne
Roedy Green - 04 Jul 2007 03:56 GMT
On Fri, 29 Jun 2007 18:26:20 GMT, "M. Hamzah Khan"
<hamzah@hamzahkhan.com> wrote, quoted or indirectly quoted someone who
said :

>Oh great, I'll try that :D.
>I think I was originally looking for the properties class, but I think
>your program will work better.

The properties file format does not have [xxxx] elements and it has
the most bizarre scheme for handling Unicode.

see http://mindprod.com/jgloss/properties.html

My class gives you a tree of [sections], each with x=y lines hanging
off it, (sorted). eacgh of those with some comments haning off that.
It is all nicely parsed for you.  I wrote it to sort the sections and
sort the line and get rid of excess white space to make ini files
easier to read.

The ugliest feature about ini files is they have different encodings,
but the encoding is not marked in the file. You are just supposed to
know.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Koalla - 12 Jul 2007 23:14 GMT
Hi Hamzah try with Properties class .
You will be able to load the key/value and then read them .
Enjoy It!

M. Hamzah Khan a écrit :
> Hi everyone,
>
[quoted text clipped - 17 lines]
>
> Hamzah


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.