In the Java IO Stream read and write files, always by its various streams can be very confusing, there are more than 40 classes, clear, after a period of confusion, decided to tidy up! In case you forget again.Java input/output stream architecture1. Byte stream and character streambyte stream: Read by bytes. character stream: read by characters. The character stream reads conveniently, the character stream
The operation of the byte stream and the character stream is basically the same, the difference is only the data unit of the operation is different: the data unit of the byte stream operation is the data unit character of bytes, character stream manipulation.
InputStream and reader are the base classes for all input streams, all of which are two abstract classes and cannot create instances by themselves, bu
1.File classThe file class can use a path string of files to create a file instance, which can be either an absolute or a relative path, and by default the system always interprets the relative path based on the user's working path, which is specified by the system property "User.dir". This is usually the path where the Java virtual machine is running.File cannot access the content itself. If you need to access the file content itself, you need to use the in
I/O system1: Stream:(1) Whether the judgment is input or output; always stand on the position of the program;(2) Determine whether the transmission is byte or character, thus determining the thickness of the pipe;A byte pipeline can pass all the data, and the character pipeline is designed to pass text data (1 characters equals 2 bytes)2:java Stream four Parent classes:Classification of streams: character s
Java Input/outputJava I/O is supported by classes and interfaces under the Java.io package, the most important of which is the 5 classes, File,outputstream,inputstream, Write,reader, and an interface serializable.File class: The ability to manipulate filesBYTE stream: (Outputstream/inputstream), you can use the byte stream to read the file contentsCharacter stream: (Writer/
********************InputStreamReader (bytes to characters) and Outputstreamreader(characters to bytes):1.InputStreamReaderA bridge from a byte stream to a character stream: It reads in bytes and converts it to a character stream based on the specified encoding.The encoding used may be specified by name, or the platform can accept the default encoding methodEach invocation of one of the InputStreamReader's read () methods may cause one or more bytes to be read from the base byte
Typically, a Python program can read input from the keyboard or read input from a file, and the results of the program can be printed to the screen or saved to a file for later use. This article describes the most basic I/O functions in Python.
One, console I/O
1. Reading keyboard input
built-in function input ([pro
)C:public set(3) method of combining IO streamLoading the contents of the text file into the collection in the form of key-value pairspublic void load (reader reader);pub1ic void 1oad (InputStream instream);To store the data in a collection in a text filepublic void Store (writer writer, String comments);public void Store (OutputStream out, String comments)(4) Case:A: According to the given file to determin
reader after reading should also write their own, perhaps later can use it!1#include 2#include 3 4 #defineSIZE 165 6 Char* Ud_gets (Char* St,intSize) {//input7 inti =0;//counter8 while(((St[i] = GetChar ())! ='\ n') (i 1) )9i++;//Continue reading if non ' \ n ' characters are read or not out of boundsTen while((I > Size-1) (GetChar ()! ='\ n')) One Continue;//if the read exceeds the bounds and there are characters later, disca
1KB write for unit while (Off if (len >= datalen) {Out.write (Outdata, off, datalen);} Else {Out.write (Outdata, off, Len);}// Flush BuffersOut.flush ();Off + = Len;Datalen-= Len;}// Close the streamOut.close ();// Get the answer codeint Respcode = Conn.getresponsecode ();// gets the input stream returnedInputStream InputStream = Conn.getinputstream ();receive (Receive request data and answer) :// Get i
Formatted input and output in Golang
This article turned from: http://zh.golanger.com/pkg/fmt/, and made a partial modification
The "Introduction" FMT Package implements formatted I/O functions, similar to the C printf and scanf.
The format placeholder is derived from C, but is simpler than c. Print placeholder: [General]%v the default format for the corresponding value.
When the structure is printed,
Talent Technology 2017-01-09 08:56
According to the transmission direction of the data, the flow is raw binary data without processing, and it can be processed by some code to conform to some form regulation.
A particular data, i.e. a stream is a sequence of bits (bits) or a character (character), such as a sequence of character streams and a sequence of numeric streams.
The flow of data from peripheral or external memory (such as keyboards, mice, files) to an application is called an
a byte array filled with multiple bytes4, the basic mode of output stream is mainly writtenout.write (int b);out.write (byte[] buf);5, FileInputStream Specific implementation of the file read operationWhile ((B=in.read ())!=-1) {read a file}in.close ();//must remember to close the flow release system resourcesBulk Read (very fast, high efficiency) vs. single-byte reading (not suitable for reading large files, very inefficient)6, FileOutputStream Spec
Tcp program design-the client obtains the input and output streams of the server, and the tcp Program DesignTcp Program Design -- the client obtains the input and output streams of the server.
Ideas:
Step 1: instantiate a ServerSocket object (server socket) to wait for requests on the Network (that is, the socket waiti
into the buffer.Obviously, the second way, it will reduce the IO operation, more efficient, the disadvantage is that memory consumption of more.Java input and output streams are designed in a multilayer packageThe bottom inputstream and OutputStream are based on byte stream, there is no caching mechanism, generally used with bufferinputstream and Bufferoutputstream encapsulation.The Read method of the Buff
C language character input and output
The input/output model provided by the standard library is very simple. Regardless of where the text is entered and where it is exported, its input/output is handled in the same way as a st
Java input/output streamPre-knowledge preparation1. Basic Java SyntaxBasic principle:While the program is running, it may be necessary to read the required data from an external storage medium or other program, which requires the use of an input stream object. The input stream points to the source called it, and the pr
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.