File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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
non blocking socket
Using FileChannel instead of RandomAccessFile
Encoding type in J2ME
Getting a time out error
NX: some questions concerning find-method