Java设置上传按钮上传文件以后,设置查找按钮用文件数据进行折半查找,运行时间显示在图形界面上
声明一个方法,然后把文件信息和执行时间返回即可,代码如下,其中时间是毫秒值,自己转换成想要的格式即可
public HashMap<String,Object> searchFile(String filename){
HashMap<String,Object> resultMap = new HashMap<>();
long beginTime = System.currentTimeMillis();
List<Object> fileList = getFileInfo(filename);
// 执行时长(毫秒)
long time = System.currentTimeMillis() - beginTime;
// 保存文件信息和时间
resultMap.put("fileList",fileList);
resultMap.put("time",time);
return resultMap;
}
查找是找什么?
就是将文件上传到后端,然后通过查找来查询文件内的内容,记录一下查询时间吧