File class
Javaio access to file names and files detection related actions
The delimiter is best used with the file.separator provided by the file class to make the program more robust.
The method provided by the file class is basically known as a name, such as GetName () is the Get file name, Isfile () is not a document.
Public classFiletest { Public Static voidMain (string[] args)throwsIOException {System.out.println (file.separator+ " " +file.pathseparator); String FileName= "E:" + file.separator + "FileTest.txt"; File F1=NewFile (fileName); F1.createnewfile (); System.out.println (F1.getname ()); System.out.println (F1.getpath ()); System.out.println (F1.exists ()); System.out.println (F1.canread ()+ "" + f1.canexecute () + "+" +f1.canwrite ()); System.out.println (F1.isfile ()+ "" + f1.isdirectory () + "+" +F1.ishidden ()); System.out.println (f1.lastmodified ()+ "");//returns the last modified timeSystem.out.println (F1.length ());//returns the length of the file contentsF1.delete (); System.out.println (F1.exists ()); }}
The content in the "demo results" file is Javaio
\ ;
FileTest.txt
E:\fileTest.txt
True
True True True
True False False14274570315046false
2. Related methods of directory operation
MkDir () tries to create a directory corresponding to the file object, returns False,list () to list all sub-filenames and pathname, and returns string[] if the creation returns true successfully
Listfiles () lists the file corresponding sub-file name and path name, and returns file[]
UblicclassTraversefile { Public Static voidMain (string[] args) {String fileName= "F:" +file.separator+ "Test"; File F=NewFile (fileName); Printfile (f); //F.mkdir (); } Public Static voidPrintfile (File f) {if(F.exists () &&f.isdirectory ()) {file[] ff=F.listfiles (); if(FF! =NULL) { for(File fff:ff) {printfile (FFF); } } if(F! =NULL) System.out.println (F.getpath ()); } }}
Javaio Flow
Input stream: Data can only be read from and not written to.
Output stream: Data can only be written, not read.
The input and output here is in the memory of the Java program.
Byte stream and character stream: the usage of the byte stream and the character stream is the same, the difference is that the byte stream and the character stream operate the different data units--byte stream operation is 8 bits of bytes, character stream
The operation is a 16-bit character. Byte stream mainly consists of InputStream and OutputStream as base class, while character stream is mainly composed of reader and writer as base class.
node stream and process flow: a node stream to read and write data from a specific data source. A node stream is a low-level stream. The processing stream is used to wrap the node stream and process the stream as an advanced stream.
The function of processing flow is mainly reflected in:
1. Increase the efficiency of IO by increasing the buffering mode. 2. Processing flow can easily input/output large batches of data at a time.
Usually if the input/output is text content using a character stream, the input/output is binary content using a byte stream.
Javaio Re-review