Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-20-2008, 10:00 AM
Member
 
Join Date: May 2008
Posts: 69
Rep Power: 0
prabhurangan is on a distinguished road
Default 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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-21-2008, 04:54 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-21-2008, 07:44 AM
Member
 
Join Date: May 2008
Posts: 69
Rep Power: 0
prabhurangan is on a distinguished road
Default 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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-21-2008, 08:19 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,525
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
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?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need help with file reader syed.shuvo New To Java 6 09-27-2008 07:43 PM
FileReader / Buffered Reader sepaht New To Java 9 07-10-2008 08:05 PM
[SOLVED] reader and writer on same file handle Nicholas Jordan Advanced Java 11 07-01-2008 03:39 AM
A simple DOM reader Java Tip Java Tips 0 01-03-2008 09:24 AM
help with file reader jason27131 New To Java 1 08-01-2007 03:03 AM


All times are GMT +2. The time now is 02:53 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org