【发布时间】:2011-02-24 15:13:34
【问题描述】:
我正在用 Java 解析具有以下规范的字节数组:
Trace data format:
- 4 bytes containing the Id.
- 4 bytes containing the address.
- N bytes containing the first name, where 0 < N < 32
- N bytes containing the last name, where 0 < N < 32
- 4 bytes containing the Minimum
- 4 bytes containing the Maximum
- 4 bytes containing the Resource Default Level
今天我没有看到任何解决方案来解析这个数组以获得 7 个具有正确类型的变量。你确认还是我错过了Java中允许在字节数组中找到字符串“限制”的东西(我看不出最小值如何与其关联的ASCII字符区分开来)。
关于两个字符串之间的特殊字符是否有任何“约定”?
【问题讨论】:
-
读完全名怎么知道?
-
它们可以是空终止的字符串吗?
-
您能为您的问题提供一个更好的标题吗?当前的一个可以应用于大多数关于 SO 的问题。
-
请将标题更改为“Parsing string or array in java”或类似内容。
-
Null 终止的字符串是以 '\0' 字符结尾的字符串。它们是 C/C++ 系统中常见的标准字符串格式。