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

网站快速排名长沙房地产管理局

网站快速排名,长沙房地产管理局,网站建设最简单的教程,wordpress怎么找到分类目录文件的创建 方式1#xff1a; new File(String pathName) 根据路径构建一个File对象方式2#xff1a; new File(File parent,String child) 根据父目录文件子路径构建方式3#xff1a; new File(String parent,String child) 根据父目录子路径构建 代码#xff1a; //方…文件的创建 方式1 new File(String pathName) 根据路径构建一个File对象方式2 new File(File parent,String child) 根据父目录文件子路径构建方式3 new File(String parent,String child) 根据父目录子路径构建 代码 //方式1 new File(String pathName) 根据路径构建一个File对象public void creat1() {String pathName d:\\creatFile\\file1.txt;File file1 new File(pathName);try {file1.createNewFile();System.out.println(文件1创建成功);} catch (IOException e) {e.printStackTrace();}}//方式2 new File(File parent,String child) 根据父目录文件子路径构建public void creat2(){File parent new File(d:\\);String child file2.txt;File file2 new File(parent, child);try {file2.createNewFile();System.out.println(文件2创建成功);} catch (IOException e) {e.printStackTrace();}}//方式3 new File(String parent,String child) 根据父目录子路径构建public void creat3(){String parent d:\\;String child file3.txt;File file2 new File(parent, child);try {file2.createNewFile();System.out.println(文件3创建成功);} catch (IOException e) {e.printStackTrace();}}常用方法 getName()获取文件名字。getAbsolutePath()获取文件的绝对路径。getParent()获取文件的父级目录。length()获取文件的大小以字节为单位。exists()判断文件是否存在。isFile()判断是否为一个文件。isDirectory()判断是否为一个目录。delete()删除文件mkdirs()创建多级目录mkdir()创建父目录(一级目录) 代码 public void fileMethods(){//先创建文件对象File file new File(d:\\file1.txt);//调用相应的方法得到对应信息System.out.println(文件名字 file.getName());//getName、getAbsolutePath、getParent、length、exists、isFile、isDirectorySystem.out.println(文件绝对路径 file.getAbsolutePath());System.out.println(文件父级目录 file.getParent());System.out.println(文件大小(字节) file.length());System.out.println(文件是否存在 file.exists());//TSystem.out.println(是不是一个文件 file.isFile());//TSystem.out.println(是不是一个目录 file.isDirectory());//F}public void delete(){File file1 new File(d:\\file3.txt);if(!file1.exists()){System.out.println(文件不存在);}else {if(file1.delete()){System.out.println(文件删除成功);}else {System.out.println(文件删除失败);}}}public void delete2(){File file1 new File(d:\\file1);if(!file1.exists()){System.out.println(文件不存在);}else {if(file1.delete()){System.out.println(文件删除成功);}else {System.out.println(文件删除失败);}}}public void creat(){String directoryPath d:\\file1\\ret;File file new File(directoryPath);if(file.exists()){System.out.println(文件存在);}else {if(file.mkdirs()){//mkdirs()创建多级目录,如:d:\\file1\\ret。mkdir()创建父一级目录,如d:\\file2System.out.println(文件创建成功);}else {System.out.println(文件创建失败);}}}
http://www.dnsts.com.cn/news/189193.html

相关文章:

  • 做网站需要的手续台州手机网站制作
  • 乐清本地网站wordpress后台登陆空白
  • 网站ui设计欣赏山西网站建设方案
  • 东莞建设网站企业电子商务服务平台
  • 酒店官方网站建设书网站的电子地图怎么做
  • 广州网站外贸推广wordpress禁止查看源代码
  • 图形设计网站网站开发技术工作室
  • 杂志在线设计网站wordpress. 说说样式
  • 道滘镇网站仿做衡水 网站建设
  • 东莞怎么制作网站上海搜索推广
  • 天河做网站哪家好网站优化都是怎么做的
  • 网站子域名 更换wordpress导航页面模板下载
  • 建站平台加盟桂林网站制作人才招聘
  • 东莞做网站沃德wordpress长文章分页插件
  • 自助网站建设价格网页设计与网站建设ppt
  • 加盟餐饮的网站建设网页设计详细步骤
  • 怎么让网站文章被收录常州建设工程信息网
  • 网站后台打不开的原因海兴贴吧
  • 东阳做网站公司网站开发使用哪种语言
  • 厦门集美网站建设怎样网站建设与管理
  • 怎么让网站分享有图片广告设计公司实践报告
  • 网站交互怎么做如何创建一个免费网站
  • 医疗网站建设需要什么资质淘宝客怎么做直播网站
  • 建设网站视频教程网站建设优化哪家专业
  • 什么是网站建设的建议优化网站标题是什么意思
  • 做网站找什么公司工作新浪微博登录网页版
  • 软件开发 网站开发哪个难网站制作流程分为哪七步
  • 房地产销售平台网站建设浅谈网站建设
  • 系统开发服务seo搜索引擎营销工具
  • 网站建设评比考核报告如何选择网站建设