[Java] "Java Programming Basic Course" seven and eight learning

Chapter VII Exception Handling

To capture one or more exceptions by try ... catch ... finally structure

Chapter VIII Java input and output and file operations

8.1 File

File type commonly used method

1. public boolean canRead () to test whether the file can be continued

Whether 2. public boolean canWrite () test the file can be modified

3. oublic boolean exists () Tests if this file or directory exists

4. public boolean isDirectory () to test whether a directory

Whether 5. public boolean isFile () test as a standard file

6. public boolean isHidden () to test whether a hidden file

7. public long lastModified () Returns the last modified time

Length 8. public long lenth () returns the file

Name 9.public String getName () returns the file or directory

10. public String getParent () Returns the parent directory

11. public String getPath () returns the relative path

12. public String getAbsolutePath () returns the absolute pathname

13. public boolean CreateNewFile () new empty file throws IOException if and only if the specified name does not exist, create a file specified by name

14. public boolean dalete () to delete a file or directory

15. public boolean mkdir () Creates the specified directory

16. public boolean mkdirs () to create a directory developed, including the creation of parent directories necessary but non-existent

17. public String [] list () Returns all files and directories in the current directory

Meet filter all files and directories 18. public String [] list (FilenameFileter filter) Returns the current directory

8.2 Input / Output (I / O) Flow

InputStream the basic method are:

1. int read () to read a byte from the stream

2. int read (byte [] buffter) a sequence of bytes is read and stored in an array in buffer 

3. int read (byte b [], int offset, int length) Reads length bytes, and returns the number of bytes actually read

4. long skip (long n) n bytes to skip stream

5. int available () returns the number of bytes available in the stream 

6. void mark () marks a location in the stream

7. void reset () the position of the index mark position

8. void close () Closes the input stream

Guess you like

Origin www.cnblogs.com/daijux/p/12080719.html