Extract a portion from a line of a text-file

P

Prabh

Hi,
I'm rather new to Java and more of a Perl guy.
Could anyone give some ideas how to accomplish the following, please?

I need to extract certain information from a text-file and generate a new file.

"From" file:
=============
It is a .properties file with a series of property settings.

Setting1 = "Foo"
Setting2 = "Bar"


Generated File:
==============
Generated file would contain info along the lines,

Setting1 obtained from "From" file = Foo

--------------------------------------------------------------

Basically, for each property I need to extract its value.

In Perl I'd do something like,
$valueFromSetting1 = (split(/=/,$line))[1] if ( $line =~ /Setting1/ ) ;

Could anyone point me to the right Java docs, manuals I should read.

Thanks,
Prabh
 
M

Marco Schmidt

Prabh:
I'm rather new to Java and more of a Perl guy.
Could anyone give some ideas how to accomplish the following, please?

If you don't want to reuse the Properties class, take a look at the
API docs for String.split.

Regards,
Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top