Socket I/O


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

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


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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center