Basic knowledge of Java ignored (iv)

Source: Internet
Author: User

Java IO (not the general importance)

54. Stream in IO: Byte stream (InputStream, outputstream), character stream (Reader, Writer), conversion stream (InputStreamReader, outputstreamwriter), compressed stream (zipxxx (), Pipe flow (PipedInputStream, PipedOutputStream), memory flow (Bytearrayinputstream, Bytearrayoutputstream), Merge Stream (Sequenceinputstream), Data manipulation flow (DataInputStream, DataOutputStream), fallback stream (Pushbackinputstream, Pushbackreader).

55, the Java IO operation the corresponding steps: A use the file class to open a document, b by the byte stream or character stream to specify the location of the output; C read/write operation; d close the input/output stream.

56. File Common methods: File.separator, File (str), CreateNewFile (), delete (), exits (), isdirectory (), Length (), mkdir (), Public File[] Listfiles () (Lists all contents of the specified directory, lists the paths), public string[] List (lists all contents of the directory, lists only the names of the files, no full paths to the files), Renameto (file dest).

57, add the line \ r \ n.

58, add information at the end of the file, do not overwrite the original information: New FileInputStream (File,true), New FileWriter (File,true).

59, read the content:

InputStream class byte[] b=new byte[(int) file.length];

Input.read (b);

or while ((Temp=input. Read ())! =-1)

{

b[len]= (byte) temp;

++len;

}

FileReader class while ((Temp=reader.read ())!=-1)

{

ch[len]= (char) temp;

++len;

}

60, Write content: OutputStream class byte[] B=str.getbytes (); Out.writer (b). FileWriter class Out.write (str);

61, character stream and byte stream difference: Byte stream directly manipulate the file itself, character stream through the buffer indirectly manipulate files. All files in the hard disk or in the transmission of the form of byte stream, byte stream operation more extensive.

62, Edge Write while ((Temp=input.read ())!=-1) {out.write (temp);}.

63, the conversion stream OutputStreamWriter is the writer's subclass, InputStreamReader is the reader subclass.

64, Pipeline (inter-thread communication through the pipeline) Flow: PipedInputStream, PipedOutputStream (this class has a connect (PipedInputStream Pi) method to associate two).

65, printing flow: PrintStream, PrintWriter, you can

Basic knowledge of Java ignored (iv)

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.