第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

用IDEA默認為utf-8,打印出來的文件老是亂碼,怎么處理 呢?

package?file;
import?java.io.File;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.ObjectOutputStream;

public?class?ObjectSeriaDemo?{
????public?static?void?main(String[]?args)?throws?IOException?{
????????String?file="F:/Code/Demo6.txt";
????????ObjectOutputStream?out=new?ObjectOutputStream(new?FileOutputStream(file));
????????Student?student=new?Student("01001","張三",20);
????????out.writeObject(student);
????????out.flush();
????????out.close();
????}
}


package?file;

import?java.io.Serializable;

public?class?Student?implements?Serializable?{
????private?String?stuno;
????private?String?stuname;
????private?int?stuage;

????public?Student(){

????}
????public?Student(String?stuno,String?stuname,int?stuage){
????????super();
????????this.stuno=stuno;
????????this.stuname=stuname;
????????this.stuage=stuage;

????}

????public?String?getStuno()?{
????????return?stuno;
????}

????public?void?setStuno(String?stuno)?{
????????this.stuno?=?stuno;
????}

????public?String?getStuname()?{
????????return?stuname;
????}

????public?void?setStuname(String?stuname)?{
????????this.stuname?=?stuname;
????}

????public?int?getStuage()?{
????????return?stuage;
????}

????public?void?setStuage(int?stuage)?{
????????this.stuage?=?stuage;
????}

????@Override
????public?String?toString()?{
????????return?"Student{"?+
????????????????"stuno='"?+?stuno?+?'\''?+
????????????????",?stuname='"?+?stuname?+?'\''?+
????????????????",?stuage="?+?stuage?+
????????????????'}';
????}
}


正在回答

2 回答

把項目編碼調成gbk試下

0 回復 有任何疑惑可以回復我~

序列化寫入文件里的是亂碼 但是你從文件讀出來的時候就不是亂碼了

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

用IDEA默認為utf-8,打印出來的文件老是亂碼,怎么處理 呢?

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號