-1

我有一个包含多个字符串的字节数组。我正在用长度更大的新字符串替换其中一个字符串。现在我怎么能在我关心的字符串之后通过长度的不同来移动这些东西。

4

1 回答 1

0

I assume what you mean is that you have a byte array where you have encoding multiple strings into. You want to replace one of these strings with a longer string. Unless you have space at the end of the byte[] for such a situation, you will need to create a new byte[]. Copy everything up to the point you want to keep, the string you want to update and then everything after it.

You can use System.arraycopy() to copy to a new byte[] or move bytes around in a byte array.

于 2013-07-26T22:20:48.750 回答