package com.ruoyi.test; import java.io.*; import java.util.*; public class ShpDetail { public static void main(String[] args) throws Exception { String shpPath = "d:\\Web\\PlatformModel\\ruoyi-admin\\uploads\\models\\geojson\\d18ae556145b4615ba93d1c52210166c\\流域.shp"; File shpFile = new File(shpPath); FileInputStream fis = new FileInputStream(shpFile); fis.skip(100); byte[] recordHeader = new byte[8]; int recordNum = 0; int successCount = 0; int failCount = 0; while (fis.available() > 8) { if (fis.read(recordHeader) < 8) break; int contentLengthWords = readIntBE(recordHeader, 4); int contentLength = contentLengthWords * 2; recordNum++; byte[] recordContent = new byte[contentLength]; int bytesRead = fis.read(recordContent); if (bytesRead < contentLength) break; int recShapeType = recordContent[0] & 0xFF; if (recShapeType == 5 || recShapeType == 15) { int numParts = readIntLE(recordContent, 36); int numPoints = readIntLE(recordContent, 40); boolean success = numParts > 0 && numPoints > 0 && numParts < 1000 && numPoints < 100000; System.out.println("Record " + recordNum + ": ShapeType=" + recShapeType + ", numParts=" + numParts + ", numPoints=" + numPoints + ", contentLength=" + contentLength + " -> " + (success ? "OK" : "SKIP")); if (success) successCount++; else failCount++; } } fis.close(); System.out.println("\nTotal: " + recordNum + ", Success: " + successCount + ", Failed: " + failCount); } 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); } }