Java Tour (25)--file copy, character stream buffer, Bufferedwriter,bufferedreader, copy file via buffer, readline working principle, custom ReadLine
Let's continue IO for the last space
I. Text copying
Read and write all said, we look at the other operations, we first look at the replication
The principle of replication: In f
= br.readline ()) = null) {System.out.println (str);//At this point, Str saves a line of string}This should make it possible to get one line without losing characters.Although the writing IO aspect of the program is not much, but Bufferedreader/bufferedinputstream has been used several times, the reason is:
It has a very special method: ReadLine (), especially convenient to use, each read back is a row, save a lot of manual splicing buffer t
Today, when using Java for IO operations, the readLine () output to the console is a lot less. ReadLine () was later found to actually read one line at a time. If we don't talk. ReadLine () reads the contents of the line to a string, each call to the ReadLine () method, is a
1. Read ()Function: Reads the number of individual characters and returns 1 if it has been read (ranging from 0 to 65535)Examples are as follows: and nbsp Byte[ ] buf = new byte[1024] Int len NBS P While (len = inread (buf ) ) > 0) { //single read count until end return-1 N Bsp Out. Write (buf 0len , NB Sp In.close
The Code implements a normal line feed of the read content and copies the content to the system clipboard.
Java: bufferedReader. fileInputStream is used to read readLine () from the file. It is in the byte format. So when reading Chinese characters, the byte stream will contain garbled characters, therefore, it is necessary to use the desired stream for reading. When reading a file using FileInputStream, i
I have a text file that I want to take one line at a time.
In C #, the first while loop starts with the first line, while in Java it starts with the second row.
I just experimented, the specific reason is still not clear, but also hope that the insider came out to explain. Thank you.
The code is as follows:
Using System; Using System.IO; Using System.Collections.Generic; Using System.ComponentModel; Using System.Data; Using System.Drawing; Using Sy
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.