Other things to know before moving to file class

3 0 0
                                    

Things to ponder before moving to file:

================================

Closeable - It is an interface that needs to be implemented when accessing streams, you need to invoke the close() method either manually or automatically.

... - This three dots is a varargs. Meaning variable arguments. If you see this in a parameter, meaning you can input as many as you can as long as they are of the same type. 

Atomic file operations - it is an operation that needs to completely performed or else fail.

Method chaining - this is a concept or technique to link one method after another to perform a series of operation to get the result you desired.

          Path path = FileSystems.getDefault().getPath("//whatever strings in here");

Glob - it is like a string regular pattern expressions but this is use to specify a behavioral pattern in a file name or a directory. 

syntax:

* - matches any number of characters

** - matches any number of characters but it crosses directory boundaries.

? - matches just one character

{} - matches a collection of sub patterns

         {text} - matches the word text

         {ta*} - matches any strings that starts with ta

[] - matches either a single character or if hyphen is use a range of character. You can use the following *, ?, and / inside the bracket. No need for escape character. If those three characters is not inside the bracket, you need the use the escape character / to match them.

         [a-z, A-Z] - matches any letters either uppercase or lowercase

         [e, s] - matches to either e or s only

=============================

sample of glob:

{doc*}.{txt, ppt} - match any string that begins with doc and ends with either the txt or ppt.

==============================

File Symbolic Link awareness - every method in a file will know if ever there is a symbolic link and it will provide you an option on what to do with it.


Java ProgrammingWhere stories live. Discover now