COntent

```java import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class ContentWritingTool { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter the content:"); String content = scanner.nextLine(); System.out.println("Enter the file name (with extension):"); String fileName = scanner.nextLine(); try { FileWriter writer = new FileWriter(fileName); writer.write(content); writer.close(); System.out.println("Content is written to the file."); } catch (IOException e) { System.out.println("An error occurred while writing the file."); e.printStackTrace(); } scanner.close(); } } ```
 

social media

Powered by Blogger.