Check out example codes for "open file java". It will help you in understanding the concepts better.

Code Example 1

import java.io.*;

public class openFile {

    public static void main(String[] args) {
        try{
            File file = new File("C:\\file.txt");
        }catch(Exception e){
            e.printStackTrace();
        }
    }
    
}

Code Example 2

try{
  File f=new File("C:\\demo\\demofile.txt");
}catch(Exception e){
 	e.printStackStace(); 
}

Learn ReactJs, React Native from akashmittal.com