Class FileSlice
java.lang.Object
nonapi.io.github.classgraph.fileslice.Slice
nonapi.io.github.classgraph.fileslice.FileSlice
- All Implemented Interfaces:
Closeable, AutoCloseable
-
Field Summary
FieldsFields inherited from class Slice
inflatedLengthHint, isDeflatedZipEntry, nestedJarHandler, parentSlice, sliceLength, sliceStartPos -
Constructor Summary
ConstructorsConstructorDescriptionFileSlice(File file, boolean isDeflatedZipEntry, long inflatedLengthHint, NestedJarHandler nestedJarHandler, LogNode log) Constructor for toplevel file slice.FileSlice(File file, NestedJarHandler nestedJarHandler, LogNode log) Constructor for toplevel file slice. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the slice.booleaninthashCode()byte[]load()Load the slice as a byte array.Read directly from FileChannel (slow path, but handles >2GB).read()Read the slice into aByteBuffer(or memory-map the slice to aMappedByteBuffer, ifClassGraph.enableMemoryMapping()was called.)slice(long offset, long length, boolean isDeflatedZipEntry, long inflatedLengthHint) Slice the file.Methods inherited from class Slice
loadAsString, open, open
-
Field Details
-
file
-
raf
TheRandomAccessFileopened on theFile.
-
-
Constructor Details
-
FileSlice
public FileSlice(File file, boolean isDeflatedZipEntry, long inflatedLengthHint, NestedJarHandler nestedJarHandler, LogNode log) throws IOException Constructor for toplevel file slice.- Parameters:
file- the fileisDeflatedZipEntry- true if this is a deflated zip entryinflatedLengthHint- the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated zip entry.nestedJarHandler- the nested jar handlerlog- the log- Throws:
IOException- if the file cannot be opened.
-
FileSlice
Constructor for toplevel file slice.- Parameters:
file- the filenestedJarHandler- the nested jar handlerlog- the log- Throws:
IOException- if the file cannot be opened.
-
-
Method Details
-
slice
Slice the file.- Specified by:
slicein classSlice- Parameters:
offset- the offset of the sub-slice within the parent slicelength- the length of the sub-sliceisDeflatedZipEntry- true if this is a deflated zip entryinflatedLengthHint- the uncompressed size of a deflated zip entry, or -1 if unknown, or 0 of this is not a deflated zip entry.- Returns:
- the slice
-
randomAccessReader
Read directly from FileChannel (slow path, but handles >2GB).- Specified by:
randomAccessReaderin classSlice- Returns:
- the random access reader
-
load
Load the slice as a byte array.- Specified by:
loadin classSlice- Returns:
- the byte[]
- Throws:
IOException- Signals that an I/O exception has occurred.
-
read
Read the slice into aByteBuffer(or memory-map the slice to aMappedByteBuffer, ifClassGraph.enableMemoryMapping()was called.)- Overrides:
readin classSlice- Returns:
- the byte buffer
- Throws:
IOException- Signals that an I/O exception has occurred.
-
equals
-
hashCode
-
close
public void close()Close the slice. Unmaps any backingMappedByteBuffer.
-