Here you can find the source of deleteFile(File file)
public static int deleteFile(File file)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static int deleteFile(File file) { if (file == null) { return -1; }//from ww w .java 2s .c o m if (file.exists()) { if (file.isFile()) { if (file.delete()) { return 0; } } if (file.isDirectory()) { File[] subFiles = file.listFiles(); if (subFiles != null) { for (File subFile : subFiles) { deleteFile(subFile); } } if (file.delete()) { return 0; } } return -1; } else { return -1; } } }