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

武汉平台网站建设 APP/网站营销网站营销推广

武汉平台网站建设 APP,网站营销网站营销推广,如何做好网站外链,什么是网站备案题目描述 A文件夹下面有多个子文件夹,然后子文件下后面有一些.jpg文件,要求把这些.jpg文件完全拷贝复制到B文件夹。 实现思路 先遍历循环A文件夹下的文件,然后找到符合.jpg的文件,放到一个列表中,然后再把列表中的jpg文…

题目描述

A文件夹下面有多个子文件夹,然后子文件下后面有一些.jpg文件,要求把这些.jpg文件完全拷贝复制到B文件夹。

实现思路

先遍历循环A文件夹下的文件,然后找到符合.jpg的文件,放到一个列表中,然后再把列表中的jpg文件放到B文件夹上。

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.file.Files;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;public class Picture {private static LinkedList<File> fileQueue= new LinkedList<>();private final String aPath="C:\\Users\\m088163\\Pictures";private final String bPath="D:\\temp";/*** 将源文件夹下所有的.jpg文件找到,并存在fileQueue 列表中。* @param path 需要查找文件的路径名* @param subStr 匹配的文件类型*/public void FindJpg(String path,String subStr){File file=new File(path);File[] files=file.listFiles();for(int i=0;i<files.length;i++){if(files[i].isDirectory()){FindJpg(files[i].getAbsolutePath(),subStr);}if(files[i].getAbsolutePath().contains(subStr)){fileQueue.add(files[i]);}}}/*** 将fileQeueue中的jpg文件存在目标文件夹。* @param path* @throws Exception*/public void moveJpg(String path) throws Exception{String myPath="";File newFile;for(File files:fileQueue){myPath=path+"\\";myPath+=files.getName();System.out.println(files.getName());newFile=new File(myPath);if(newFile.exists()){System.out.println("创建文件失败"+newFile+"失败,目标文件已经存在");}if(!newFile.getParentFile().exists()){System.out.println("文件的根目录不存在,创建根目录");newFile.getParentFile().mkdir();}copyfile(files.getAbsoluteFile(),newFile);}}/*** 写入文件操作* @param fromDest* @param toDest* @throws Exception*/public void copyfile(File fromDest,File toDest ) throws Exception{FileInputStream is =new FileInputStream(fromDest);FileOutputStream os =new FileOutputStream(toDest);byte[] b =new byte[1024];int temp=0;while((temp=is.read(b))!=-1){os.write(b,0,temp);}is.close();os.close();}public static void main(String[] args) {Picture picture = new Picture();picture.FindJpg(picture.aPath, ".jpg");try {picture.moveJpg(picture.bPath);} catch (Exception e) {e.printStackTrace();}}
}
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.file.Files;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;public class Picture {private static LinkedList<File> fileQueue= new LinkedList<>();private final String aPath="C:\\Users\\m088163\\Pictures";private final String bPath="D:\\temp";/*** 将源文件夹下所有的.jpg文件找到,并存在fileQueue 列表中。* @param path 需要查找文件的路径名* @param subStr 匹配的文件类型*/public void FindJpg(String path,String subStr){File file=new File(path);File[] files=file.listFiles();for(int i=0;i<files.length;i++){if(files[i].isDirectory()){FindJpg(files[i].getAbsolutePath(),subStr);}if(files[i].getAbsolutePath().contains(subStr)){fileQueue.add(files[i]);}}}/*** 将fileQeueue中的jpg文件存在目标文件夹。* @param path* @throws Exception*/public void moveJpg(String path) throws Exception{String myPath="";File newFile;for(File files:fileQueue){myPath=path+"\\";myPath+=files.getName();System.out.println(files.getName());newFile=new File(myPath);if(newFile.exists()){System.out.println("创建文件失败"+newFile+"失败,目标文件已经存在");}if(!newFile.getParentFile().exists()){System.out.println("文件的根目录不存在,创建根目录");newFile.getParentFile().mkdir();}copyfile(files.getAbsoluteFile(),newFile);}}/*** 写入文件操作* @param fromDest* @param toDest* @throws Exception*/public void copyfile(File fromDest,File toDest ) throws Exception{FileInputStream is =new FileInputStream(fromDest);FileOutputStream os =new FileOutputStream(toDest);byte[] b =new byte[1024];int temp=0;while((temp=is.read(b))!=-1){os.write(b,0,temp);}is.close();os.close();}public static void main(String[] args) {Picture picture = new Picture();picture.FindJpg(picture.aPath, ".jpg");try {picture.moveJpg(picture.bPath);} catch (Exception e) {e.printStackTrace();}}
}

转载于:https://www.cnblogs.com/NaCl/p/10489070.html

http://www.lbrq.cn/news/776179.html

相关文章:

  • 鹤山网站建设/google收录提交入口
  • 宁波拾谷网站建设/微信推广链接怎么制作
  • wordpress建站打不开二级页面/简述优化搜索引擎的方法
  • 广州做网站的公司/最近爆发什么病毒感染
  • 怎么做网站音乐/软文推广是什么
  • 网站建设 网址导航/个人如何在百度上做广告
  • 谷歌优化seo/宁波seo搜索优化费用
  • 营销展示型网站建设价格/国产搜什么关键词最好看
  • 网站推广策划报告/小程序怎么引流推广
  • 我做网站啦 圆通导航/软文世界
  • 哪建设网站/最近一周的重大新闻
  • 网站建设应计入哪个会计科目/河北网站seo地址
  • 大作设计网站是中国的吗/成都seo招聘
  • 软件公司招聘/seo优质友链购买
  • 合肥教育网站建设/北京网站优化排名
  • 天津网站建设包括哪些/如何做网站
  • html5 网站 源码/阿里域名注册网站
  • 在淘宝上做代销哪个网站好/百度一下百度官网
  • 免费网站建设网站推广/名片seo什么意思
  • 关于网站开发网页上传和网站发布/门户网站制作
  • 贸易型企业网站建设/seo优化教程培训
  • 锦州电脑网站建设/辽宁和生活app下载安装
  • 学做网站看那个网/成都调查事务所
  • 四川通江县住房和建设局网站/江苏营销型网站建设
  • 东莞广告公司东莞网站建设价格/百度关键词搜索怎么收费
  • 网站策划与建设阶段的推广的目标/2023上海又出现疫情了
  • 营销网站建站公司/网络推广费用大概价格
  • 手机上怎么自己做网站/网站推广怎么做
  • java购物网站扫码支付怎么做/品牌策略包括哪些内容
  • 朝阳区网站开发公司/抖音引流推广怎么做
  • VUE+SPRINGBOOT从0-1打造前后端-前后台系统-会议记录
  • damn the jvm again(2)
  • Linux中Apache与Web之虚拟主机配置指南
  • VMD例程(Matlab 2021b可直接使用)
  • 【图像处理基石】UE输出渲染视频,有哪些画质相关的维度和标准可以参考?
  • 【数据分析】循环移位岭回归分析:光遗传学冻结行为模式研究