Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In a file i have some data ,i not required full data ,from certain point i required



SearchRequest
TransactionInformation.TransactionControlNumber:	1371010171250883
TransactionInformation.Priority:	null
FingerData.Position:	1
FingerData.Position:	2
FingerData.Position:	3
FingerData.Position:	4
FingerData.Position:	5
FingerData.Position:	6
FingerData.Position:	7
FingerData.Position:	8
FingerData.Position:	9
FingerData.Position:	10
TargetGalleries:	fingerPlain-1,fingerLatent-1,exceptionFingerPlain,
SUCCESS
3272060107390021,3.0312126
3573021702300001,2.728711
3173015811550002,2.4808035
3328023112300007,2.1470318
3175036405300002,2.0835547
7371045209380001,1.4756335
1671046105520001,1.4315698
7502034101500001,1.1825134
3174095204390002,0.9443519
1306014503350001,0.7167574
3173014203420002,0.67425823
3171080502520003,0.46428326
3173010903500003,0.40578112
3175100112570005,0.328002
3171077112400014,0.32794788
3325074504530001,0.20473967



in above file i requred data from after the success ,till the end of success data should be skipped and the output should come in seperate file
Posted
Updated 10-Oct-11 18:26pm
v2
Comments
Firo Atrum Ventus 11-Oct-11 1:11am    
What have you tried?
Richard MacCutchan 11-Oct-11 5:40am    
You will need to read the file one record at a time and ignore all records until you see the word "SUCCESS".
udayz999 11-Oct-11 5:42am    
how can i do that,to upto SUCCESS give me a hint
Richard MacCutchan 11-Oct-11 6:03am    
Do you know how to read a file? If not, take a look at this tutorial.
udayz999 11-Oct-11 6:05am    
ss,i know it

I've started it for you, I'll leave you to fill in the blanks:
Java
public class FileSpliter {
    
    public static void main(String[] args) {
        // open the input file
        
        // read until the line is SUCCESS
        
        // open output file

        // read remainder of file and write to output file
        
        // close output file
        
        // close input file
    }
}
 
Share this answer
 
hi
you can read the input file line by line, find desired pattern, and finally write the desired lines to output file.
This example could help you:

http://www.java2s.com/Code/Java/File-Input-Output/Allowsreadingandwritingtoaplaintextfileviaalistoflines.htm[^]



best regards!
 
Share this answer
 
ok, without giving away too much and a much simpler approach instead of reading line by line, although may need optimisation when u have had a hang of it:

1) open the input file
2) read into a
Java
char[]
of appropriate size
3) convert to string
4) look for "SUCCESS"
5) and, read everything after that keyword
6) finally, write to the output file. DONE!!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900