java file code example
Example 1: Java Files
import java.io.File; // Import the File class
File myObj = new File("filename.txt"); // Specify the filename
Example 2: open file java
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();
}
}
}
Example 3: java file class
import java.io.File;