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

📄 filetest.java

📁 基于LWVCL开发的库
💻 JAVA
字号:
import java.io.File;public class FileTest {    public static void exists(File f) {      String type = "File";      if (f.isDirectory()) { type = "Directory"; }      System.out.print(type + " \"" + f.getPath() );      if (f.exists()) {          System.out.println("\" does exist");      } else {          System.out.println("\" does not exist");      }    }    public static void main(String[] argv) throws Exception {        File g1 = new File("/", "tmp"); exists(g1);        File g2 = new File("/"); exists(g2);        File g3 = new File(g2, "tmp"); exists(g3);        File g4 = new File(""); exists(g4);        File g5 = new File("","NotExist2"); exists(g5);	File g6 = new File((String)null,"NotExist2"); exists(g6);        try {        File b2 = new File("/", null); exists(b2);        } catch (NullPointerException e) {System.out.println("caught 1");}	try {	File b3 = new File((File)null,"NotExist2"); exists(b3);        } catch (NullPointerException e) {System.out.println("caught 2");}    }}/**********JDK 1.1 outputDirectory "/tmp" does existDirectory "/" does existDirectory "/tmp" does existFile "" does not existFile "/file2" does not existFile "file2" does not existcaught 1caught 2JDK 1.2 outputDirectory "/tmp" does existDirectory "/" does existDirectory "/tmp" does existFile "" does not existFile "/file2" does not existFile "file2" does not existcaught 1File "file2" does not exist*************//* Expected Output:Directory "/tmp" does existDirectory "/" does existDirectory "/tmp" does existFile "" does not existFile "/NotExist2" does not existFile "NotExist2" does not existcaught 1File "NotExist2" does not exist*/

⌨️ 快捷键说明

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