DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3

Thread: Socket I/O

  1. #1
    Greg Guest

    Socket I/O


    I am trying to work with Socket IO. I know you can read byte data via the
    getInputStream() method but is there a way to read character data from the
    socket ?


    Thanks
    Greg

  2. #2
    Paul Clapham Guest

    Re: Socket I/O

    You read the bytes into a byte array and then convert them to String, using
    the constructor that takes a byte array as its parameter.

    PC2

    "Greg" <gjtaylor@tycoelectronics.com> wrote in message
    news:3af2a00a$1@news.devx.com...
    >
    > I am trying to work with Socket IO. I know you can read byte data via the
    > getInputStream() method but is there a way to read character data from the
    > socket ?
    >
    >
    > Thanks
    > Greg




  3. #3
    Lewis Kwan Guest

    Re: Socket I/O


    "Greg" <gjtaylor@tycoelectronics.com> wrote:
    >
    >I am trying to work with Socket IO. I know you can read byte data via the
    >getInputStream() method but is there a way to read character data from the
    >socket ?
    >
    >
    >Thanks
    >Greg


    Greg,

    You can wrap some 'reader' stream around the Input stream obtained from the
    getInputStream() method as follow:

    InputStreamReader isr = new InputStreamReader ( sock.getInputStream()
    );

    and then issue reads against 'isr'.

    Lewis, Toronto


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links