Documente Academic
Documente Profesional
Documente Cultură
-----------------------------------------------------------
What is a File System?
- how your folders/directories and files are arranged in your computer
- arranged in a tree-like structure
----------------------------------------------------------
What is a Path?
eg:
C:\Program Files\Java\jdk1.8.0_20\bin
C:\Program Files\Java\jdk1.8.0_20\bin\javac.jar
Types of Path:
1. Absolute Path
2. Relative Path
----------------------------------------------------
java.nio.file package
Path Interface
Paths class
FileSystem
FileSystems
Path will create the path even if it does not exists. It will not create the path
in file system.
It is the work of Files class to check whether the file exists or not
---------------------------------------------------------
createFile() - will create a file
createDirectory() - will create a folder/directory
createDirectories() -will create all the non-existing directories
----------------------------------------------------------
FileVisitor Interface
- predefined interface in java.nio.file package
- has 4 imp methods:
1. preVisitDirectory() - before visiting folder
2. postVisitDirectory() - after visiting folder
3. visitFile() - when it visits a file
4. visitFileFailed() - when visit file fails
-----------------------------------------------------------------------------
PathMatcher class
it wants to count the number of a particular files from the subdirectory also