Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

send/receive a stream of Unicode characters over TCP/IP  RSS feed

 
Timothy Toe
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to send/receive a stream of Unicode characters over TCP/IP.
Before sending, I will assemble the stream which is actually TLVs (Tag, Length, Value). For receiving, it will be the opposite.

There are so many interfaces, classes and methods in the java.io package. Can anyone point to me which one should I use ? I believe there are 2 main categories of interfaces, classes and methods in the in the java.io package : those that work on bytes and those that work on characters. I should use the one for characters ?

Thanks.
 
Mark Van Tuyl
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to read characters, you can use InputStreamReader: http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStreamReader.html

To write characters, you can use OutputStreamWriter:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/OutputStreamWriter.html
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the IO Trail in Sun's Java Tutorial. (See the link in my sig for the full tutorial.) In particular, you should check out the section on Custom Networking.

Layne
 
Timothy Toe
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.

I noticed there are methods like :
readUTF() and
writeUTF()
I wonder whether I should use these... and how.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!