this channel ' s file to the given writable byte* Channel.* * That reads from this channel and writes to the target channel. Many* Operating systems can transfer bytes directly from the filesystem cache* to the target channel without actually copying them. Public Abstract Long transferTo (long position, long count,writablebytechannel target)throws IOException;The above is the new method of FileChannel.The FileInputStream member variables in the I/O
After a day of study, the basic has a certain understanding of Java--io, and now share with you.Java. The IO package defines the types of multiple streams (classes or abstract classes) to implement input and output functions, which can be categorized from different angles:Can be divided into input stream and output stream according to different direction of data
: node flow and processing flow.Output stream:Input stream:So both the input and the output are from the point of view of the program.BYTE stream: A read-in or read-out is a 8 -bit binary.Character Stream: A read-in or read- out is a binary binary.The principle of a byte stream and a character stream is the same, except that the units are handled differently. The suffix is stream is a byte stream, and the prefix is Reader, andWriter is a stream of characters.Node stream: Directly connected to t
Is to write a file, that is, output (o ).
Package COM. sinosuperman. driver; import Java. io. bufferedwriter; import Java. io. file; import Java. io. filewriter; import Java.
io stream in JavaAccording to the direction of the flow is divided into the input stream and the output stream according to the size of the read text stream and the character stream byte stream bytes read read Chinese when it is easy to garbled characters stream by character reading is usually used to read the Chinese based on the read way node stream and cache stream file input stream and output stream (FileInputStream fileoutputstream) FileInputStre
From: www.chinaitlab.com: 18 times
Provided by yangyi at 22:00:02 on
I. Three types of Io streams1. stream direction: input stream and output stream2. Data Units of streams are divided into byte streams and byte streams.3. Different stream-based functions are divided into node stream and processing stream.Ii. Four abstract classes of Io streams:Internal stream: reader writerByte stream: in
original nature of the dataMerge Flow Sequenceinputstream, direct example Applicationcut stream split, cut a file into three files for example, there are no new objects. For example, list all directories: RecursiveImport Java.io.*;import java.util.*; public class Test {public static void main (string[] args) throws IOException {file f= new file ("e:\\ Baidu Cloud Sync Disk");Showdir (f); public static void Showdir (file dir) {file [] files = Dir.list
Standard code for IO Stream (advanced) Release resourcesThe main consideration is when the release of resources is more appropriate. And before and after jdk1.7 is different.Package Com.wzlove.demo;import Java.io.filereader;import Java.io.filewriter;import java.io.ioexception;/** * Standard IO format processing * * @author wzlove * @create 2018-07-23 9:54 */public class Standardio {//jdk7 before public stat
Java IO stream byte output stream OutputString (), output stream outputstring
One of the key points of Java learning: Use of the OutputStream byte output stream
FileOutPutStream: a subclass that specifies the channel for writing data.
Steps:
1. Get the target file
2. Create a channel (if no target file exists, a channel is automatically created)
3. write Data wri
The main operations of Java IO have been finished before
In this section, we'll talk about other aspects of Java IO
serializable serialization
Instance 1: Serialization of Objects
Copy Code code as follows:
Import Java.io.File;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import Jav
. out. println (p );}}
Filter:
If the. java file in drive C is used, the filter is used.
list(FilenameFilter filter)Returns an array of strings that specify the files and directories that meet the specified filter in the directory indicated by this abstract path name.
FilenameFilter,The class instance that implements this interface can be used for the filter file name.
This interface has only one method:
accept(File dir,String name) Test whether the
Inheritance level of Reader/Writer is designed to be internationalized. The byte stream only supports 8-bit read/write and cannot process 16-bit Unicode characters well, the char of java itself is 16 bits, and the addition of the escape stream is to support Unicode in all IO operations.
Suggestion: Try to use the byte stream whenever possible. If you cannot meet your requirements, consider byte stream !!!
:\\webworkspace"); Try (directorystream files.newdirectorystream (dir)) { for(Path e:stream) { System.out.println (E.getfilename ()); } } Catch (IOException e) { }Above is the traversal of a single directory, which does not traverse the entire directory. Traversing the entire directory requires the use of: Files.walkfiletree8) traverse the entire file directory: Public Static v
1. Character Stream In the program a character equals two bytes, Java provides us with reader and writer two classes dedicated to manipulating character streams 1) Character output stream: Writer Writer is a character stream, which is an abstract class, so to use it, it must also be instantiated by its subclass before it can be used. common methods of writer class
Method Name
Description
Public abstract void C
ObjectiveIn the previous article, I reviewed the multithreading of Java. In this article, we mainly introduce the knowledge of Java IO .Introduction to IOWhat is IO?
The name of IO is also the abbreviation for input and output, which is the inputs and outputs stream
-encoded objects and to improve the input and output operation function "Decorate" class.The following is a code for reading and writing memory dataImport Java.io.ioexception;//import Java.io.stringbufferinputstream;import Java.io.stringreader;import Java.io.bufferedoutputstream;import Java.io.filenotfoundexception;import Java.io.fileoutputstream;import Java.io.printstream;import Java.io.stringreader;public class IOExample1 {public static void main (string[] args) {try{ String meminput= "Input i
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.