File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
plexus-java/src/main/java/org/codehaus/plexus/languages/java/version Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 11package org .codehaus .plexus .languages .java .version ;
22
33import java .io .IOException ;
4+ import java .io .InputStream ;
45import java .io .UncheckedIOException ;
56import java .nio .file .Files ;
67import java .nio .file .Path ;
@@ -62,9 +63,19 @@ public static JavaClassfileVersion of(byte[] bytes) {
6263 * @return the {@link JavaClassfileVersion} of the path java class
6364 */
6465 public static JavaClassfileVersion of (Path path ) {
65- try {
66- byte [] readAllBytes = Files .readAllBytes (path );
67- return of (readAllBytes );
66+ try (InputStream is = Files .newInputStream (path )) {
67+ byte [] bytes = new byte [8 ];
68+ int total = 0 ;
69+ while (total < 8 ) {
70+ int l = is .read (bytes , total , 8 - total );
71+ if (l > 0 ) {
72+ total += l ;
73+ }
74+ if (l == -1 ) {
75+ break ;
76+ }
77+ }
78+ return of (bytes );
6879 } catch (IOException ex ) {
6980 throw new UncheckedIOException (ex );
7081 }
You can’t perform that action at this time.
0 commit comments