我有一个文件,其中的单词由“|”分隔。这里我需要搜索日期“20180603”。但是,我无法硬编码要搜索的值。日期格式固定为 YYYYDDMM,日期可以是任何格式。我需要将此处显示的日期转换为今天的日期(系统日期)。
我正在粘贴外部文件的外观(只是我在相关值周围添加了星号以强调):
00000548|WILLIAM|HUBER|WH5718||N|**20180306**|SVP-TECHNICAL FIELD SERVICES|06|329000.00 |0.00 |0.00 |205440.00 |0.00 |0.00 |0.00 |0.00 |0.00 |55000.00 |0.00 |0.00 |0.00 |1600.00 |0.00 |0.00 |0.00 |0.00 |225502.08 |0.00 |0.00 |0.00 |27629.91 |36717.17 |0.00 |33.000 |0.000 |F
00000828|NORBERTA|NOGUERA|NN1413||N|**20180306**|VP-SPECIAL PROJECTS|05|213000.00 |0.00 |88464.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |0.00 |86502.87 |0.00 |0.00 |0.00 |16811.41 |15023.40 |0.00 |33.000 |0.000 |F
00001308|ERROL|PHIPPS|EP4499||N|00000548|WILLIAM|HUBER|WH5718||N|20180306|SVP-TECHNICAL FIELD SERVICES|06|329000.00 |0.00 |0.00 |205440.00 |0.00 |0.00 |0.00 |0.00 |0.00 |55000.00 |0.00 |0.00 |0.00 |1600.00 |0.00 |0.00 |0.00 |0.00 |225502.08 |0.00 |0.00 |0.00 |27629.91 |36717.17 |0.00 |33.000 |0.000 |F
我尝试了很多问题,但没有运气。
下面是我试过的代码;
public class ReadFile {
public static void main(String[] args) throws IOException {
File f1= new File("C:/Users/kumar.sushobhan/Desktop/ESPYTR_Big_file_EXEC.dat");
//File f1= new File("C:/Users/kumar.sushobhan/Desktop/h.txt");
String words[]= null;
FileReader fr= new FileReader(f1);
BufferedReader br= new BufferedReader(fr);
String s;
int c = 0;
String regex= "\\d{4}\\d{2}\\d{2}";
while((s= br.readLine())!=null)
{
words= s.split("|");
for(String word: words)
{
//System.out.println(word);
if(word.equals(regex))
{
c++;
}
}
}
System.out.println(c);
fr.close();
}
}
我希望读取快照中存在的日期并将其更改为当前系统日期。
翻过高山走不出你
白衣非少年
繁花如伊
随时随地看视频慕课网APP
相关分类