public int skipbytes (int n) throws IOException
The file pointer moves backwards n bytes, and n is negative when the pointer does not move
public int read (byte[] b) throws IOException
Reads a maximum of b.length bytes into the array b
public void Write (byte[] b) throws IOException
Writes B.le
Java learning notes 43 (brief introduction to the print stream and IO stream tools) and learning notes
Print stream:
There are two classes: PrintStream and PrintWriter. The methods of the two classes are the same. The difference is that the constructor
PrintStream: constructor: receives the File type, receives the string File name, and receives the byte output stream (OutputStream)
PringWriter: constructor:
By reading the Java Io source code, you can find the basic architecture of Io. Note: This article is purely intended to record and share what you have learned. Some images and code are from other blogs. Sorry, I hope that people who have read this blog can leave your comments and give them a learning opportunity. Thank you very much !!!
* Byte-based
and provide methods such as print ().In addition, PrintWriter and PrintStream are directly created if no file object exists.They will overwrite the original files, but there is no way to add them.It's easy to solve this problem. Check the API documentation again. PrintWriter has a constructor PrintWriter (Writer out), that is, it can pass in the Writer object.PrintStream has a constructor PrintStream (OutputStream out), that is, it can pass in the OutputStream object.Therefore, we can write it
JAVA 47th-IO stream (1): file read/write
Input stream and output stream relative to memory
Read data from external devices to memory: Input
Write data in memory to external devices: Output
I/O streams often use base classes
Abstract base class of byte stream: InputStream, OutputStream
Abstract base class of characters: Reader and Writer
PS: The child classes generated by these four schools are suffixed with
Next: "Architecture design: Inter-system Communication (4)--io communication model and Java Practice Medium", we continue to explain asynchronous IO7. Asynchronous IOIn the previous two articles, we explained the three IO models for blocking synchronous IO, non-blocking synchronous
cannot be saved during serialization, the value obtained by static object variables in deserialization is the value of the static variable corresponding to the corresponding class in the current jvm, and transient (transient) keyword is generally used to identify state variables that do not need to be passed during serialization.
Simple test code:
01Import java. io. FileInputStream;02Import
asynchronoussocketchannel created through asynchronoussocketchannel belongs to the same group and shares resources.
The callback interface of the asynchronous Io operation result of Java. NiO. channels. completionhandler is used to define the callback work after the IO operation is completed. The aio api allows two methods to process asynchronous operation resu
) {
e.printstacktrace ();
} finally {
fis.close ();}}}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21-22Note: The above program finally uses the Fis.close () to turn off the input stream of the file, like JDBC programming, open the file IO resources in the program does not belong to the memory resources, garbage collection mechanism can not reclaim the resource, so should be shown to close the open
Reproduced from: http://blog.csdn.net/daijialin/article/details/231384Prior to JDK 1.4, Java IO Operations were concentrated in the Java.io package and were based on the streaming blocking (blocking) API. For most applications, such APIs are easy to use, however, some applications with high performance requirements, especially server applications, often require a more efficient way to process
.
Then there is the fileio class for various Io operations.
Package Org. wing. NIO. test; import Java. io. bufferedinputstream; import Java. io. bufferedoutputstream; import Java. io.
improve the character writing efficiency, added buffer 16 // as long as the stream object to be improved as a parameter is passed to the buffer's constructor, 17 BufferedWriter bufw = new BufferedWriter (fw ); 18 19 for (int x = 1; x
02 IO stream (BufferedReader)
1/* 2 Characters read buffer 3 this buffer provides a method to read a row at a time, readLine () 4 */5 import java.
The instance describes Java IO file replication, and the instance describes javaio
IO streams are mainly divided into two categories: byte streams and byte streams.
Note:
1. audio files, images, and videos (with a wide range) are throttled by words
2. if it involves only the text, the ghost stream is used.
Use byte streams to copy text content (other files can al
Common IO streams in Java and their usage
In Java, IO streams are divided into two categories. One is the input stream. All input streams are directly or indirectly inherited from the InputStream abstract class. The input stream is used as the data source, we can read byte data through the read method of the input stre
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.