fileSystem.delete里邊主要有兩個參數一個Path,這個是要刪除的路徑Path f,一個是是否遞歸(recursive)
Path f, boolean recursive
/** Delete a file.
*
* @param f the path to delete.
* @param recursive if path is a directory and set to
* true, the directory is deleted else throws an exception. In
* case of a file the recursive can be set to either true or false.
* @return true if delete is successful else false.
* @throws IOException
*/
源碼里是這樣寫的 ,我的理解是
如果要刪除的路徑是一個文件,參數recursive 是true還是false都行
如果要刪除的路徑是一個目錄,參數recursive 開啟true就是遞歸刪除,如果填false,而下級目錄還有文件,就會報錯
關於遞歸或者遞歸刪除可以自行百度。