File (file class)

xiaoxiao2021-03-31  190

// 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 "c: /boot.ini"); P ("File Name:" f1.getName ()); P ("PATH:" f1.getPath ()); P ("ABS PATH:" F1.GetabsolutePath ()); P (f1.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");

P ("File Hidden:" f1.ishidden ());}}

转载请注明原文地址:https://www.9cbs.com/read-130843.html

New Post(0)