File class:RenametoDeleteListListfilesFilenameFilter Flow: A conduit for data communicationFlow of data: file, memory, networkClassification of streams:1. Direction2. Units3. function Common streams:Node Flow:1, File Stream (FILEXXX): Manipulate the flow of files, data stored in the file2. Memory Stream (BYTEARRAYXXX): Flow of operating memory, data stored in memoryProcessing Flow:3. Buffer
IO Stream classification
I/O flows based on byte operations: InputStream and OutputStream
I/O flow based on character manipulation: reader and writer
I/O streams based on disk operations: File
Network operation-based I/O Flow: Socket
Generally, the first two of us are more commonly usedFile Basic Operations Public Static void Main(string[] args)throwsioexception{File File =NewFile ("D:/python"); File.mkdir();//folder does not
The simple use of Io flow is very simple ~ PackageCom.j2se.d59.demo;ImportJava.io.*;//the objects in IO are from java.io.*;//The input and output of the IO stream is relative to the memory Ram//Categories: units "byte stream, character stream" or direction "input stream, output str
Java IO (input output) stream I. IO stream Overview 1. IO stream is used for data transmission between devices. 2. Data Operations in Java are performed in a stream-based manner. 3. Classification: 1) data by Operation: byte strea
class -_-! Note that java. io. * is introduced at the beginning of the program. The input and output streams are used.
Class FileTest {public void copyFolder (String oldPath, String newPath) {try {// create a new folder (new File (newPath) If the folder does not exist )). mkdirs (); // read the content of the entire folder to the file string array. Set a cursor I below, and read the array File filelist = new File (oldPath) without stopping the move )
Java knowledge point list V1.0 and java knowledge point listJava knowledge point list V1.0
1. download and install the Java SDK in the Development Environment
2. environment variable configuration (path and classpath)
3. Naming rules for basic programming identifiers
4.
Buffered Stream buffer: Set buffer for faster execution efficiencySub-class:(i) Bufferedinputstream: buffer input byte stream, purpose: Improve the efficiency of reading filesNote: Bufferedinputstream He is not capable of reading and writing dataInternal implementation: You maintain a byte array of 8 bytes.Steps to use:1. Locate a target file.2. Establish the cha
The logging here is implemented using the print stream.The content in the text message is of type string. And like writing data in a file, we often use the file output stream object FileOutputStream.1 New File ("F:\\a.txt"); 2 New FileOutputStream (file,true); // The second argument is an append text 3 outputstream.write (97);After the above code executes, the content in A.txt is a, because the write method receives data of type Byte, and 97 correspon
1. Get all files or folders in the specified directory1 Packagecn.itcast_01;2 ImportJava.io.File;3 Importjava.io.IOException;4 /**5 * Requirements: Gets all files and directories in the specified directory (returns an array of names or a file array)6 */7 Public classFileDemo5 {8 Public Static voidMain (string[] args) {9 //To create a file object and specify an abstract path nameTenFile File =NewFile ("E:"); One //
. This is extremely important, it not only reduces the file space, and even if the code is not very sophisticated, there is no need to worry about an infinite loop (an example of an insensitive case where you can save objects in a recursive way without effectively auditing which objects have been saved, and then you may end up in a never-ending loop).
Unfortunately, the file format defined by the Java serialization mechanism appears to be fragile, a
What is a stream?Flow in Java refers to a buffer that flows in a calculationClassification of streamsThe main differences between character streams and byte streams are:
When a byte stream is read, it returns a byte when it is read, and the character stream reads one or more bytes using the byte throttle (the
In Java 8, the stream cannot be reused, and once it is used or consumed, the stream is closed. 1. Example–stream has been closed!
Looking at the example below, it will be thrown a illegalstateexception that says "stream is closed"
("Ran.txt", "RW");//Throw abnormal raf.write ("Assad". GetBytes ());//Use the default character set of the platform to encode this String as a byte sequence and store the result in a new The byte array. Raf.writeint (97);//can write basic data type Byte, int accounts for 4 bytes three spaces +araf.write ("Adelaide". GetBytes ()); Raf.writeint (98); Raf.close ();}Random writes and detailspublic static void Randomwrite () throws Ioexception{randomaccessfile RAF = new Randomaccessfile ("Ran.txt",
Reprint please indicate source: http://www.cnblogs.com/lighten/p/7063161.html1. PrefaceThe previous chapters have introduced all paired (input and output) byte streams in the Java IO Package, and this chapter describes some of the remaining byte streams, including: Linenumberinputstream, Sequenceinputstream, StringBufferInputStream. In JDK8 's version, only the middle sequenceinputstream were not discarded, and the other two were indicated to be obsol
Java IO (input output) stream 1. The buffer of the upstream stream 1. What is the buffer, also known as the cache, is a part of the memory space. That is to say, a certain amount of storage space is reserved in the memory space, which is used to buffer input or output data. This reserved space is called a buffer zone. The buffer zone is divided into the input buf
("!hello World!"); //use the methods in the buffer to flush the data to the destination file. Bufw.flush (); //closes the buffer while closing the FW stream objectBufw.close (); }}BufferedReader:test.txt------The >java programConstruction method: BufferedReader br = new Bufferreader (Reader in);Main methods: int read (); Reads a single character.int read (char[] cbuf,int off,int len);//reads a character in
, "utf-8"); Osw.write ("Hello! ");//Do not write flush cannot flush buffered write file, close Close file also has this functionOsw.write (' Medium ');//write single characterOsw.write ("First meeting, please take more care", 2, 3);//write a part of a string; start with the second character, write three altogether
char[] ch = {' present ', ' Day ', ' Down ', ' rain '}; Osw.write (CH); //write array osw.write (CH, 2, 2); //Starting from the
JAVA 52nd-IO stream (6) File object
File class
Used to encapsulate files or folders as objects.
Convenient operations on file and folder attributes
The File object can be passed to the stream constructor as a parameter.
1. constructor and Separator
Public static void FileDemo () {// constructor demo // You can encapsulate an existing or nonexistent File or direc
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.