diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Reference Architectures and Patterns/hjp5/examples/TestFile.java | |
| download | Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2 | |
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/TestFile.java')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/TestFile.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/TestFile.java b/Master/Reference Architectures and Patterns/hjp5/examples/TestFile.java new file mode 100644 index 0000000..91bae8a --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/TestFile.java @@ -0,0 +1,40 @@ +/* TestFile.java */
+
+import java.io.*;
+import java.util.*;
+
+public class TestFile
+{
+ public static void main(String[] args)
+ {
+ File fil = new File("TestFile.java");
+ TestFile.printFileInfo(fil);
+ fil = new File("..");
+ TestFile.printFileInfo(fil);
+ }
+
+ static void printFileInfo(File fil)
+ {
+ System.out.println("Name= "+fil.getName());
+ System.out.println("Path= "+fil.getPath());
+ System.out.println("AbsolutePath= "+fil.getAbsolutePath());
+ System.out.println("Parent= "+fil.getParent());
+ System.out.println("exists= "+fil.exists());
+ System.out.println("canWrite= "+fil.canWrite());
+ System.out.println("canRead= "+fil.canRead());
+ System.out.println("isFile= "+fil.isFile());
+ System.out.println("isDirectory= "+fil.isDirectory());
+ if (fil.isDirectory()) {
+ String[] fils = fil.list();
+ for (int i=0; i<fils.length; ++i) {
+ System.out.println(" "+fils[i]);
+ }
+ }
+ System.out.println("isAbsolute= "+fil.isAbsolute());
+ System.out.println(
+ "lastModified= "+(new Date(fil.lastModified()))
+ );
+ System.out.println("length= "+fil.length());
+ System.out.println("");
+ }
+}
\ No newline at end of file |
