reading c# binary files in java

后端 未结 3 1862
无人共我
无人共我 2021-01-07 03:05

I have a program in C# .net which writes 1 integer and 3 strings to a file, using BinaryWriter.Write().

Now I am programming in Java (for Android, and

3条回答
  •  春和景丽
    2021-01-07 03:48

    As its name implies, BinaryWriter writes in binary format. .Net binary format to be precise, and as java is not a .Net language, it has no way of reading it. You have to use an interoperable format.

    You can choose an existing format, like xml or json or any other interop format.

    Or you can create your own, providing your data is simple enough to make it this way (it seems to be the case here). Just write a string to your file (using a StreamWriter for instance), provided you know your string's format. Then read your file from java as a string and parse it.

提交回复
热议问题