In 1.java, I/O is implemented using classes and interfaces in the Java.io package. File is one of the most commonly used classes in the Java.io package, which represents a file name (or directory name). Although the file class provides methods to work with directories and files within the corresponding directory, there is no way to work with the file contents. That is, it does not provide any way to read or write the bytes or characters contained in the file.
In 2.java, sequential file I/O is done through flow abstraction (random Access file I/O is done with the Randomaccessfile class, but sequential I/O is more common).
3. Assign a value to the args parameter of the main () function in eclipse:
Select Project Main class right-click the run configuration in run as
Select the 2nd tab (x) =arguments
Enter the parameters in program arguments, click Apply, and then click Run
For example my command exercise is:. +java
If you have multiple parameters, you can separate multiple parameters with a space.
Example 1: A short program that implements deleting a file or directory specified on the command line
4.FileInputStream reads the bytes of the source file and uses FileOutputStream to copy the bytes to the destination file.
Example 2 The Finally statement in the program ensures that the stream is properly closed before the program exits.
The stream reads and writes to the console: reading a line of text using BufferedReader, BufferedReader reads a single character from a InputStreamReader, and InputStreamReader from System.in ( This is a inputstream) read bytes, system.in will read the keystrokes on the user's keyboard. In addition, the program uses System.out and system.err to display text output, System.out and System.err are instances of PrintStream.
Example 2:
Java Step1: Basic knowledge 3