国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

數(shù)據(jù)流的代碼

2020-04-03 22:14 作者:小垃圾kiki  | 我要投稿
package cn.jd.io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
/*
?* 數(shù)據(jù)流:
?* 1先寫出后讀取
?* 2讀取的順序和寫出保持一致
?*/
public class DataTest {
?? ?public static void main(String[] args) throws IOException {
?? ??? ?//字節(jié)數(shù)組流
?? ??? ?ByteArrayOutputStream? baos=new ByteArrayOutputStream();
?? ??? ? //先寫出再讀取,因?yàn)槟悴粚懩阕x什么內(nèi)容,所以你先寫一個(gè)內(nèi)容讓人家讀
?? ??? ?DataOutputStream dos=new DataOutputStream(new BufferedOutputStream(baos));
?? ??? ?//接下來就是怎么寫入到字節(jié)數(shù)組里面了??? 操作數(shù)據(jù)類型+數(shù)據(jù)
?? ??? ?dos.writeUTF("我太難了");
?? ??? ?dos.writeInt(18);
?? ??? ?dos.writeBoolean(false);
?? ??? ?dos.flush();
?? ??? ?byte[]? datas=baos.toByteArray();?? //將字節(jié)流轉(zhuǎn)為字節(jié)數(shù)組
?? ??? ?
?? ??? ?//讀取
?? ??? ?DataInputStream dis=new DataInputStream(new BufferedInputStream(new ByteArrayInputStream(datas)));
?? ??? ?//接下來就是從程序里面讀取內(nèi)容,順序要和寫出的一致
?? ??? ? String msg=dis.readUTF();
?? ??? ? int age=dis.readInt();
?? ??? ? boolean flag=dis.readBoolean();
?? ??? ? System.out.println(msg);
?? ??? ?
?? ?}
}

數(shù)據(jù)流的代碼的評論 (共 條)

分享到微博請遵守國家法律
海城市| 梧州市| 远安县| 常州市| 和龙市| 邵阳市| 西吉县| 普定县| 美姑县| 清远市| 麻江县| 湖南省| 宣化县| 金湖县| 黄大仙区| 安仁县| 普定县| 英吉沙县| 普宁市| 黔江区| 北票市| 连城县| 都安| 亳州市| 奇台县| 柘荣县| 琼中| 乳山市| 安远县| 西和县| 新邵县| 华蓥市| 朔州市| 乌鲁木齐市| 孝感市| 宁国市| 射洪县| 前郭尔| 黄骅市| 嵊泗县| 南乐县|