import java.nio.file.*; import java.util.*; public class FileWriteExample { public static void main(String[] args) { try { // Specify the file path String filePath = "/path/to/your/file.txt"; // This is the content that will be written to the file ListIn this example, we import the java.nio.file package to use the Files and Paths classes. We then specify the file path as a String and create a List object with the content that we want to write to the file. Finally, we call the Files.write() method and pass in the file path and the content to be written. The java.nio.file.Files class is included in the standard Java library and is part of the java.nio.file package.lines = Arrays.asList("The quick brown fox", "Jumped over the lazy dog"); // Write the content to the file Files.write(Paths.get(filePath), lines); System.out.println("Successfully wrote to the file!"); } catch (Exception e) { System.out.println("An error occurred while writing to the file."); e.printStackTrace(); } } }