7.0 Streams

Source: Internet
Author: User

When I worked on Lab-1, I used Streams, though I hadn ' t learned.

And this time, let me talk about more details of Streams.

First, let ' s has a look at a piece of codes.

Implementingbinaryreadwritetofile

In the above codes, we copy a. txt file FFFF.txt to a new-built. txt file COPY.txt

Following is both files in the given directory. And they have the same contents.

Implementing buffered I/O

This time, we still copy the. txt file FFFF.txt, too. However, we used a new, that's, we copy the file by implementing BufferedStream.

We get the same result, though.

Reading and Writing to a text file

The third time, we finished the same function but this time we used Streams specially for the text file.

And this time, I write the output to the console which is the content of the copied file, FFFF.txt. We can also find the new file that is copy from FFFF.txt in the directory.

(Don ' t amazed by the content, it's just some error message that occurred if I ran another program before,,,,,, ~)

warning!

While using Streams, don ' t forget to Close () the Streams after we have the M.

-----------------END & to Be continued-----------------

7.0 Streams

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.