Java I/O notes

Source: Internet
Author: User

1. Overview of common Java I/O classes

2. file reading and writing

You can choose to use FileInputStream (FileOutputStream) or FileReader (FileWriter) depending on whether the file is a binary file or a text file.

These classes allow you to read one byte or character at a time from the beginning of a file to the end of a file, or write a read to a byte array or an array of characters. Instead of reading the entire file at once, you can sequentially read the bytes and characters in the file.

If you need to read some parts of a file in a jump, or if you want to write at the same time, you can use Randomaccessfile.

You may need to read the file's information instead of the contents of the file, such as file size, attributes, and file list under Folders, you can use file.

3. Piping

The pipeline in Java IO provides the ability to communicate with two threads running in the same JVM.

You cannot use pipelines to communicate with threads in different JVMs (different processes). Conceptually, the Java pipeline differs from the pipeline in the Unix/linux system. In Unix/linux, two processes running in different address spaces can communicate through a pipeline. In Java, both sides of the communication should be different threads running in the same process.

Java I/O notes

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.