First, what is a flow?Flow is an abstract concept, is the abstraction of input, in Java programs, the input/output operation of data is carried out in a "stream" manner. The device can be file, network, memory and so on.Flow has directionality, as to whether it is an input stream or an output stream is a relative conce
Java input/output stream (1)
1. What is IO?
In Java, I/O operations mainly refer to the use of Java for input and output operations. all Java I/O mechanisms are input and output based on data streams, which represent the flow sequence of character or byte data.
used to write data to the hard disk.
Core methods:
InputStream:
int read(byte [] b, int off, int len)
The read method is used to read data. The first parameter is a byte array used to store the read data. The second parameter is the offset, which specifies that the read data is stored from the specified position of the array. The third parameter indicates the length of the array, that is, the amount of data that can be read by read each time. The return value of this method is the number of byt
corresponding base class typeBufferedreader: Provides the Readline Method for colleges to read a single string.Bufferedwriter: Provides newline for writing a line separator, that is, line feed.Bufferedinputstream is of little useBufferedoutputstream is of little use11. Conversion stream. Great use!When constructing a conversion stream, you can specify its encoding set.Inputstreamreader needs to be connecte
Objective:
We are using Java io stream outputstream, printwriter ... , the Flush () method is often used.
A Why to Flush:
Like caching in network hardware, streams can also be cached in software, which is cached directly in Java code. This can be achieved by Bufferedoutputstream or bufferedwriter links to the underlying st
: OutputStream or Writer: output from the program to a file;
Node streamNode stream: Directly connected to the data source, read in or read out.Direct use of node flow, read and write inconvenient, in order to read and write files faster, only the processing stream.Common node streams
Parent class: InputStream , OutputStream , Reader ,Writer
File:,,, FileInputStream FileOutputStrean FileReader FileWriter file to process the node
has been identified, there are too many objects in the system. Which one is used?
Specific data devices.
Devices corresponding to the Data source: Hard Disk (File), memory (array), and keyboard (System. in)
Devices for data collection: Hard Disk (File), memory (array), and console (System. out ). 4. Do I need to add other functions to basic operations? For example, buffer.
Decoration if needed. The File class encapsulates files and folders in the Fil
This article will discuss about Thread pool that uses single thread to execute tasks. From Java 5.0 + one can get such pool from Executors using following method-Public static ExecutorService newSingleThreadExecutor ()Creates an Executor that uses a single worker thread operating off an unbounded queue. (Note however that if this single thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to ex
Randomaccessfile Overview
The Randomaccessfile class does not belong to a stream and is a subclass of the object class. But it incorporates the functions of InputStream and OutputStream.
Supports read and write to random access files.
B:read (), write (), Seek ()
13. IO Stream (data input/output stream)
1. What is
1, read/write (input/output) is for me, not for you to manipulate the object, such as reading the file is I read the file, for me is input, and I write files, for me is the output.2, Java IO uses the packaging mode, a flow wrapper another stream, to achieve better purposes. What is the rule of a flow wrapper for another flow? Use the byte stream to read the file,
This article will discuss about Thread pool with fixed number of thread. From Java 5.0 + one can get such pool from Executors using following method-Public static ExecutorServiceNewFixedThreadPool (int nThreads)Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. at any point, at most nThreads threads will be active processing tasks. if additional tasks are submitted when all threads are active, they will
the comparer.
Min
Returns the smallest element in the stream according to the comparer.
Of
Returns a stream that has a value given.
Reduce
Use a unique ID and accumulator on the stream to perform the decrement operation.
Sorted
Returns a new stream
One, character stream BufferedReader:BufferedReader reads the contents from the buffer, and all input byte data is placed in the bufferBufferedWriter: Writes a batch of data to a buffer, when the buffer area is full, and then writes the contents of the buffer to the character output streamSecond, read and write to the text file 2.1, character input stream2.2. Character output stream2.3. Comprehensive use Packagecom.pb.io.buffered;ImportJava.io.Buffere
() fd = new FileDescriptor ();FileOutputStream f2 = new FileOutputStream (fd );Method 4: The constructor uses the file name as its first parameter and the Boolean value as the second parameter.FileOutputStream f = new FileOutputStream ("d:/abc.txt", true );Note: (1) when writing data in a file, if the file already exists, it overwrites the existing file; (2) when the read/write operation ends, the close method should be called to close the stream.Program ex
IO stream 05 -- video Study Notes for bixiangdong JAVA basic tutorial, 05 -- bixiangdong
Day20
10 create a java file list11 Properties12 Properties access13 Properties14 Properties exercises15 PrintWriter16 merge streams17. Cut files
10 create a java file list
Exercise:Store the absolute path of a
methods are as follows:1, FileInputStream (String name)2, FileInputStream (file file)Similar to FileOutputStream, the use of the latter is recommended. FileInputStream, also writes an example, operates the "Stream.txt" generated under the D disk above: public static void Main (string[] args) throws exception{file File =
new File ("D:/stream.txt"
); InputStream in = new FileInputStream (file); byte b1[] = new byte[( Span
Java-stream end and Exception Handling Mechanism, java-Exception Handling
1.1java.io.objectInputStream object input stream: used to read and convert a group of bytes (a group of bytes converted by writing an object through the object output stream) to the corresponding objec
); System.out.println(date1);} catch (ParseException e) { e.printStackTrace();}
Merging stream compression streamsSupports three formats of compression, Zip/jar/gzip, zip here for example the other two are the sameZipEntry, is the compressed file directory of each file
Zipoutputstream (OutputStream)
Putnextentry (zipentry?)
Files, folders can be compressedZipFile cl
(); byte[] Breturn = null; MemoryStream ms = new MemoryStream (); Bitreturn.save (MS, System.Drawing.Imaging.ImageFormat.Png); Breturn = Ms. GetBuffer ();It is believed that this article has certain reference value for the C # program design of everybody.In addition to the Declaration,Running GuestArticles are original, reproduced please link to the form of the address of this articleExample tutorial for converting between stream and byte[] in C # Th
【Core JavaLearning notes Java SE8 Stream library stream from iteration to streamIf you want to calculate how many long words are in a text (letter >12).
Iterative type:getlist();//虚构方法,获得一个Listlong0;for(String w:words){if(w.length()>12) count++;}
Flow type:getlist();//虚构方法,获得一个Listlong count = words.stream().filter(w->w.length12).count();
The benefits of
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.