-3

I want to erase all pdf files that do not contain text. I tried to use a PdfBox. Method pdftoText converts pdf to String.

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");
                }
            }


        }


}

This did not bring any results

Donotello
  • 157
  • 2
  • 2
  • 14

1 Answers1

1

String objects can not be compared using == in Java.

Please us the String.equals() method.

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

if(s1.equals(s2))
    //dostuff
else
    //dootherstuff
Matt Clark
  • 27,671
  • 19
  • 68
  • 123