Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
目前我有字节数组。其中包含一个.jpg文件以及一些其他不需要的数据。
我想做的是找出数据“FF D8”(JPEG数据的开始)的位置。
iOS中的相同代码是:https ://stackoverflow.com/a/18477915/5215474
这在 Java 中实现起来很简单。
int position = -1; for (int i = 0; i < bytes.length - 2; i++) { if (bytes[i] == (byte) 0xff && bytes[i + 1] == (byte) 0xdf) { position = i; break; } }