反序列化,将byte数组转为Object

版权声明:本文为博主原创文章,未经博主允许不得转载,如果你非要转载,那能怎么办呢? https://blog.csdn.net/ghjzzhg/article/details/80612429
         /**
	 * 将byte[] -->Object
	 * @param bytes
	 * @return
	 */
	private static Object unserialize(byte[] bytes) {
		ByteArrayInputStream bais = null;
		try {
			// 反序列化
			bais = new ByteArrayInputStream(bytes);
			ObjectInputStream ois = new ObjectInputStream(bais);
			return ois.readObject();
		} catch (Exception e) {
			logger.error("{}", e);
		} finally {
			try {
				bais.close();
			} catch (IOException e) {
				logger.error("{}", e);
			}
		}
		return null;
	}

猜你喜欢

转载自blog.csdn.net/ghjzzhg/article/details/80612429