Saturday, December 29, 2007

to delete a file

public static void deleteFile(String completePathFile) throws IOException {
        try {
            File filetoDelete = new File(completePathFile);
            if (filetoDelete.exists()) {
                if (!filetoDelete.delete())
                    throw new IOException(
                            "ERROR FILE NOT DELETED !! pathFile : "
                                    + filetoDelete.getAbsolutePath());
            }
        } catch (IOException ex) {
            throw new IOException("Error in deleting file");
        }
    }

No comments: