如何清除protobuf的缓冲区?

发布于 2024-09-16 13:29:41 字数 44 浏览 3 评论 0原文

清除到目前为止写入的所有字节,有没有办法用 protobuf 做到这一点?

Clear all bytes writen so far, is there a way to do this with protobuf?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

软的没边 2024-09-23 13:29:42

当你说清楚时,你是否要求撤消已经写入的字节?

如果您使用 FileOutputStream 或 OstreamOutputStream,那么您编写的内容可能无法清除,因为它已经保存到磁盘或流式传输到某个地方。如果您使用的是 ArrayOutputStream(如果您要将其写入套接字,则可能会这样),那么您可以通过重新创建 ArrayOutputStream 并将其再次指向同一缓冲区来撤消。

如果您向我们展示您当前使用的代码将会有所帮助,以便我们可以更好地为您提供建议。

When you say clear, are you asking to undo the bytes you have already written?

If you are using the FileOutputStream or OstreamOutputStream, then what you have written might not be clear-able, as it has already been saved to disk or streamed somewhere. If you are using an ArrayOutputStream (which you might be if you are going to be writing it to a socket), then you can undo by just recreating your ArrayOutputStream and pointing it at the same buffer again.

It would help if you showed us the code you are currently using, so we can better advise you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文