Java 如果pdf文件不包含文本,如何删除该文件?

Java 如果pdf文件不包含文本,如何删除该文件?,java,erase,Java,Erase,我想删除所有不包含文本的pdf文件。我试着用PdfBox。 方法pdftoText将pdf转换为字符串 public static void main(String[] args) throws FileNotFoundException, InterruptedException { String pdfText = PDFTextParser.pdftoText("xxx.pdf");

我想删除所有不包含文本的pdf文件。我试着用PdfBox。 方法
pdftoText
将pdf转换为字符串

public static void main(String[] args) throws FileNotFoundException, InterruptedException {


            String pdfText = PDFTextParser.pdftoText("xxx.pdf");                                        //files[i]);
            if (pdfText == "") {
                File toBeDeletedFile = new File(location+"xxx.pdf");
                if (toBeDeletedFile.delete()) {
                    System.out.println("success");
                }
                else {
                    System.out.println("still there");
                }
            }


        }


}

这并没有带来任何结果

字符串
对象无法在Java中使用
=
进行比较

请使用
String.equals()
方法

String s1 = "dat1";
String s2 = "dat2";

if(s1.equals(s2))
    //dostuff
else
    //dootherstuff