Results 1 to 1 of 1
- 10-15-2010, 10:18 AM #1
How can this be more simple? *seurch code*
I have a program that looks in a file for lines that start with: ">"
Let's say the file is:
> Hello
Cat
Fish
> Morning
Dog
Lama
Cow
Bat
> Night
Cat
Frog
Hamster
I made a program that looks if the word Morning is in the file. He looks for a sentence that begins with a ">" then he looks to the word behind it. And if there is a match, then he writes that word to an output file.
Now I also want that he takes the word Dog, Lama, Cow and Bat with him. So I want in the output file:
> Morning
Dog
Lama
Cow
Bat
I got him to the point where he writes
> Morning
in the output file. But I also need the lines below that don't start with an ">". I did use this code in my other program:
But for that one we needed a certain line part (number), and I was wondering if it would be posible that he looks every line after the matched ">". Besides putting everytime:Java Code:if (getal == 6) { getal = 0; if (line.indexOf(">")>=0) { // Write the output to a certain file. output1b.println(number); output1b.flush(); }
And the continue every time with indexOf.Java Code:if (getal == 1) { getal = 0; }
And that for line 1, 2, 3, .... 10 etc.
Is there a way to make this more simple?
Similar Threads
-
please help in java code (simple)
By rahul_swe23 in forum New To JavaReplies: 4Last Post: 01-26-2009, 03:32 PM -
Simple code. Could you help pls..?
By Iliyas in forum New To JavaReplies: 8Last Post: 12-26-2008, 03:17 AM -
Simple code help
By rednose in forum New To JavaReplies: 11Last Post: 11-30-2008, 06:02 AM -
Please help me this is simple bit of code
By BlitzAcez in forum New To JavaReplies: 4Last Post: 11-27-2008, 05:52 AM -
simple code
By elizabeth in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks