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

做360网站优化关键词竞价排名名词解释

做360网站优化,关键词竞价排名名词解释,郑州网站建站网站,政府网站哪里做的最好文件的创建 方式1: new File(String pathName) 根据路径构建一个File对象方式2: new File(File parent,String child) 根据父目录文件子路径构建方式3: new File(String parent,String child) 根据父目录子路径构建 代码: //方…

文件的创建

  1. 方式1: new File(String pathName) 根据路径构建一个File对象
  2. 方式2: new File(File parent,String child) 根据父目录文件+子路径构建
  3. 方式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();}}

常用方法

  1. getName():获取文件名字。
  2. getAbsolutePath():获取文件的绝对路径。
  3. getParent():获取文件的父级目录。
  4. length():获取文件的大小(以字节为单位)。
  5. exists():判断文件是否存在。
  6. isFile():判断是否为一个文件。
  7. isDirectory():判断是否为一个目录。
  8. delete():删除文件
  9. mkdirs():创建多级目录
  10. 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.hrbkazy.com/news/39812.html

相关文章:

  • 高端手机网站设计东营网站seo
  • qq推广设置中心seo去哪里学
  • 淘金网站建设推广国家认可的教育培训机构
  • 用c做网站自助建站官网
  • 做医疗的网站建设网络营销服务公司
  • 乌鲁木齐建设银行招聘网站有什么功能
  • 网站维护 关站 seo哈尔滨网站建设
  • 建设网站要多少费用网上销售培训课程
  • 开网站做一个交易所怎么做发软文
  • 怎么用VS2012建设网站小小课堂seo自学网
  • 汉阳放心的建站企丿网站及搜索引擎优化建议
  • windows7做网站永久免费自助建站系统
  • 360推广手机优化大师下载安装
  • 朋友圈海报用什么网站做的安徽seo优化规则
  • 园林景观网站源码大数据查询个人信息
  • 响应式网站建设教程做网络推广工作怎么样
  • 网站建设之数据信息的保密性长沙网站包年优化
  • 有关网站开发的国外书籍手机网站建设价格
  • 西安网站制作开发公司哪家好如何自建网站
  • 营口做网站的公司企业网站推广注意事项
  • 网站建设要托管服务器现在做推广的新渠道有哪些
  • 做网站哪个靠谱免费网站建设
  • 简单的网站建设公司购物网站页面设计
  • 杭州网站现场备案国内疫情最新情况
  • 做网站的步骤的文本全国免费发布广告信息
  • 化妆品网站建设方案优化培训学校
  • 做设计的网站定制拼多多商品关键词搜索排名
  • 网站规划要点bt兔子磁力搜索
  • 企业官网建设 创意网站建设最近发生的热点新闻事件
  • 宝鸡做网站的公司电话seo项目