package com.ruoyi.test; import java.io.*; public class ShpDebug { public static void main(String[] args) throws Exception { String shpPath = "d:\\Web\\PlatformModel\\ruoyi-admin\\uploads\\models\\geojson\\8aa64945328e428d97923165c8b8cf31\\流域.shp"; FileInputStream fis = new FileInputStream(shpPath); fis.skip(100); // Skip header byte[] recordHeader = new byte[8]; fis.read(recordHeader); int contentLengthWords = readIntBE(recordHeader, 4); int contentLength = contentLengthWords * 2; byte[] recordContent = new byte[contentLength]; fis.read(recordContent); System.out.println("Content Length: " + contentLength); System.out.println("First 64 bytes (hex):"); for (int i = 0; i < 64; i++) { System.out.printf("%02X ", recordContent[i]); if ((i + 1) % 16 == 0) System.out.println(); } System.out.println("\n\nReading at offset 24-27 (numParts):"); System.out.printf("Bytes: %02X %02X %02X %02X\n", recordContent[24], recordContent[25], recordContent[26], recordContent[27]); System.out.println("As LE int: " + readIntLE(recordContent, 24)); System.out.println("As BE int: " + readIntBE(recordContent, 24)); System.out.println("\nReading at offset 28-31 (numPoints):"); System.out.printf("Bytes: %02X %02X %02X %02X\n", recordContent[28], recordContent[29], recordContent[30], recordContent[31]); System.out.println("As LE int: " + readIntLE(recordContent, 28)); System.out.println("As BE int: " + readIntBE(recordContent, 28)); fis.close(); } static int readIntBE(byte[] data, int offset) { return ((data[offset] & 0xFF) << 24) | ((data[offset + 1] & 0xFF) << 16) | ((data[offset + 2] & 0xFF) << 8) | (data[offset + 3] & 0xFF); } static int readIntLE(byte[] data, int offset) { return (data[offset] & 0xFF) | ((data[offset + 1] & 0xFF) << 8) | ((data[offset + 2] & 0xFF) << 16) | ((data[offset + 3] & 0xFF) << 24); } }