java junior - rise

1, Java flow (Stream), file (File), IO

  Read console input: Java control input is done by System.in

  Multi-character read from the console char [] Input: string read by a read () method from BufferedReader objects,

  String read from the console string []: reading a string for an Bufferedreader readLine from the standard input () method

  Console output: print, println (), write ()

2、FileInputStream

  Read data from the file reads:

    Use string type of input file name to create a stream object to read the file

    File object can also be used to create a stream object to read an input file, an object file that is created using File () method

3、FileOutputStream

    Create a file and write data files

    If the output stream before opening the file, the target file does not exist, then the flow will create a file

4, mkdir () Create Folder

  mkdirs () to create a folder and all its parent folder

  Returns true isDirectiry () method

  list () and extract the files contained in the folder list

5, abnormal

  Code missing semicolon: java.lang.Error

  To do a divisor 0: java.lang.ArithmeticException

  Trying to store the wrong type to an object thrown when an array of anomalies: ArrayStoreException 

  When attempting to cast an object is not an instance of a subclass: ClassCastException

  Passed an illegal or incorrect parameter to the method: IIIegalArgumentException

  There are many reasons for abnormal, usually containing:

    Illegal user input data

    To open a file does not exist

    A communication network connection is interrupted, the memory overflow or JVM

  [Some of these anomalies caused by user error, caused some procedural errors, physical errors caused some]

6, master three types of abnormal

  Checked exception: user error or a problem caused by abnormal, compilation time can not be simply ignored

  Runtime exceptions: the programmer may be avoided, it can be ignored at compile time

  Error: not unusual, the problem is out of control of the programmer. Errors are usually ignored in the code. For example, stack overflow

7, Exception class hierarchy

  All exceptions are inherited from java.lang.Exception class subclass: IOException, RuntimeException

  Subclass Throwable class: Exception, Error

Guess you like

Origin www.cnblogs.com/sharry/p/12059529.html