Best inputstreams/outputstreams for sockets

Discussion in 'Java' started by Bruce Lee, Dec 7, 2004.

  1. Bruce Lee

    Bruce Lee Guest

    Does anyone know what are the best inputstream/outputstreams for writing a
    stream of ASCII text to sockets? I mean, you can stick different streams
    together in different combinations.
     
    Bruce Lee, Dec 7, 2004
    #1
    1. Advertising

  2. Bruce Lee wrote:
    > Does anyone know what are the best inputstream/outputstreams for writing a
    > stream of ASCII text to sockets? I mean, you can stick different streams
    > together in different combinations.
    >
    >

    For text only? How 'bout...

    InputStream is = socket getInputStream();
    InputStreamReader isr = new InputStreamReader(in, "ASCII");
    BufferedReader in = new BufferedReader(isr);

    OutputStream os = socket.getOutputStream();
    OutputStreamWriter osw = new OutputStreamWriter(os, "ASCII");
    BufferedWriter out = new BufferedWriter(osw);

    Steve
     
    Steve Horsley, Dec 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yurai Núñez Rodríguez

    Problems using ASPNET OutputStreams

    Yurai Núñez Rodríguez, May 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    301
    Yurai Núñez Rodríguez
    May 2, 2004
  2. Andy Fish

    closing writers and outputstreams

    Andy Fish, Nov 13, 2003, in forum: Java
    Replies:
    1
    Views:
    509
    Thomas Weidenfeller
    Nov 13, 2003
  3. bugbear
    Replies:
    11
    Views:
    599
    bugbear
    Sep 5, 2005
  4. raven
    Replies:
    0
    Views:
    308
    raven
    Jul 12, 2007
  5. Philipp
    Replies:
    15
    Views:
    698
    Tom Anderson
    May 17, 2008
Loading...

Share This Page