, outputstream, reader, and writer. In Java, other diverse stream types are derived from them:
Among them, inputstream and outputstream already exist in earlier Java versions. They are based on byte streams, while reader and writer based on bytes streams are later added as supplements. The above level chart is a basic level system in the Java class library.
In these four abstract classes, inputstream an
generating key-value pairs. The end of the read data is where the Recordreader in the file should stop reading.Some methods that must be overloadedInitialize initializing the record reader is based on the file input format, which is suitable for locating the byte position where the file starts to read. Getcurrentkey and GetCurrentValue The framework uses these two methods to pass the generated key-value p
character encoding when processing a character stream importjava.io.*;publicclassencodetest{ Privatestaticvoidreadbuff (Byte[]buff) throwsIOException{ ByteArrayInputStreamin=new Bytearrayinputstream (Buff);intdata; while ((Data=in.read ())!=-1) System.out.print (data+ ""); System.out.println (); in.close ();} publicstaticvoidmain (stringargs[]) throws Ioexception{system.out.println ("Unicode character encoding in memory:" ); chArc= ' Good ';intlowbit=c0xff; inthighbit= (CAMP;0XFF00) >>8; sy
not appear in the InputStream section, mainly because the string should belong to the range of character stream. Has been abandoned, of course, the output part of the need for it is not necessary! It is also allowed to exist just to keep the version backwards compatible.4.SequenceInputStream can be thought of as a tool class that reads two or more input streams as an i
to the user's input in the console, System.out is the output of the value console System.out.print ("Please enter a line of things:"); String inputstring= "";//scanner reads system.in, nextline () reads a line, that is, Inputstring=new Scanner (system.in) until the first carriage return is read. Nextline (); SYSTEM.OUT.PRINTLN ("You entered:" +inputstring); System.out.print ("Please enter a line of things:
Transferred from: https://www.cnblogs.com/biehongli/p/6074713.htmlThe 1:java language defines many classes that are specifically responsible for input or output in various ways, and these classes are placed in the java.io package. whichAll input stream classes are abstract class InputStream (byte input stream), or abst
Concept of Flow:1. An in Putstream that operates on a byte. out Putstream class in is the reading data, out is the output data, the number is easy to confuse.The most common subclasses of InputStream and OutputStreamFileInputStream and FileOutputStream working with byte dataDataInputStream can be used in binary operation2. Reader.writer class for string manipulationReader.writer subclasses Bufferedreader.bufferedwrite can manipulate strings---------
textinputformat the entire file line as the value data, Keyvalueinputformat is the Search tab character to split the row into key-value pairs. This is especially useful when outputting a mapreduce job as input to the next job, because the default output format (described in more detail below) is to output data in Keyvalueinputformat format. Finally speaking Sequ
handle characters is more common, and in order to handle characters, the reader and writer two abstract classes are available in Java to handle character input and output.The underlying method of the InputStream class is the Read () method, which reads a byte from the input source, the return value is the read-in byte, and the return type is int. The specific ty
Overview:
Various stream types (classes and abstract classes) are located in the Java.io package, each of which inherits one of four abstract streams:
Type
BYTE stream
Character Stream
Input stream
InputStream
Reader
Output stream
OutputStream
Writer
10.1.1 concept of stream
1). input and output streams
Buffered stream)
10.1.2 input/output stream class library
Data processing can be divided into two types: byte stream and character stream. byte stream is also called binary byte stream) or bit stream (BITS steam ).
Java. Lang. Object->
Inputstream \ outputstream \
allows you to write Java objects into data streams.Optimize the read/write processJDK 1.1 adds a set of read/write classes that provide more useful abstraction and better input/output performance than existing data stream classes. For example, BufferedReader and BufferedWriter are used to read and write text from character-based input and
); BufferedReader is = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); //进行输入 输出控制 .......
The above code snippet only uses the synchronization mechanism to write the socket process communication frame, actually needs to consider the question to be more complex (the interested reader may refer to my article "The Internet Real Time communication system design and the realization"). This frame is listed o
Java input/output stream (2)
6. Java. IO stream class library1. Four Basic classes of io streams
The java. io package contains all classes required for stream I/O. There are four basic classes in the java. io package: InputStream, OutputStream, Reader, and Writer. They process byte streams and response streams respectively:
Basic data flow I/O
, character-based I/O operations. The Write class is an abstract class, not a real data stream, but it provides the user with a way to write a binary as a stream of characters.Subclass of Reader class:Bufferdwrite: Writes text to the output stream, providing buffering of the characters writtenPipedwrite: Writing characters to PipedreaderPrintwrite: Write a formatted character (format the binary number as a
DataOutputStream (bufferedoutputstream); Out.writeint (3); Out.writeboolean (true); Out.flush (); Out.close (); The stream of nodes is entered here, and the filter stream corresponds exactly to the upper output, and the reader can extrapolate datainputstream in = new DataInputStream (New Bufferedinputstream new FileInputStream ("A.txt")); Syst
Java I/O system (input/output stream) Flow characteristics 1. Contains liquid (data) 2. It has the classification of direction (read or write) Flow: input stream and output stream input stream: input stream in IO packet inherits f
Input and output are the ways in which applications interact with users. In the command line mode, standard input and output devices (the console of the keyboard and display) are used ), in Windows applications, users can interact with users through graphical user interfaces, while in Web applications, users can intera
:"); System.out.println (str); }Writer--output data to the corresponding output stream (the target of the output), written to the fileFlush ()--Brushes all output streams and outputs all cached bytes to the corresponding output stream.Class FileWriter Inheritance OutputSt
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, but
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.