*
The moose likes Beginning Java and the fly likes file i/o qustion .. please help !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "file i/o qustion .. please help !!" Watch "file i/o qustion .. please help !!" New topic
Author

file i/o qustion .. please help !!

shalu sharma
Ranch Hand

Joined: Sep 09, 2002
Posts: 51
Hi all,
My requirement is that i have a file eg : abc.txt, then I need to search the string 'black box'. let's say that i found 6 occurences of the string black box in my file abc.txt, now after this string black box, I have some text of type:
1, 2323, 9849438, 539039
2, 4394983, 494938, 4954095
3, 5o343049, 4934, 999349838
... and so on.
here I need to take out all the lines after string black box, which is not fixed there may be 10 or 20 lines. one more thing to note is that I have to only take out those after black box which have the value in next line always incremented by 1.
ie, if the sample file is of type :
black box
1, 3232, 32323, 32323, 54854
2, iuriu, 238372, 68685, 96589
3, uuery, 585, 459584, 59
kklsfjsjisiof
fsifsfsjsjklfsklfj
skfkljsf
black box
4, iuwieuo, wour, 3943434
5, oiieq, 4874, 945848
oritr]iprit]r
trotirtrtoorotirit
trtrtioirt]irtiurtrr
black box
6, iidsdjks, 88343, 95696586
7, iieuiure, 3847, 3943948
8, 73, itr, 849584, kkjfg
9, eirieu,iiuru, woeooiwe

So I don't have to take 'kklsfjsjisiof' after '3, uuery, 585, 459584, 59
also there is no fixed no of lines to expect after black box., it could vary. the only input the user would be providing is the filename and nothing else. so far I have been able to find all the occurences of string blackbox but am stuck after that.
Regards
shalu
SudhaPrakash Madanambedu
Greenhorn

Joined: Aug 06, 2002
Posts: 2
What do you mean by 'take out' those lines? Do you want to print them on console or write them to a file?
Anyway, put down your code here, we can try to repair it.


Sudha
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: file i/o qustion .. please help !!
 
Similar Threads
Generating random numbers with given properties
Threads
file i/o extracting strings from file ..
file i/o problems
String time validations(Javascript)