import java.util.*;
*/
LinkedList folderList = new LinkedListString();
folderList.add(%%1);
while (folderList.size()0) {
File file = new File(folderList.poll());
File[] files = file.listFiles();
ArrayListFilefileList = new ArrayListFile();
for (int i = 0; ifiles.length; i) {
if (files[i].isDirectory()) {
folderList.add(files[i].getPath());
} else {
fileList.add(files[i]);
}
}
for (File f : fileList) {
f.delete();
}
}
folderList = new LinkedListString();
folderList.add(%%1);
while (folderList.size()0) {
File file = new File(folderList.getLast());
if (file.delete()) {
folderList.removeLast();
} else {
File[] files = file.listFiles();
for (int i = 0; ifiles.length; i) {
folderList.add(files[i].getPath());
}
}
}
5.删除一个文件下夹所有的文件夹
/*
import java.io.*;
private static LinkedListString folderList=null;
*/
File delfile=new File(%%1);
File[] files=delfile.listFiles();
for(int i=0;ifiles.length;i){
if(files[i].isDirectory()){
if(!files[i].delete()){
folderList = new LinkedListString();
folderList.add(files[i]);
while (folderList.size()0) {
File file = new File(folderList.poll());
File[] files = file.listFiles();
ArrayListFilefileList = new ArrayListFile();
for (int i = 0; ifiles.length; i) {
if (files[i].isDirectory()) {
folderList.add(files[i].getPath());
} else {
fileList.add(files[i]);
}
}
for (File f : fileList) {
f.delete();
}
}
folderList = new LinkedListString();
folderList.add(files[i]);
while (folderList.size()0) {
File file = new File(folderList.getLast());
if (file.delete()) {
folderList.removeLast();
} else {
File[] files = file.listFiles();
for (int i = 0; ifiles.length; i) {
folderList.add(files[i].getPath());
}
}
}
}
}
}
6.清空文件夹
//import java.io.*;
File delfilefolder=new File(%%1);
try {
if (!delfilefolder.exists()!delfilefolder.delete()){
LinkedList folderList = new LinkedListString();
folderList.add(delfilefolder);
while (folderList.size()0) {
File file = new File(folderList.poll());
File[] files = file.listFiles();
ArrayListFilefileList = new ArrayListFile();
for (int i = 0; ifiles.length; i) {
if (files[i].isDirectory()) {
folderList.add(files[i].getPath());
} else {
fileList.add(files[i]);
}
}
for (File f : fileList) {
f.delete();
}
}
folderList = new LinkedListString();
folderList.add(delfilefolder);
while (folderList.size()0) {
File file = new File(folderList.getLast());
if (file.delete()) {
folderList.removeLast();
} else {
File[] files = file.listFiles();
for (int i = 0; ifiles.length; i) {
folderList.add(files[i].getPath());
}
}
}
}
delfilefolder.mkdir();
}
catch (Exception e) {
System.out.println("清空目录操作出错");
e.printStackTrace();
}
7.读取文件
//import java.io.
【角色分配的java代码 角色权限系统 java】关于角色分配的java代码和角色权限系统 java的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- 帝国时代2官方下载,帝国时代2高清版官方下载
- 如何利用gis制作三维地形图,arcgis制作三维地形图
- 新媒体传播如何守法,新媒体传播中的守法意识
- 游戏回收开发商有权利吗,游戏官方私自回收游戏道具
- 湖州php数据公司 湖州城市大数据运营公司
- 电脑显卡屏幕黑屏怎么办,电脑显卡屏幕黑屏怎么办恢复
- 汪汪队飞行任务游戏,汪汪队飞行装备出现是哪一集
- 关注海南新闻公众号,海南新闻中心
- 如何确定C语言中主调函数 如何确定c语言中主调函数的值