跳过文件中的数据 [英] skipping data in file

查看:62
本文介绍了跳过文件中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从一个特定的角度来看,文件中我有一些数据,我不需要完整的数据,



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

推荐答案

我已经开始了它为您服务,我将让您填写空白:
I''ve started it for you, I''ll leave you to fill in the blanks:
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
    }
}



您可以逐行读取输入文件,找到所需的模式,最后将所需的行写入输出文件.
该示例可以为您提供帮助:

http://www.java2s.com/Code/Java/File-Input-Output/允许通过alistoflines.htm读取和写入纯文本文件 [ ^ ]



最好的问候!
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!


好,不要放弃太多,更简单的方法,而不是逐行阅读,尽管当您遇到麻烦时可能需要进行优化:

1)打开输入文件
2)读入适当大小的
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
char[]


3)转换为字符串
4)查找成功"
5),然后阅读该关键字之后的所有内容
6)最后,写入输出文件.完成!

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!!!


这篇关于跳过文件中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆