一次熬夜解决的java乱码问题
2015-10-11 03:54
585 查看
在java API中String有一个方法
public byte[] getBytes()
Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.
The behavior of this method when this string cannot be encoded in the default charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required.
对这个字符串进行编码为一个字节序列使用平台的默认字符集,结果存储到一个新的字节数组
Returns:
The resultant byte array
整个晚上和客户一直抓包,发现有个字符串的长度不一样,在调用接口的时候,不匹配
解决方案
慎用该方法
http://www.blogjava.net/baizhihui19870626/articles/388054.html
public byte[] getBytes()
Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.
The behavior of this method when this string cannot be encoded in the default charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required.
对这个字符串进行编码为一个字节序列使用平台的默认字符集,结果存储到一个新的字节数组
Returns:
The resultant byte array
整个晚上和客户一直抓包,发现有个字符串的长度不一样,在调用接口的时候,不匹配
解决方案
慎用该方法
http://www.blogjava.net/baizhihui19870626/articles/388054.html
相关文章推荐
- java传入相关的时间可以获取这个时间段的星期时间
- 记惠普javaweb实训周之版本控制系统的实践
- 深入探讨Java的类加载机制
- Eclipse desktop
- Spring AOP 实现机制
- java的Class类及getClass()函数
- Java对象创建过程
- 将java程序作为Windows服务
- Maven和Eclipse集成和构建多模块Maven项目
- Sun jdk, Openjdk, Icedtea jdk关系
- 学生选课系统-教师功能模块设计(Java+NetBeans+SQLServer2008)
- 5个Java9新特性你知道了吗?
- Struts的配置文件加载顺序
- mvn 调试java工程
- Eclipse替代ndk-gdb断点调试Android NDK程序
- java枚举之简要
- java之反射构造方法
- java反射之成员变量的反射
- java 线程学习笔记(二)
- eclipse、android studio快速输入System.out.println();