class FileSystem {

	public static void delete(File file) throws IOException {
		if (file != null) {
			final LinkedList<File> candidates = new LinkedList<>();
			candidates.add(file);
			File fl;
			File[] children;
			while (!candidates.isEmpty()) {
				fl = candidates.getFirst();
				if (fl.isDirectory()) {
					children = fl.listFiles();
					if (children != null && children.length > 0) {
						// Non empty directory
						for (final File c : children) {
							candidates.push(c);
						}
					} else {
						// empty directory
						candidates.removeFirst();
						fl.delete();
					}
				} else {
					// not a directory
					candidates.removeFirst();
					fl.delete();
				}
			}
		}
	}

	private  FileSystem();

}