We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Delete Blank/Empty Documents using JAVA

Hi team,

Requesting a work around solution to delete blank/empty word document using JAVA.

Regards
Priya Dharshini J P

@priyadharshini

Thanks for your inquiry. Please use following code example to delete empty document from the disk. Hope this helps you.

Document doc = new Document(MyDir + "input.docx");
if(doc.toString(SaveFormat.TEXT).trim().length() == 0)
{
    File file = new File(MyDir + "input.docx");

    if(file.delete()){
        System.out.println(file.getName() + " is deleted!");
    }else{
        System.out.println("Delete operation is failed.");
    }
}

Thanking You @tahir.manzoor

Regards
Priya Dharshini J P