1 Star 3 Fork 0

清风/CommonUtils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ForMysqlFileETL.java 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
清风 提交于 2018-12-12 11:35 . sql文件ETL
public class ForMysqlFileETL {
private static final String filePath="D:\\github\\信审\\归档\\wk_db_loan.sql";
private static final String dateStr="\'0000-00-00 00:00:00\'";
// '2018-12-04 11:09:18.862' datePattern for this
private static final String datePattern="'\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}'";
private static final String newStr="CURRENT_TIMESTAMP";
public static void main(String[] args) {
long start=System.currentTimeMillis();
FileReader fileReader;
try {
fileReader=new FileReader(new File(filePath));
BufferedReader bufferedReader = new BufferedReader(fileReader);
int i = filePath.lastIndexOf(".");
String newFilePath = filePath.substring(0, i) + 1 + filePath.substring(i);
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(new File(newFilePath)));
String s;
while ((s = bufferedReader.readLine())!=null){
String s1 = s.replaceAll("\\?", "").replaceAll("?", "").replaceAll(dateStr,newStr).replaceAll(datePattern,newStr);
bufferedWriter.write(s1+"\n");
}
System.out.println((System.currentTimeMillis()-start)+" milliseconds spent for file ETL");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/agp5050/CommonUtils.git
[email protected]:agp5050/CommonUtils.git
agp5050
CommonUtils
CommonUtils
master

搜索帮助