IO stream in Java (1)

Source: Internet
Author: User

BYTE stream://bytes One byte read-write FileInputStream in=new fileinputstream ("source file"); FileOutputStream out=new fileoutputstream ("Target file"), ... in.close (); Out.close (); First, remember that once the IO stream is used, it is common sense to remember to close it. Using buffer, efficient read byte bufferedinputstream in=new bufferedinputstream ("source file"); Bufferedoutputstream out=new Bufferedoutputstream (new FileOutputStream ("Target file"), ... in.close (); Out.close (); Character stream: InputStreamReader isr=new inputstreamreader (New FileInputStream ("Source file path"), "set Encoding"); OutputStreamWriter osw=new OutputStreamWriter (New FileOutputStream ("Destination file path"), "set Encoding"), ... osw.close (); Isr.close (); or you can write this: FileReader fr=new FileReader ("Source file path"); FileWriter fw=new FileWriter ("Destination file path"), ... fr.close (); Fw.close ();//Use buffer, efficient read character BufferedReader br=new BufferedReader (New Filereade ("Source file path"); PrintWriter pw=new printwriter ("Destination file path"), ... br.close ();p w.close (); serialization and deserialization://serialization of Objects ObjectOutputStream Oos=new ObjectOutputStream (file), where file refers to a string file= "the path of the files in the project";//deserialization of the object ObjectInputStream ois= New ObjectinputstreaM (New FileInputStream (file)); 

  

IO stream in Java (1)

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.