You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.5 KiB
59 lines
1.5 KiB
package com.yuxue.pay;
|
|
import java.io.*;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
|
|
import org.omg.CORBA.PRIVATE_MEMBER;
|
|
|
|
import com.yuxue.pay.cost;
|
|
|
|
public class readWanted {
|
|
|
|
public String readWantedText(String wanted) throws IOException, ParseException {
|
|
String filepath = "D:\\HDH.txt";
|
|
int count=0;// 记录次数
|
|
String last=null;
|
|
|
|
try {
|
|
FileReader fr = new FileReader(filepath);
|
|
BufferedReader br = new BufferedReader(fr);
|
|
String temp = "";// 用于临时保存每次读取的内容
|
|
|
|
while (temp != null) {
|
|
temp = br.readLine();
|
|
if (temp != null && temp.contains(wanted)) {
|
|
count++;
|
|
last=temp;
|
|
}
|
|
}
|
|
|
|
} catch (FileNotFoundException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
|
|
String date2 = sdf.format(new Date());// new Date()为获取当前系统时间
|
|
FileWriter fWriter = new FileWriter(filepath, true);
|
|
fWriter.write(wanted + " " + date2 + "\n");
|
|
fWriter.close();
|
|
System.out.println(last);
|
|
String s5="";
|
|
if(count%2!=0)
|
|
{
|
|
String[] s1=last.split(" ");
|
|
String sdate=s1[1].concat(" "+s1[2]);
|
|
cost cost =new cost();
|
|
//计算费用
|
|
s5=cost.cost(sdate, date2);
|
|
return s5;
|
|
}
|
|
else {
|
|
return "welcome";
|
|
}
|
|
|
|
}
|
|
} |