⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedemo.java~5~

📁 java2参考大全上的例子的源码和自己的理解.
💻 JAVA~5~
字号:
package file方法;

/**
 File Name: COPYRIGHT
 Path: \java\COPYRIGHT
 Abs Path: D:\java\COPYRIGHT
 Parent: \java
 does not exist
 is not writeable
 is not readable
 is not a directory
 might be a named pipe
 is not absolute
 File last modified: 0
 File size: 0 Bytes

 */

// Demonstrate File.
import java.io.File;

class FileDemo {
  static void p(String s) {
    System.out.println(s);
  }

  public static void main(String args[]) {
//    File f1 = new File("D:/JAVA Programe/File方法/java/COPYRIGHT.txt");
    File f1 = new File("../java/COPYRIGHT.txt");
    p("File Name: " + f1.getName());
    p("Path: " + f1.getPath());
    p("Abs Path: " + f1.getAbsolutePath());
    p("Parent: " + f1.getParent());
    p(f1.exists() ? "exists" : "does not exist");
    p(f1.canWrite() ? "is writeable" : "is not writeable");
    p(f1.canRead() ? "is readable" : "is not readable");
    p("is " + (f1.isDirectory() ? "" : "not" + " a directory"));
    p(f1.isFile() ? "is normal file" : "might be a named pipe");
    p(f1.isAbsolute() ? "is absolute" : "is not absolute");
    p("File last modified: " + f1.lastModified());
    p("File size: " + f1.length() + " Bytes");
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -