删除mac电脑隐藏文件的小程序

package com.sam;

import java.io.File;

public class Main {

	//public static final String PREFIX = "._"; 
	public static final String PREFIX = ".DS_Store";
	
	public static void main(String[] args) 
	{
		String dirPath = "E:\\androidworkspace\\aaaa";
		
		File mainDir = new File(dirPath);
		deleteFileInDir(mainDir);
		
		
	}
	
	public static void deleteFileInDir(File dir)
	{
		File files[] = dir.listFiles();
		if(files != null)
		{
			for(File file : files)
			{
				if(file.isDirectory())
				{
					deleteFileInDir(file);
				}else {
					System.out.println(file.getAbsolutePath());
					if(file.getName().startsWith(PREFIX))
					{
						System.out.println("should delete");
						file.delete();
					}
				}
			}
		}
		
	}

}

你可能感兴趣的:(java)