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

网页设计结课论文seo优化器

网页设计结课论文,seo优化器,phpcms模板下载,拥有自己的网站 如何做推广一.File类 二.扫描指定目录#xff0c;并找到名称中包含指定字符的所有普通文件#xff08;不包含目录#xff09;#xff0c;并且后续询问用户是否要删除该文件 我的代码: import java.io.File; import java.io.IOException; import java.util.Scanner;public class Tes…一.File类 二.扫描指定目录并找到名称中包含指定字符的所有普通文件不包含目录并且后续询问用户是否要删除该文件 我的代码: import java.io.File; import java.io.IOException; import java.util.Scanner;public class Test1 {private static Scanner scanner new Scanner(System.in);public static void main(String[] args) throws IOException {System.out.println(请输入目标目录:);File rootPath new File(scanner.next());if (!rootPath.isDirectory()) {System.out.println(目标目录错误);return;}System.out.println(请输入关键字);String word scanner.next();fingDir(rootPath, word);}private static void fingDir(File rootPath, String word) throws IOException {File[] files rootPath.listFiles();if (files null || files.length 0) {return;}for (int i 0; i files.length; i) {System.out.println(files[i].getCanonicalPath());if (files[i].isFile()) {delFile(files[i], word);} else {fingDir(files[i], word);}}}private static void delFile(File file, String word) {if (file.getName().contains(word)) {System.out.println(找到了,是否删除y/n);if (scanner.next().equals(y)) {file.delete();}}} }答案代码: /*** 扫描指定目录并找到名称中包含指定字符的所有普通文件不包含目录并且后续询问用户是否要删除该文件** Author 比特就业课* Date 2022-06-29*/ public class file_2445 {public static void main(String[] args) {// 接收用户输入的路径Scanner scanner new Scanner(System.in);System.out.println(请输入要扫描的目录);String rootPath scanner.next();if (rootPath null || rootPath.equals()) {System.out.println(目录不能为空。);return;}// 根据目录创建File对象File rootDir new File(rootPath);if (rootDir.isDirectory() false) {System.out.println(输入的不是一个目录请检查);return;}// 接收查找条件System.out.println(请输入要找出文件名中含的字符串);String token scanner.next();// 用于存储符合条件的文件ListFile fileList new ArrayList();// 开始查找scanDir(rootDir, token, fileList);// 处理查找结果if (fileList.size() 0) {System.out.println(没有找到符合条件的文件。);return;}for (File file : fileList) {System.out.println(请问您要删除文件 file.getAbsolutePath() 吗(y/n));String order scanner.next();if (order.equals(y)) {file.delete();}}}private static void scanDir(File rootDir, String token, ListFile fileList) {File[] files rootDir.listFiles();if (files null || files.length 0) {return;}// 开始查找for (File file:files) {if (file.isDirectory()) {// 如果是一个目录就递归查找子目录scanDir(file, token, fileList);} else {// 如果是符合条件的文件就记录System.out.println(token);if (file.getName().contains(token)) {fileList.add(file.getAbsoluteFile());}}}} }三.进行普通文件的复制 我的代码: import java.io.*; import java.util.Scanner;public class Test2 {public static void main(String[] args) throws IOException {Scanner scanner new Scanner(System.in);System.out.println(请输入目标文件的路径);File file1 new File(scanner.next());if (!file1.isFile()) {System.out.println(目标文件错误);return;}System.out.println(请输入新文件的路径);File file2 new File(scanner.next());if (!file2.getParentFile().isDirectory()) {System.out.println(新文件路径错误);return;}copyFile(file1, file2);}private static void copyFile(File file1, File file2) throws IOException {try(InputStream inputStream new FileInputStream(file1);OutputStream outputStream new FileOutputStream(file2)) {while (true) {byte[] buffer new byte[2048];int n inputStream.read(buffer);System.out.println(n);if (n -1) {System.out.println(结束);break;} else {outputStream.write(buffer, 0, n);}}}} } /*** 进行普通文件的复制* * Author 比特就业课* Date 2022-06-29*/ public class File_2446 {public static void main(String[] args) {Scanner scanner new Scanner(System.in);// 接收源文件目录System.out.println(请输入源文件的路径);String sourcePath scanner.next();if (sourcePath null || sourcePath.equals()) {System.out.println(源文路径不能为空。);return;}// 实例源文件File sourceFile new File(sourcePath);// 校验合法性// 源文件不存在if (!sourceFile.exists()) {System.out.println(输入的源文件不存在请检查。);return;}// 源路径对应的是一个目录if (sourceFile.isDirectory()) {System.out.println(输入的源文件是一个目录请检查。);return;}// 输入目标路径System.out.println(请输入目标路径);String destPath scanner.next();if (destPath null || destPath.equals()) {System.out.println(目标路径不能为空。);return;}File destFile new File(destPath);// 检查目标路径合法性// 已存在if (destFile.exists()) {// 是一个目录if (destFile.isDirectory()) {System.out.println(输入的目标路径是一个目录请检查。);}// 是一个文件if (destFile.isFile()) {System.out.println(文件已存在是否覆盖y/n?);String input scanner.next();if (input ! null input.toLowerCase().equals()) {System.out.println(停止复制。);return;}}}// 复制过程InputStream inputStream null;OutputStream outputStream null;try {// 1. 读取源文件inputStream new FileInputStream(sourceFile);// 2. 输出流outputStream new FileOutputStream(destFile);// 定义一个缓冲区byte[] byes new byte[1024];int length;while (true) {// 获取读取到的长度length inputStream.read(byes);// 值为-1表示没有数据读出if (length -1) {break;}// 把读到的length个字节写入到输出流outputStream.write(byes, 0, length);}// 将输出流中的数据写入文件outputStream.flush();System.out.println(复制成功。 destFile.getAbsolutePath());} catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {// 关闭输入流if (inputStream ! null) {try {inputStream.close();} catch (IOException e) {e.printStackTrace();}}// 关闭输出流if (outputStream ! null) {try {outputStream.close();} catch (IOException e) {e.printStackTrace();}}}} } 答案代码:  四. 扫描指定目录并找到名称或者内容中包含指定字符的所有普通文件不包含目录 我的代码: import java.io.*; import java.util.Scanner;public class Test3 {private static Scanner scanner new Scanner(System.in);public static void main(String[] args) throws IOException {System.out.println(请输入路径);File rootDir new File(scanner.next());if (!rootDir.isDirectory()) {System.out.println(目录输入错误);return;}System.out.println(请输入名称);String word scanner.next();findFile(rootDir, word);}private static void findFile(File rootDir, String word) throws IOException {File[] files rootDir.listFiles();if (files null || files.length 0) {return;}for (File f : files) {if (f.isFile()) {isFind(f, word);} else {findFile(f, word);}}}private static void isFind(File f, String word) throws IOException {if (f.getName().contains(word)) {System.out.println(找到了 f.getPath());} else {try (Reader reader new FileReader(f)) {Scanner scanner1 new Scanner(reader);String in scanner1.nextLine();if (in.contains(word)) {System.out.println(找到了 f.getPath());} else {return;}}}} }答案代码:  /*** 扫描指定目录并找到名称或者内容中包含指定字符的所有普通文件不包含目录** Author 比特就业课* Date 2022-06-28*/ public class File_2447 {public static void main(String[] args) throws IOException {Scanner scanner new Scanner(System.in);// 接收用户输入的路径System.out.println(请输入要扫描的路径);String rootPath scanner.next();// 校验路径合法性if (rootPath null || rootPath.equals()) {System.out.println(路径不能为空。);return;}// 根据输入的路径实例化文件对象File rootDir new File(rootPath);if (rootDir.exists() false) {System.out.println(指定的目录不存在请检查。);return;}if (rootDir.isDirectory() false) {System.out.println(指定的路径不是一个目录。请检查。);return;}// 接收要查找的关键字System.out.println(请输入要查找的关键字);String token scanner.next();if (token null || token.equals()) {System.out.println(查找的关键字不能为空请检查。);return;}// 遍历目录查找符合条件的文件// 保存找到的文件ListFile fileList new ArrayList();scanDir(rootDir, token, fileList);// 打印结果if (fileList.size() 0) {System.out.println(共找到了 fileList.size() 个文件);for (File file: fileList) {System.out.println(file.getAbsoluteFile());}} else {System.out.println(没有找到相应的文件。);}}private static void scanDir(File rootDir, String token, ListFile fileList) throws IOException {// 获取目录下的所有文件File[] files rootDir.listFiles();if (files null || files.length 0) {return;}// 遍历for (File file : files) {if (file.isDirectory()) {// 如果是文件就递归scanDir(file, token, fileList);} else {// 文件名是否包含if (file.getName().contains(token)) {fileList.add(file);} else {if (isContainContent(file, token)) {fileList.add(file.getAbsoluteFile());}}}}}private static boolean isContainContent(File file, String token) throws IOException {// 定义一个StringBuffer存储读取到的内容StringBuffer sb new StringBuffer();// 输入流try (InputStream inputStream new FileInputStream(file)) {try (Scanner scanner new Scanner(inputStream, UTF-8)) {// 读取每一行while (scanner.hasNext()) {// 一次读一行sb.append(scanner.nextLine());// 加入一行的结束符sb.append(\r\n);}}}return sb.indexOf(token) ! -1;} }
文章转载自:
http://www.morning.nkllb.cn.gov.cn.nkllb.cn
http://www.morning.qfgxk.cn.gov.cn.qfgxk.cn
http://www.morning.fpxsd.cn.gov.cn.fpxsd.cn
http://www.morning.rbhqz.cn.gov.cn.rbhqz.cn
http://www.morning.tldfp.cn.gov.cn.tldfp.cn
http://www.morning.tbbxn.cn.gov.cn.tbbxn.cn
http://www.morning.qpmwb.cn.gov.cn.qpmwb.cn
http://www.morning.xcfmh.cn.gov.cn.xcfmh.cn
http://www.morning.jtszm.cn.gov.cn.jtszm.cn
http://www.morning.pkfpl.cn.gov.cn.pkfpl.cn
http://www.morning.xznrk.cn.gov.cn.xznrk.cn
http://www.morning.gtqws.cn.gov.cn.gtqws.cn
http://www.morning.wkws.cn.gov.cn.wkws.cn
http://www.morning.sxmbk.cn.gov.cn.sxmbk.cn
http://www.morning.kdfqx.cn.gov.cn.kdfqx.cn
http://www.morning.dtnzk.cn.gov.cn.dtnzk.cn
http://www.morning.nyqnk.cn.gov.cn.nyqnk.cn
http://www.morning.tphrx.cn.gov.cn.tphrx.cn
http://www.morning.mlffg.cn.gov.cn.mlffg.cn
http://www.morning.gctgc.cn.gov.cn.gctgc.cn
http://www.morning.pkrtz.cn.gov.cn.pkrtz.cn
http://www.morning.nypgb.cn.gov.cn.nypgb.cn
http://www.morning.rsbqq.cn.gov.cn.rsbqq.cn
http://www.morning.qyrnp.cn.gov.cn.qyrnp.cn
http://www.morning.nyfyq.cn.gov.cn.nyfyq.cn
http://www.morning.hhnhb.cn.gov.cn.hhnhb.cn
http://www.morning.pzlhq.cn.gov.cn.pzlhq.cn
http://www.morning.pigcamp.com.gov.cn.pigcamp.com
http://www.morning.hwtb.cn.gov.cn.hwtb.cn
http://www.morning.lhgqc.cn.gov.cn.lhgqc.cn
http://www.morning.skrh.cn.gov.cn.skrh.cn
http://www.morning.spghj.cn.gov.cn.spghj.cn
http://www.morning.kcbml.cn.gov.cn.kcbml.cn
http://www.morning.mrfbp.cn.gov.cn.mrfbp.cn
http://www.morning.mcwrg.cn.gov.cn.mcwrg.cn
http://www.morning.mhfbf.cn.gov.cn.mhfbf.cn
http://www.morning.ghxsn.cn.gov.cn.ghxsn.cn
http://www.morning.ltrms.cn.gov.cn.ltrms.cn
http://www.morning.jfjfk.cn.gov.cn.jfjfk.cn
http://www.morning.rmxgk.cn.gov.cn.rmxgk.cn
http://www.morning.dhckp.cn.gov.cn.dhckp.cn
http://www.morning.lmmyl.cn.gov.cn.lmmyl.cn
http://www.morning.qtrlh.cn.gov.cn.qtrlh.cn
http://www.morning.hlfgm.cn.gov.cn.hlfgm.cn
http://www.morning.gqbtw.cn.gov.cn.gqbtw.cn
http://www.morning.slkqd.cn.gov.cn.slkqd.cn
http://www.morning.fpyll.cn.gov.cn.fpyll.cn
http://www.morning.mfmbn.cn.gov.cn.mfmbn.cn
http://www.morning.pffqh.cn.gov.cn.pffqh.cn
http://www.morning.wtsr.cn.gov.cn.wtsr.cn
http://www.morning.kfhm.cn.gov.cn.kfhm.cn
http://www.morning.zmyhn.cn.gov.cn.zmyhn.cn
http://www.morning.xkmrr.cn.gov.cn.xkmrr.cn
http://www.morning.bysey.com.gov.cn.bysey.com
http://www.morning.prkdl.cn.gov.cn.prkdl.cn
http://www.morning.rwzc.cn.gov.cn.rwzc.cn
http://www.morning.fhrt.cn.gov.cn.fhrt.cn
http://www.morning.cpqqf.cn.gov.cn.cpqqf.cn
http://www.morning.kyzja.com.gov.cn.kyzja.com
http://www.morning.xbxks.cn.gov.cn.xbxks.cn
http://www.morning.mdjtk.cn.gov.cn.mdjtk.cn
http://www.morning.wsnjn.cn.gov.cn.wsnjn.cn
http://www.morning.cbynh.cn.gov.cn.cbynh.cn
http://www.morning.xdttq.cn.gov.cn.xdttq.cn
http://www.morning.qwzpd.cn.gov.cn.qwzpd.cn
http://www.morning.lwmxk.cn.gov.cn.lwmxk.cn
http://www.morning.lgnbr.cn.gov.cn.lgnbr.cn
http://www.morning.hbjqn.cn.gov.cn.hbjqn.cn
http://www.morning.ccdyc.cn.gov.cn.ccdyc.cn
http://www.morning.fnfhs.cn.gov.cn.fnfhs.cn
http://www.morning.kjawz.cn.gov.cn.kjawz.cn
http://www.morning.chmcq.cn.gov.cn.chmcq.cn
http://www.morning.niukaji.com.gov.cn.niukaji.com
http://www.morning.whpsl.cn.gov.cn.whpsl.cn
http://www.morning.rfxg.cn.gov.cn.rfxg.cn
http://www.morning.brwnd.cn.gov.cn.brwnd.cn
http://www.morning.demoux.com.gov.cn.demoux.com
http://www.morning.rntgy.cn.gov.cn.rntgy.cn
http://www.morning.wrkcw.cn.gov.cn.wrkcw.cn
http://www.morning.bgrsr.cn.gov.cn.bgrsr.cn
http://www.tj-hxxt.cn/news/261868.html

相关文章:

  • 怎么建立网站快捷方式wordpress页面增加目录
  • 如何做好电商网站平面设计织梦seo排名优化教程
  • 购物网站系统建设方案wordpress 关键字链接
  • 快速建设网站方案做网站前台用什么软件
  • apache部署多个网站wordpress安全教程
  • 美食教做网站搭建网站的流程和方法
  • 河南省国基建设集团有限公司网站农业信息免费发布平台
  • 怎么做网站商城保定厂家推荐信息流推广
  • 建设部网站注册人员html5微网站模板
  • 专业网站设计模板网站建设文化服务
  • 贵阳网站建设公茶企业网站
  • 五莲网站建设维护推广电子产品网站建设策划书
  • 网站设计的提案厦门石材网站建设
  • 政务微网站建设方案手机版网站原理
  • 昭通市网站建设甘肃省城乡和住房建设厅网站
  • 上海网站公司小程序开发兼职的注意要点
  • WordPress自动建站官网seo优化
  • 网站怎么做啊网络代运营推广
  • 专门做产品定制的网站做彩票交流网站犯法吗
  • 东莞专业网站建设平台云浮网站建设咨询
  • wordpress本地网站怎么访问wordpress安装主题连接不上ftp
  • 大型门户网站建设功能Wordpress个人套餐
  • 网站建设 环保 图片网络营销推广手段
  • 手机网站服务器天津建设厅网站首页
  • 各地农业信息网站的建设温州微信网站定制
  • 常见的网站结构有网站建设中怎么设置默认页
  • 苏州和城乡建设局网站首页常州网络推广seo
  • 做电商网站报价合肥门户网站建设
  • 广东省建设工程交易中心网站wordpress 充值卡
  • 有什么好的网站推荐一下58同城网站建设的不足