Io Stream (Input Output):
The main function of IO technology is to solve the problem of data transmission between equipment and equipment. For example: Hard disk---> Memory memory----> data-------the keyboard on the hard drive > in memory
Application Scenarios for IO technology:
Export reports, upload photos, download, interpret XML files ...
Data is saved to the hard disk, and the data can be saved permanently. Data is typically saved to the hard disk as a file
Sun uses a file class to describe files or folders.
The file class can describe a document or a folder.
How to construct the file class:
File (String pathname) specifies the path to the files or folders to create a file.
File (file parent, string child) creates a new file instance based on the parent abstract pathname and the children pathname string.
File (string parent, String child)
Directory separator: The directory separator on the Windows machine is \, the directory separator on the Linux machine is/.
Note: both \ and/can be used as directory separators on Windows. And, if you write/you just need to write one.
Import Java.io.file;public class Demo01 {public static void Main (string[] args) { file parent =new file ("D:\\java ");//Build a File object file File=new file (parent," Java "); System.out.println (Is there a Java folder under the D:\\java path?) "+file.exists ()); File File02=new file ("d:\\", "Java");// System.out.println ("Is there a Java folder under the D disk?"). "+file02.exists ());} }
Output Result:
Are there any Java folders under the D:\Java path? True
Is there a Java folder under D disk? True
You can pass in the file object or string type as a path, generally choose File, you can call some methods of file to do preprocessing
Import Java.io.file;public class Demo02 {public static void Main (string[] args) { System.out.println (" System's File delimiter: "+file.separator"; File File=new file ("D:" +file.separator+ "Java"); System.out.println (File.exists ());} }
The File.separator method is: System-related default name separators
Output Result:
System's file delimiter: \
True
Introduction to Java's File class