I am developing a Java application that reads and writes byte arrays (of seemingly random bytes) in a file.

I would like to know what method I can use to separate these byte arrays, because if I encode them in UTF-8, I might run into a newline character by accident right?

So then the bufferedReader.nextLine() might think it's the end of a byte[]?

Downvoter, care to explain?

有帮助吗?

解决方案

If you're writing and reading bytes you probably just want to use a DataOutputStream and DataInputStream

The way you separate the different byte arrays is by knowing the number of bytes and the order they appear in the file.

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