Object与byte[]互转
User user=new User();
user.setId("bonnie");
user.setAge("10");
//Object转byte[]
ByteArrayOutputStream byteArrayOutputStream =new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream=new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(user);
byte[] bytes=byteArrayOutputStream.toByteArray(); //byte[]转Object
ByteArrayInputStream byteArrayInputStream=new ByteArrayInputStream(bytes);
ObjectInputStream objectInputStream=new ObjectInputStream(byteArrayInputStream);
User user1=(User)objectInputStream.readObject();
System.out.println(user1);
Object与byte[]互转的更多相关文章
- object与byte[]的相互转换、文件与byte数组相互转换
转载自 https://blog.csdn.net/scimence/article/details/52233656 object与byte[]互转 /// <summary> // ...
- 对像转成 和 byte 互转类库方法
using System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serializatio ...
- 字符串string和内存流MemoryStream及比特数组byte[]互转
原文:字符串string和内存流MemoryStream及比特数组byte[]互转 字符串string和内存流MemoryStream及比特数组byte[]互转比较 定义string变量为str, ...
- 【C#】Switch datatype between object and byte[]
This sample shows how to turn object to byte[], as well as turn byte[] to object. So,I can turn any ...
- Go语言网络通信---string与int互转,int64与[]byte互转,int直接互转,string与[]byte互转
string与int互转 #string到int int,err:=strconv.Atoi(string) #string到int64 int64, err := strconv.ParseInt( ...
- file与 byte[] 互转
byte 转file String filepath="D:\\"+getName(); File file=new File(filepath); ...
- C# String 与 byte 互转
String转换为byte数组用byte[] arr = System.Text.Encoding.Default.GetBytes("abcde") byte数组转换为Strin ...
- String Byte 互转
string类型转成byte[]: byte[] byteArray = System.Text.Encoding.Default.GetBytes ( str ); byte[]转成string: ...
- golang struct 和 byte互转
相比于encoding, 使用unsafe性能更高 type MyStruct struct { A int B int } var sizeOfMyStruct = int(unsafe.Sizeo ...
随机推荐
- 基于 H5 Canvas 实现楼宇新风系统
前言 现如今,新型冠状病毒疫情牵动着每一个人的神经,每天起床后的第一件事就是打开疫情地图,看看最新的疫情数据. (http://www.hightopo.com/demo/coronavirus/) ...
- Java 添加、读取、删除Excel图片
本文介绍在Java程序中如何添加图片到excel表格,添加图片时可设置图片大小.位置.旋转.超链接.可选文本等,以及如何读取.删除excel表格中已有的图片. 工具:Free Spire.XLS fo ...
- WinBox软路由的自定义IP设定
软路由ros(MIKRTIK)安装简单步骤 由于本主也是刚刚接触软路由这个硬件方面的知识.所以也是略知皮毛而已,今天通过网上的学习,然后自己总结了一下怎么在软路由中设定一个自定义IP ...
- Mysql无法启动、闪退
一.mysql下载完成后,运行bin目录下的mysql.exe,提示文件缺失 二.此报错为VC运行库不全或没有安装导致,百度搜索“微软常用运行库合集”进行下载安装即可解决 三.运行时闪退,无法 ...
- codewars--js--Find The Parity Outlier
问题描述:(找出奇数数组中唯一的偶数,或是偶数数组中唯一的奇数) You are given an array (which will have a length of at least 3, but ...
- StackExchange.Redis 之 Set集合 类型示例
话不多说直接上代码: // set添加单个元素 stopwatch.Start(); "); stopwatch.Stop(); Console.WriteLine("set添加单 ...
- Linux下使用Nginx
模拟tomcat集群 1.下载tomcat7,/usr/local下新建目录tomcat,将tomcat7剪切到/usr/local/tomcat wget http://mirror.bit.edu ...
- 关系模式范式分解教程 3NF与BCNF口诀
https://blog.csdn.net/sumaliqinghua/article/details/86246762 [通俗易懂]关系模式范式分解教程 3NF与BCNF口诀!小白也能看懂原创置顶 ...
- 《自拍教程21》mediainfo_多媒体文件查看工具
mediainfo命令介绍 mediainfo.exe(Linux/iMac下是未带后缀的mediainfo), 是一款音视频图片文件的信息查询工具, 常用于查看多媒体文件的视频流信息,音频流信息,字 ...
- npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
Mac 权限不够 前面加sudo 然后输入密码