39 lines
1022 B
Java
39 lines
1022 B
Java
|
//: io/DirectoryDemo.java
|
|||
|
// <20>2015 MindView LLC: see Copyright.txt
|
|||
|
// Sample use of Directory utilities.
|
|||
|
import java.io.*;
|
|||
|
import com.mindviewinc.util.*;
|
|||
|
import static com.mindviewinc.util.Print.*;
|
|||
|
|
|||
|
public class DirectoryDemo {
|
|||
|
public static void main(String[] args) {
|
|||
|
// All directories:
|
|||
|
PPrint.pprint(Directory.walk(".").dirs);
|
|||
|
// All files beginning with 'T'
|
|||
|
for(File file : Directory.local(".", "T.*"))
|
|||
|
print(file);
|
|||
|
print("----------------------");
|
|||
|
// All Java files beginning with 'T':
|
|||
|
for(File file : Directory.walk(".", "T.*\\.java"))
|
|||
|
print(file);
|
|||
|
print("======================");
|
|||
|
// Class files containing "Z" or "z":
|
|||
|
for(File file : Directory.walk(".",".*[Zz].*\\.class"))
|
|||
|
print(file);
|
|||
|
}
|
|||
|
} /* Output:
|
|||
|
[.\xfiles]
|
|||
|
.\TestEOF.class
|
|||
|
.\TestEOF.java
|
|||
|
.\TransferTo.class
|
|||
|
.\TransferTo.java
|
|||
|
----------------------
|
|||
|
.\TestEOF.java
|
|||
|
.\TransferTo.java
|
|||
|
.\xfiles\ThawAlien.java
|
|||
|
======================
|
|||
|
.\FreezeAlien.class
|
|||
|
.\GZIPcompress.class
|
|||
|
.\ZipCompress.class
|
|||
|
*///:~
|