IO之File类

来源:互联网 发布:淘宝企业店铺开店流程 编辑:程序博客网 时间:2024/05/18 03:38

package joeho.net.csdn.blog.io;

import java.io.*;
public class FileTest {
 
 /**
  * Method main
  *
  *
  * @param args
  *
  */
 public static void main(String[] args) throws IOException {
  
  File f = new File("test.txt");
  if(f.exists()){
   f.delete();  
  }
  else{
   f.createNewFile();
  }
  System.out.println(f.getName());
  System.out.println(f.getAbsolutePath());
  System.out.println(f.getParentFile());
  System.out.println(f.canWrite()?"Canwrite":"not Canwrite");
 } 
}

原创粉丝点击