//建立一個檔案夾
public void newFolder(String folderPath) {
try {
String filePath = folderPath;
File myFilePath = new File(filePath);
if (!myFilePath.exists()) {
myFilePath.mkdir();
}
} catch (Exception e) {
System.out.println("建立檔案夾操作出錯");
e.printStackTrace();
}
}
//刪除檔案夾
public void delFolder(String folderPath){
try{
String filePath = folderPath;
File delPath = new File(filePath);
delPath.delete();
}catch (Exception e) {
System.out.println("刪除檔案夾操作出錯");
e.printStackTrace();
}
}
//建立檔案
public void createFile(String fileName){
try{
String myFileName = fileName;
if (!myFileName.exists()) {
myFileName.createNewFile();
}
}catch (Exception e) {
System.out.println("建立檔案操作出錯");
e.printStackTrace();
}
}
//刪除檔案
public void delFile(String fileName){
try{
String myFileName = fileName;
myFileName.delete();
}catch (Exception e) {
System.out.println("刪除檔案操作出錯");
e.printStackTrace();
}
}