我正在尝试从服务器获取HttpPost结果,并将其转换为字节数组,并从byte[]获取特定字节。现在,我正在使用此代码,并且可以正常工作。我需要将其更改为我想做的。这是代码: 通用标签

由于此HttpPost,我得到了一个字符串,我需要像我一样将其转换为字节并从中获取特定的字节。像从15元素开始到25或类似的东西。有什么建议我该怎么做?

提前感谢所有建议和帮助。

有帮助吗?

其他提示

改为使用EntityUtils.toByteArray()方法: 通用标签

要获取数组的前5位,请使用 Arrays.copyOf() 方法: 通用标签

Use

execute(HttpUriRequest request, ResponseHandler<? extends T> responseHandler)

instead of

execute(HttpUriRequest request)

with custom responseHandler. This way you can handle input stream directly and do anything you want with it. Using EntityUtils is GC ineficient I suppose. If you care about this kind of stuff.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top