一个简单问题,跟者有分

hu_zy 2003-10-17 07:24:58
关于JAVA的文档怎么找?
比如我的代码(这个代码是我随便写来举例的,只是为了说明问题,请不要在语法问题上争论):
HttpConnection conn;
InputStream in;
conn = Connector.open("http://localhost/cgi-bin/test.cgi");
......

String myString = new String(conn.getHeaderField("title").getBytes("gb2312"), "UNICODE");
.........
但是getBytes()抛出找不到gb2312编码的异常。
现在我需要看一下为什么会这样,希望看到String.getBytes()的说明,请问在哪里可以找到?


再次声明: 以上的代码是为了说明问题,而不是问题的所在。

跟者有分
...全文
122 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hu_zy 2003-10-20
  • 打赏
  • 举报
回复
不过在SUN的网站里通过搜索找到了,基类的说明文档只在J2SE的文档里出现,有点晕。
hu_zy 2003-10-20
  • 打赏
  • 举报
回复
to truezerg(赵明宇) :
那样没用的,没有任何参考价值,只有一个函数的伪代码放在那里,
如: getBytes(...) { return null;}
moke33 2003-10-19
  • 打赏
  • 举报
回复
getBytes
public void getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin)
Deprecated. This method does not properly convert characters into bytes. As of JDK 1.1, the preferred way to do this is via the the getBytes() method, which uses the platform's default charset.

Copies characters from this string into the destination byte array. Each byte receives the 8 low-order bits of the corresponding character. The eight high-order bits of each character are not copied and do not participate in the transfer in any way.
The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1. The total number of characters to be copied is srcEnd-srcBegin. The characters, converted to bytes, are copied into the subarray of dst starting at index dstBegin and ending at index:


dstbegin + (srcEnd-srcBegin) - 1


Parameters:
srcBegin - index of the first character in the string to copy.
srcEnd - index after the last character in the string to copy.
dst - the destination array.
dstBegin - the start offset in the destination array.
Throws:
IndexOutOfBoundsException - if any of the following is true:
srcBegin is negative
srcBegin is greater than srcEnd
srcEnd is greater than the length of this String
dstBegin is negative
dstBegin+(srcEnd-srcBegin) is larger than dst.length

--------------------------------------------------------------------------------

getBytes
public byte[] getBytes(String charsetName)
throws UnsupportedEncodingException
Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array.
The behavior of this method when this string cannot be encoded in the given charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required.


Parameters:
charsetName - the name of a supported charset
Returns:
The resultant byte array
Throws:
UnsupportedEncodingException - If the named charset is not supported
Since:
JDK1.1

--------------------------------------------------------------------------------

getBytes
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
Since:
JDK1.1

--------------------------------------------------------------------------------

wxh512 2003-10-17
  • 打赏
  • 举报
回复
truezerg 2003-10-17
  • 打赏
  • 举报
回复
在你的开发工具里按住CTRL点你要看的方法,一般的开工具都会转到那个方法的实现处,你看的是jdk中的方法,因为有源码,所以没有问题
bb_star_bb 2003-10-17
  • 打赏
  • 举报
回复
去文档的index-all.html,搜索“getbytes”
fischsuppe 2003-10-17
  • 打赏
  • 举报
回复
jofield 2003-10-17
  • 打赏
  • 举报
回复
在java.lang.string 下
java.lang.Object
|
+--java.lang.String
这也找不到的话.
在index中G打头的,在找getBytes()。

13,100

社区成员

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

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