Re: extract a text, from a text file, that is contained between two strings
- From: Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 31 May 2008 23:38:21 GMT
On Fri, 30 May 2008 11:38:49 -0700 (PDT), Giordano
<mejoro82@xxxxxxxxx> wrote, quoted or indirectly quoted someone who
said :
Can you tell me your best way to
extract a text, from a text file, that is contained between two
strings
example: we have a file which contains these words
<<
Ei fu. Siccome immobile,
dato il mortal sospiro,
stette la spoglia immemore
orba di tanto spiro,
...
I want extract that word contained between the 2 words "la" and
"immemore"
I do this sort of thing alls the time. I use HunkIO.readEntireFile to
get the file into a String in Ram and HunkIO.writeEntireFile to put it
back.
See http://mindprod.com/products1.html#HUNKIO
Just use String.indexOf to find your strings. use the variants of it
that take an starting offset.
Put it back together with concatenation or a StringBuilder.
see http://mindprod.com/jgloss/stringbuilder.html
http://mindprod.com/jgloss/string.html
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.
- Follow-Ups:
- Prev by Date: Re: ok, i've tried, any hlp, [self explanatory]
- Next by Date: Re: 'javac is not an internal or external command' this is the error iam getting while compiling a simple program
- Previous by thread: Re: ok, i've tried, any hlp, [self explanatory]
- Next by thread: Re: extract a text, from a text file, that is contained between two strings
- Index(es):
Relevant Pages
|
|