wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use bytebuffer send Chinese will throw exception.
 
Similar Threads
Using FileChannel instead of RandomAccessFile
non blocking socket
Encoding type in J2ME
Getting a time out error
NX: some questions concerning find-method