Java 读取 doc docx pdf rtf txt html 文件文本内容
配置SVN服务器开机自启动

java 删除文件夹

Jimmy posted @ 2012年3月13日 18:27 in Java Programming , 1778 阅读

用Java的File类删除文件夹时发现,如果文件夹下有其他文件则此文件夹无法删除,需要递归的删除。

	public void deleteFile(File fileDir)
	{	
		if(fileDir.exists())
		{
			if(fileDir.isFile())
			{
				fileDir.delete();
			}
			else if(fileDir.isDirectory())
			{
				for(File file : fileDir.listFiles())
				{
					this.deleteFile(file);
				}
				fileDir.delete();
			}
		}
		else
		{
			System.err.println("directory does not exist!");
		}
	}
Avatar_small
hotmail email login 说:
2020年8月30日 19:56

Even when you are quite good at using internet or email, you may have problems with it. Some problems are quite common and you can solve it (forgot password, forgot username...) but sometimes, proxy problems... you may cannot sign in your email. If you cannot solve it yourself, hotmail email login will be a helpful choice.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter