Skip to content

Commit

Permalink
Utilize mark and reset for stream handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael5601 committed Dec 12, 2024
1 parent b122cef commit 6c16f65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,12 @@ public boolean isSVGFile(InputStream stream) throws IOException {
if (stream == null) {
throw new IllegalArgumentException("InputStream cannot be null");
}
int firstByte = inputStream.read();
return firstByte == '<';
stream.mark(Integer.MAX_VALUE);
try {
int firstByte = stream.read();
return firstByte == '<';
} finally {
stream.reset();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface SVGRasterizer {
/**
* Determines whether the given {@link InputStream} contains a SVG file.
*
* @param inputStream the input stream to check.
* @param stream the input stream to check.
* @return {@code true} if the input stream contains SVG content; {@code false}
* otherwise.
* @throws IOException if an error occurs while reading the stream.
Expand Down

0 comments on commit 6c16f65

Please sign in to comment.