在JAVA(Eclipse)中序列化文件时如何将编码设置为UTF8

时间:2019-07-07 23:16:10

标签: java file serialization encoding binary

我试图通过序列化(例如“ object.out”)写入Java文件,但是无法正常读取。相反,它向我展示了这样的东西

我尝试将首选项编码设置为UTF-8

case some_var do
%MyStruct{} = struct_var ->
 # we are saying we expect this var to be of the `MyStruct` variety.
other_case ->
  do_something_else()
end

screenshot or Eclipse

1 个答案:

答案 0 :(得分:3)

ObjectOutputStream不适合人类食用。用ObjectOutputStream编写的数据唯一要做的就是用ObjectInputStream读回。 Java中还有许多其他技术可以编写数据供人类读取或与其他系统交换。对象流格式已经使用Unicode作为其表示的一部分,您无需对其进行配置。