import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.zip.InflaterInputStream;

public class PAKReader {

    public static void main(String[] args) {
        String pakFilefolderPath = "/storage/emulated/0/Android/data/com.tencent.tmgp.pubgmhd/files/UE4Game/ShadowTrackerExtra/ShadowTrackerExtra/Saved/Paks";
      
        try {
            Path pakPath = Path.of(pakFilePath);
            FileChannel fileChannel = (FileChannel) Files.newByteChannel(pakPath, StandardOpenOption.READ);
            
            ByteBuffer headerBuffer = ByteBuffer.allocate(32);
            fileChannel.read(headerBuffer);
            headerBuffer.order(ByteOrder.LITTLE_ENDIAN);
            
            int pakSize = headerBuffer.getInt(12);
            int entriesOffset = headerBuffer.getInt(16);
            
            int entryCount = (pakSize - entriesOffset) / 104;
            ByteBuffer entriesBuffer = ByteBuffer.allocate(entryCount * 104);
            fileChannel.position(entriesOffset);
            fileChannel.read(entriesBuffer);
            entriesBuffer.order(ByteOrder.LITTLE_ENDIAN);
           
            for (int i = 0; i < entryCount; i++) {
                String fileName = new String(entriesBuffer.array(), i * 104, 100).trim();
                int fileOffset = entriesBuffer.getInt(i * 104 + 100);
                int fileSize = entriesBuffer.getInt(i * 104 + 108);
                
                ByteBuffer fileBuffer = ByteBuffer.allocate(fileSize);
                fileChannel.position(fileOffset);
                fileChannel.read(fileBuffer);
               
            }
            
            fileChannel.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}