wood burning stoves*
The moose likes I/O and Streams and the fly likes use bytebuffer send Chinese will throw exception. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "use bytebuffer send Chinese will throw exception." Watch "use bytebuffer send Chinese will throw exception." New topic
Author

use bytebuffer send Chinese will throw exception.

jgm jinggm
Greenhorn

Joined: Nov 19, 2003
Posts: 8
//use bytebuffer send Chinese whill throw a ioexception.
SocketChannel Channel = null;
StringBuffer m_Buffer = new StringBuffer("中文");
charset = Charset.forName("ISO-8859-1");
encoder = charset.newEncoder();
Channel.write(encoder.encode(CharBuffer.wrap(m_Buffer)));
//this can throw a ioException and message is "Input length = 1"
//what will i do???/
jgm jinggm
Greenhorn

Joined: Nov 19, 2003
Posts: 8
this is right:
charset = Charset.forName("gb2312");
 
 
subject: use bytebuffer send Chinese will throw exception.