Java file reader...?
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.
"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.
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.
Java file reader ..?
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.
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?