当前位置: 首页 > news >正文

重点实验室网站建设的研究现状WordPress人物插件

重点实验室网站建设的研究现状,WordPress人物插件,专业做互联网招聘的网站有哪些,帮人做网站犯法目录 1 需求2 实现1#xff08;第一种方法#xff09;2 实现2 #xff08;推荐使用这个#xff0c;快#xff09;3 实现3#xff08;推荐#xff09; 1 需求 现在有一个文件夹#xff0c;里面会一直存数据#xff0c;动态的存数据#xff0c;之后可能会达到100万第一种方法2 实现2 推荐使用这个快3 实现3推荐 1 需求 现在有一个文件夹里面会一直存数据动态的存数据之后可能会达到100万1千万数据。 那么为了查询这个文件夹里面2天之内的数据根据修改时间进行查询我们如何操作 2 实现1第一种方法 /*** 遍历出一个文件夹下的全部的数据* */public static void getAllFile(File fileInput, ListFile allFileList) {// 获取文件列表File[] fileList fileInput.listFiles();if (!ArrayUtil.isEmpty(fileList)) {for (File file : fileList) {if (file.isDirectory()) {// 递归处理文件夹// 如果不想统计子文件夹则可以将下一行注释掉getAllFile(file, allFileList);} else {// 如果是文件则将其加入到文件数组中allFileList.add(file);}}}}/*** 一个文件夹下前两天的全部的数据* */public static ListFile listOrderByDate(String fliePath) {// 存放的是一个文件夹下的全部的数据ListFile allFileList new ArrayList();getAllFile(new File(fliePath), allFileList);long start DateUtil.offsetDay(new Date(), -2).getTime();long end new Date().getTime();ListFile collect allFileList.parallelStream().filter(x - x.lastModified() start x.lastModified() end).collect(Collectors.toList());ListFile sortedCollect collect.stream().sorted((t1, t2) - Long.compare(t2.lastModified(), t1.lastModified())).collect(Collectors.toList());return sortedCollect;}public static void main(String[] args) {long beginTime System.currentTimeMillis();String psth D:\\100w\\dest;// 遍历文件夹ListFile files listOrderByDate(psth);System.out.println(files.size());long endTime System.currentTimeMillis();long l endTime - beginTime;System.out.println(l/1000);使用上面的方法72608个文件大小 都是50MB 左右的文件花费了15秒 2 实现2 推荐使用这个快 public static void main(String[] args) throws InterruptedException, ExecutionException {long beginTime System.currentTimeMillis();String folderPath D:\\100w\\dest; // 替换为实际的文件夹路径int numThreads Runtime.getRuntime().availableProcessors(); // 获取可用的处理器核心数// 获取当前时间Date currentDate new Date();// 计算两天前的时间long twoDaysAgoMillis currentDate.getTime() - 2 * 24 * 60 * 60 * 1000;// 创建文件对象表示文件夹File folder new File(folderPath);// 获取文件夹下的所有文件File[] files folder.listFiles();// 创建线程池ExecutorService executor Executors.newFixedThreadPool(numThreads);// 创建任务列表ListCallableListFile tasks new ArrayList();// 将文件列表分成多个子列表int batchSize 10000; // 每个子列表的大小if (files ! null) {for (int i 0; i files.length; i batchSize) {final int startIndex i;final int endIndex Math.min(i batchSize, files.length);// 创建子任务每个子任务处理一个子列表的文件CallableListFile task () - {ListFile result new ArrayList();for (int j startIndex; j endIndex; j) {File file files[j];// 检查文件最后修改时间是否在两天内if (file.lastModified() twoDaysAgoMillis) {result.add(file);}}return result;};tasks.add(task);}}// 提交并行任务ListFutureListFile futures executor.invokeAll(tasks);// 收集结果ListFile result new ArrayList();for (FutureListFile future : futures) {result.addAll(future.get());}// 关闭线程池executor.shutdown();// 处理结果例如打印文件名System.out.println(result.size());long endTime System.currentTimeMillis();long l endTime - beginTime;System.out.println(l/1000);获取是1秒 3 实现3推荐 public static void main(String[] args) {long start System.currentTimeMillis();String folderPath D:\\100w\\dest; // 替换为实际的文件夹路径ListFile modifiedFiles getModifiedFilesWithinTwoDays(folderPath);System.out.println(修改时间在2天之内的文件数量: modifiedFiles.size());long end System.currentTimeMillis();long ss end - start;System.out.println(ss/1000);// 处理修改时间在2天之内的文件数据}public static ListFile getModifiedFilesWithinTwoDays(String folderPath) {ListFile modifiedFiles new ArrayList();File folder new File(folderPath);if (folder.exists() folder.isDirectory()) {File[] files folder.listFiles();if (files ! null) {Instant twoDaysAgo Instant.now().minus(Duration.ofDays(2));for (File file : files) {try {BasicFileAttributes attrs Files.readAttributes(file.toPath(), BasicFileAttributes.class);Instant lastModifiedTime attrs.lastModifiedTime().toInstant();if (lastModifiedTime.isAfter(twoDaysAgo)) {modifiedFiles.add(file);}} catch (Exception e) {e.printStackTrace();}}}}return modifiedFiles;}
http://www.zqtcl.cn/news/570611/

相关文章:

  • wordpress 百度站长沈阳app开发公司哪家好
  • 做网站平台公司网站建设硬件环境
  • 可视化编辑建站平台新密市城乡建设局网站
  • 电子商务的网站的建设内容wordpress主题 微软
  • 什么软件可以做动画视频网站网站的按钮怎么做 视频
  • 饰品做商城网站模式17网站一起做网店新塘
  • 微信做的地方门户网站做设计的平台
  • 旅游网站建设国内外现状安卓开发软件安装教程
  • 网站建设必备网站自助建设
  • 杭州免费自助建站模板辽宁建设工程信息网为什么打不开
  • sdcms网站源码百度怎么免费做网站
  • 图书馆网站参考咨询建设wordpress安装500
  • 详细描述建设网站wordpress 子页面
  • 做公司网站推广如何快速推广
  • 给期货交易类做网站违法吗青海企业网站制作
  • 成都网站模板购买一站式营销型网站建设服务
  • wordpress建站优势做网站认证对网站有什么好处
  • synology做网站专业企业建站价格
  • php开发大型网站开发免费个人微网站
  • 专门做奢侈品的网站怎么建设课题网站
  • 博客推广那个网站列好深圳社保个人网页登录
  • 网站的背景图怎么做最新章节 第一百四十七章 做视频网站
  • 济南网站建设百家号阿里云怎么wordpress
  • 网站分享对联广告北京建设执业网站
  • 一级做爰片免费网站域名流量查询
  • 做网站网站需要注意什么网站建设swot市场分析
  • 大学生兼职网站的融资方案云凡济南网站建设开发
  • 做动态效果的插件网站抚顺清原网站建设招聘
  • 商务网站开发需求分析厦门35网站建设公司
  • wordpress classseo推广服务