1,业务分析
通过条件筛选每一条我们要的日志,通过时间戳条件筛选对应的日志,最后输出出来
代码:
处理时间 06:00 —> 60000
val _start = start.replace(":","").mkString("","","00").toInt
val _end = end.replace(":","").mkString("","","00").toInt
当前时间
val date = new Date()
date.getTime+filename
要处理时间 xxxxxxxx,28/Feb/ 2019:13:49:28,xxxxxx
时间切割后结果124928
val r_time = s.split(",").toList(1).split(":",2).toList(1).replace(":","").toInt
比大小
if(_start<r_time&& r_time<_end)
判断另一个筛选条件
包含’wesd’的条件(此部分看不懂的同学,可微信我)
_ad.r.findAllIn( ad ).hasNext
最后根据条件输出就好
写在最后送上file写文件和下载文件的方法
上代码
def save(filename:String,content:String): Unit ={
val file = new File(pathname)
if(!file.exists()){
file.mkdirs()
}
println("filename:"+filename)
println("content:"+content)
val writer = new FileWriter(pathname+"/_new_"+filename, true)
writer.write(content+"\r\n")
writer.flush()
writer.close()
}
@RequestMapping(Array("down"))
@ResponseBody
def down(name:String,response:HttpServletResponse): Array[Byte] ={
response.setContentType("appliction/octet-stream")
response.setHeader( "Content-disposition", "attachment;filename=" + pathname+"/"+name )
val path = Paths.get( pathname+"/"+name)
Files.readAllBytes(path)
}
本着共同探讨的方法去学习去分享