String类型怎么转变成byte数组?

highest6 2003-10-20 03:54:28
谢谢
...全文
155 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
highest6 2003-10-20
  • 打赏
  • 举报
回复
艾,我们项目组用的是JDK1.3,换成JDK1。4getBytes()方法就出来了,;(
fft123 2003-10-20
  • 打赏
  • 举报
回复
getBytes()
Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.

getBytes(String charsetName)
Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array.

楼主这种问题最好去查一下jdk的帮助
看一下相关类的方法就是了
whyxx 2003-10-20
  • 打赏
  • 举报
回复
s.getBytes();
caoxmby 2003-10-20
  • 打赏
  • 举报
回复
String s="hello";
byte[] data1=s.getBytes();
byte[] data2=s.getBytes("GBK");

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧