Skip to content

Commit b15325e

Browse files
committed
BAEL-9267: Determine If a File is a PDF File in Java
1 parent 4d3b9d3 commit b15325e

File tree

1 file changed

+1
-1
lines changed
  • text-processing-libraries-modules/pdf-2/src/test/java/com/baeldung/detect

1 file changed

+1
-1
lines changed

text-processing-libraries-modules/pdf-2/src/test/java/com/baeldung/detect/PdfDetectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void whenDetectPdfByFileSignature_thenCorrect() throws IOException {
4949
boolean isPdf = false;
5050
try (InputStream fis = new BufferedInputStream(new FileInputStream(PDF_FILE))) {
5151
byte[] bytes = new byte[5];
52-
if (fis.read(bytes) >= 5) {
52+
if (fis.read(bytes) == 5) {
5353
String header = new String(bytes);
5454
isPdf = Objects.equals(header, "%PDF-");
5555
}

0 commit comments

Comments
 (0)