InputOut

Discussion in 'Java' started by Leonard, Mar 7, 2007.

  1. Leonard

    Leonard Guest

    I want to read de characters in an array : ok but I want them to
    display on the screen with OutputStreamWriter, but
    nothing happens, what's wrong. I know there's a better way, but I want
    to do it this way.

    public class IO
    {

    public static void main (String[]args)
    {
    System.out.println("Geef een zin in");
    Writer uitvoer = new OutputStreamWriter(System.out); //
    streaming to screen


    char[]buf = new char[250];
    Reader invoer = new InputStreamReader(System.in);


    try{
    invoer.read(buf); //ok
    uitvoer.write(buf); //nothing appear
    }
    catch(IOException ioe)
    {
    System.out.println("fout bij inlezen");

    }
    Leonard, Mar 7, 2007
    #1
    1. Advertising

  2. Leonard

    Phi Guest

    an OutputStreamWriter may be buffered, so flush() it ...

    Leonard wrote:
    > I want to read de characters in an array : ok but I want them to
    > display on the screen with OutputStreamWriter, but
    > nothing happens, what's wrong. I know there's a better way, but I want
    > to do it this way.
    >
    > public class IO
    > {
    >
    > public static void main (String[]args)
    > {
    > System.out.println("Geef een zin in");
    > Writer uitvoer = new OutputStreamWriter(System.out); //
    > streaming to screen
    >
    >
    > char[]buf = new char[250];
    > Reader invoer = new InputStreamReader(System.in);
    >
    >
    > try{
    > invoer.read(buf); //ok
    > uitvoer.write(buf); //nothing appear

    uitvoer.flush(); // write immediately and don't buffer
    > }
    > catch(IOException ioe)
    > {
    > System.out.println("fout bij inlezen");
    >
    > }
    >
    Phi, Mar 7, 2007
    #2
    1. Advertising

  3. Leonard

    Lew Guest

    Please do not top post.

    Phi wrote:
    > an OutputStreamWriter may be buffered, so flush() it ...


    Which is the answer given to your question when you multiposted it to
    comp.lang.java.help as "IO problem". That was rather unfair to those trying to
    help you. You should cross post instead, when you feel the need to approach
    multiple newsgroups at once.

    -- Lew
    Lew, Mar 7, 2007
    #3
  4. Leonard

    Guest

    Lew wrote:
    > Please do not top post.
    >
    > Phi wrote:
    >> an OutputStreamWriter may be buffered, so flush() it ...

    >
    > Which is the answer given to your question when you multiposted it to
    > comp.lang.java.help as "IO problem". That was rather unfair to those
    > trying to help you. You should cross post instead, when you feel the
    > need to approach multiple newsgroups at once.
    >
    > -- Lew



    Sorry, does "top post" mean, I should not add my Answer to the top of
    the question?
    Anyway, it was not my intention to add anything to
    "comp.lang.java.help", because I only subscribed to
    "comp.lang.java.programmer".
    Can anybody help me with this "cross post" thing? How does "cross post"
    work. How do I enable (or disable) it?
    What acutally is a "Followup-To:" (I can choose it in my Thunderbird
    Mail Client, but I have no Idea what it means).

    Thanks

    phi
    , Mar 8, 2007
    #4
  5. wrote:
    > Lew wrote:
    >> Please do not top post.
    >>
    >> Phi wrote:
    >>> an OutputStreamWriter may be buffered, so flush() it ...

    >> Which is the answer given to your question when you multiposted it to
    >> comp.lang.java.help as "IO problem". That was rather unfair to those
    >> trying to help you. You should cross post instead, when you feel the
    >> need to approach multiple newsgroups at once.
    >>
    >> -- Lew

    >
    >
    > Sorry, does "top post" mean, I should not add my Answer to the top of
    > the question?
    > Anyway, it was not my intention to add anything to
    > "comp.lang.java.help", because I only subscribed to
    > "comp.lang.java.programmer".
    > Can anybody help me with this "cross post" thing? How does "cross post"
    > work. How do I enable (or disable) it?
    > What acutally is a "Followup-To:" (I can choose it in my Thunderbird
    > Mail Client, but I have no Idea what it means).
    >
    > Thanks
    >
    > phi

    In Thunderbird, to cross-post you would type something like:

    Newsgroup: | *** comp.lang.java.programmer, comp.lang.java.help

    or:

    Newsgroup: | *** comp.lang.java.programmer
    Newsgroup: | *** comp.lang.java.help

    (The ***'s are my attempt to denote the little rolodex-card-thingy)
    Followup-To is basically the newsgroup version of Reply-To: it just
    tells the client to default to following up to the selected newsgroup(s).
    Joshua Cranmer, Mar 8, 2007
    #5
    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.

Share This Page