In this example, we create a new file using the File class of the java.util package. We provide the name of the file we want to create as a string to the File constructor. If the file doesn't exist, it returns true and creates a new file, otherwise, it returns false and displays a message indicating that the file already exists. Example 2: Deleting a file using File class:java import java.io.File; public class DeleteFileExample { public static void main(String[] args) { try { File file = new File("fileToDelete.txt"); if (file.delete()) { System.out.println("File deleted successfully"); } else { System.out.println("File doesn't exist or unable to delete"); } } catch (Exception e) { e.printStackTrace(); } } } ``` In this example, we delete a file using the delete() method of the File class. If the file exists and successfully gets deleted, it returns true and displays a message indicating that the file has been deleted successfully. If the file doesn't exist, it returns false and displays a message indicating that the file doesn't exist, or if the file has been deleted unsuccessfully, it returns false and displays a message indicating that the file is unable to delete. The java.util File package library is a part of the Java standard library.