Results 1 to 4 of 4
Thread: Java file reader...?
- 11-20-2008, 10:00 AM #1
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
Java file reader...?
Hi Members,
I have to read a file and append to string. In this i have to check for my start and end 'Delimiter'. and the data read from file should be appended to a first string until the 'start' delimiter is found, once the start delimiter is found, the remaining part of the file, upto the 'end delimiter' should be appended to another string.
Example: File.txt
"This is a sample file for your information. JESUS Please help me in this , this logic code should be done in java. MARY I tried using String.split() function but i could not get the solution."
This is the content of the file. Here im setting my 'start delimiter' as 'JESUS' and 'end delimiter' as 'MARY' and until the start delimiter is found i should read the data from file and append it to first string and once after the first delimiter is found and until the end delimiter is found i have to append it to another string.
So, the output should be :
String firstData = "This is a sample file for your information. I tried using String.split() function but i could not get the solution.";
String secondData = "Please help me in this , this logic code should be done in java. ";
Looking forward for the logic code done in Java.
Regards,
Prabhu.
- 11-21-2008, 04:54 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Is that file contain those text as a paragraph or as a collections of lines?
One of the simple way I can see is, read a line and split/tokernize into words based on the space character. So the result you have is in an array. Once you found the delimiters store the result in another array and retrieve a string from there, and do the process.
- 11-21-2008, 07:44 AM #3
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
Java file reader ..?
Eranga,
This is a collection of lines. FYI. This is a backup *.sql file, I have to read the file and store it to a string and once my start delimiter is found and upto the end delimiter i define it should save it to another string.
Prabhu.
- 11-21-2008, 08:19 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you have a collection of lines, it's much easier. As I said read a line-by-line and split in into words based on the space character. Then validate each word for your delimiter.
Did you try anything so far?
Similar Threads
-
[SOLVED] Need help with file reader
By syed.shuvo in forum New To JavaReplies: 6Last Post: 09-27-2008, 07:43 PM -
FileReader / Buffered Reader
By sepaht in forum New To JavaReplies: 9Last Post: 07-10-2008, 08:05 PM -
[SOLVED] reader and writer on same file handle
By Nicholas Jordan in forum Advanced JavaReplies: 11Last Post: 07-01-2008, 03:39 AM -
A simple DOM reader
By Java Tip in forum Java TipReplies: 0Last Post: 01-03-2008, 09:24 AM -
help with file reader
By jason27131 in forum New To JavaReplies: 1Last Post: 08-01-2007, 03:03 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks