<<< Working with directories and files | Index | Using the Path class >>> |
A static method of the Paths class
Path get( String[, String]... )
For example,
Path filePath = Paths.get( "C:\\example\\Data.txt" );
Methods of the Path interface
Path getFileName() // name of the file or directory Path getName(int) // specific element of the path Path getName() // last element of the path int getNameCount() // how many elements present Path getParent() // for example, the parent of "/a/b/c" is "/a/b" Path getRoot() Path toAbsolutePath() // relative to absolute path File toFile() String toString // the path boolean exists() // true if path does exist boolean notExists() // true if path does not exist void delete() // deletes path, throws exception if no such path exists void deleteIfExists() // deletes path if it does exist
<<< Working with directories and files | Index | Using the Path class >>> |