Dark Horse programmer--java--io stream-writes some characters to a directory on the specified hard disk:

Source: Internet
Author: User


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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.