Write some characters to the directory on the specified hard disk:
Import java.io.*;//Save some text to the file in the hard disk//manipulate the text, so use character stream to manipulate public class Filewriterdemo {public static void main (string[] args) {//Create a character output stream object that can write character data to a file// since it is written to a file, it must be explicitly defined when creating the object (the destination where the data is stored) //If the file does not exist, it is automatically created //If the file exists, it will be overwritten filewriter FW = NULL; try { fw = new FileWriter ("c:\\users\\administrator\\desktop\\ Test folder \\FileWriterdemos1.txt");//Call Write method to write Data fw.write ("Asdfsdafsafs"); Refresh to write data directly to the destination Fw.flush ();} catch (IOException e) {//TODO auto-generated catch Blocke.printstacktrace ();} Finally{try {fw.close ();} catch (IOException e) {e.printstacktrace ();}}} }To run the program:
Dark Horse programmer--java--io stream-writes some characters to a directory on the specified hard disk: