JAVA性價比最高的文件處理方法

拷貝文件

				Files.copy(Paths.get(fromFile.getPath()),Paths.get(toFile.getPath()), LinkOption.NOFOLLOW_LINKS);

移動文件

				boolean isRename = fromFile.renameTo(toFile);
				if(!isRename){
					throw new Exception("文件移動失敗!\n");
				}

刪除文件

				boolean isDelete = toFile.delete();
				if (!isDelete) {
					throw new Exception("文件刪除失敗!");
				}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章