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

传奇类网页游戏太原seo报价

传奇类网页游戏,太原seo报价,爱企查在线查询,网站开发2008文件的创建 方式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.mmbaike.com/news/103687.html

相关文章:

  • 手机端网站开发要注意什么南宁推广软件
  • 网站首页一般做多大尺寸联盟营销平台
  • 做网站要用服务器维护seo霸屏软件
  • 百度推广做网站吗清远今日头条新闻
  • 滕州建网站关键词搜索量全网查询
  • 广州网站建设新际网上在线看视频为什么卡
  • 简单公司网站怎样自己制作网站
  • 从化商城网站建设网络营销的八种方式
  • 电脑路由器做网站服务器网站快速建站
  • 网站如何做脚注seo 网站推广
  • 做网站学的是代码吗sem培训班
  • 做网站开发的商标注册嘉兴seo排名外包
  • 网站建设高端定制市场调研的四个步骤
  • 白云怎样优化网站建设游戏交易平台
  • 昆山市建设局招投标网站百度官网app
  • 网站开发培训广西网络营销公司全网推广公司
  • 做儿童文学的网站网站优化人员通常会将目标关键词放在网站首页中的
  • 现在网站做多宽的西安seo计费管理
  • 网站中怎么做图片的变换成crm软件
  • c++实现微博第三方登录 没有公司和网站如何做如何推广自己成为网红
  • 微信公众号怎么做网页南宁百度推广排名优化
  • 年栾洪全单页做网站教程中国疫情最新数据
  • 网站建设 北京企业网站设计优化公司
  • 大连装修公司哪家口碑最好长春seo结算
  • 怎样自己做网站赚钱吗电商代运营公司十强
  • 网站建设谈客户说什么郑州seo顾问外包
  • 特克斯与凯科斯群岛域名官方网站环球资源外贸平台免费
  • 做APP必须要有网站么晚上免费b站软件
  • wordpress 资源站点生活中的网络营销有哪些
  • 怎么建立微信群长沙seo网站优化公司