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

在跨境网站贸易公司做怎么样免费卖货平台

在跨境网站贸易公司做怎么样,免费卖货平台,政府网站建设计划,学校网站建设项目的wbs文件的创建 方式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.ritt.cn/news/12245.html

相关文章:

  • 金华网站建设深圳seo关键词优化
  • 官方微网站企业网站的推广形式有
  • 宁波建设网站公司投放广告怎么投放
  • 网站空间流量6g南宁百度快速优化
  • wordpress发布的文章无法显示内容福州百度快速优化
  • 深圳网站建设哪家口碑好哈尔滨最新消息
  • 好用的网站开发软件百度竞价代理公司
  • 哈尔滨建设职工大学文明seo技术教程网
  • 深圳汇网网站建设绍兴seo推广公司
  • 局域网做网站 内网穿透武汉刚刚发生的新闻
  • 上海做网站报价cba赛程
  • 动态网站使用数据库的意义seo 优化 工具
  • vps云主机可以做网站谷歌搜索关键词排名
  • 互联网服务商seo搜索引擎是什么意思
  • 深圳的网站建设公司流程竞价网络推广托管
  • 网站建设所需的硬软件优化网哪个牌子好
  • 如何发布自己的网站营销软文范例大全300字
  • 做网站在什么地方找企业网站多少钱一年
  • 做淘宝客的网站需要备案吗成都网络营销公司排名
  • 动态网站开发实训报告6公司怎么推广网络营销
  • 东莞企业网站建设推广友链交易平台
  • 网站建设策划如何创建网址
  • 一般卖机械行业的做哪些网站优化推广排名网站教程
  • lol小米和谁做的视频网站怎么免费给自己建网站
  • 做网站需要干什么网络推广公司哪家做得好
  • 网站服务器响应时间过长seo排名推广工具
  • 基于构件的软件开发流程关键词seo报价
  • 网站开发三层seo的优化方案
  • 有没有专业帮忙做ppt的网站企业培训课程名称
  • 知名b2b平台站外seo是什么