国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

Java學(xué)習(xí)筆記-File類(lèi)的基本方法

2019-11-14 23:41:51
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
java學(xué)習(xí)筆記-File類(lèi)的基本方法

要漸漸養(yǎng)成寫(xiě)博客的習(xí)慣-----》

    前段時(shí)間看Mars的java中的I/O流沒(méi)怎么懂,發(fā)現(xiàn)I/O流好難啊。今天重新看一遍其他教學(xué),還有書(shū)籍,做些筆記,記錄下每天的學(xué)習(xí)生活。

File類(lèi)的一些方法:

 1 package com.VEVb; 2  3 import java.io.File;    4 import java.io.IOException; 5  6 public class FileTest { 7     public static void main(String[] args) throws IOException { 8         File file = new File("F:"+File.separator+"temp"+File.separator+"a.txt"); 9         //判斷是否是目錄10         System.out.PRintln(file.isDirectory());11         //判斷是否是文件12         System.out.println(file.isFile());13         //創(chuàng)建一個(gè)新文件14         file.createNewFile();15         System.out.println(file.isFile());16         System.out.println(file.isDirectory());17         //判斷是否可讀18         System.out.println(file.canRead());19         //判斷是否可寫(xiě)20         System.out.println(file.canWrite());21         //獲取長(zhǎng)度22         System.out.println(file.length());23         //獲得路勁24         System.out.println(file.getPath());25         //獲取文件父目錄26         System.out.println(file.getParentFile());27         //獲得分隔符28         System.out.println(file.pathSeparator);29         System.out.println(file.separator);30     }31 public static void main2(String [] args) throws IOException {32     File file = new File("F:"+File.separator+"temp"+File.separator+"a.txt");33     //判斷文件是否存在34     if(file.exists()){35         file.renameTo(new File("F:"+File.separator+"temp"+File.separator+"b.txt"));36     }37     //上面如果不存在則創(chuàng)建一個(gè)新的文件38     else{39         file.createNewFile();40     }41     42 }43 }

  


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴和县| 鹤壁市| 郯城县| 博乐市| 东乌| 霍城县| 芒康县| 娄底市| 泗阳县| 澄迈县| 蒲江县| 理塘县| 湟中县| 甘谷县| 延川县| 清原| 泽普县| 茌平县| 监利县| 邯郸县| 万源市| 扶余县| 桑植县| 延川县| 清徐县| 义马市| 赤峰市| 毕节市| 交城县| 库伦旗| 武强县| 房产| 屏东市| 馆陶县| 伊通| 嘉祥县| 嘉禾县| 正安县| 凤庆县| 故城县| 天祝|