JAVA IO (byte flow into a character stream)

Source: Internet
Author: User

 Public classIndex { Public Static voidMain (string[] args) {//To create a file objectFile F1 =NewFile ("src/byte stream _ translated into _ Character stream/text.txt"); File F2=NewFile ("src/byte stream _ translated into _ Character stream/textcopy.txt"); Try (            //Create an input/output stream (java1.7 the code that starts here will automatically close)Reader InputStream =NewInputStreamReader (NewFileInputStream (F1), "GBK"); Writer OutputStream=NewOutputStreamWriter (NewFileOutputStream (F2,true), "GBK"); ){            //declaring buffer arrays            Char[] B =New Char[1024]; //declaring the number of byte variables to get            intLen =-1;  while(len = Inputstream.read (b))! =-1) {                //writes the read byte array to the destination fileOutputstream.write (b, 0, Len); }        } Catch(Exception e) {//Output Exception InformationE.printstacktrace (); }    }}

JAVA IO (byte flow into a character stream)

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.