output stream with out.flush HELP NEEDED BAD!

Discussion in 'Java' started by spidey12345, Feb 8, 2007.

  1. spidey12345

    spidey12345 Guest

    PrintWriter out = new PrintWriter(new
    FileOutputStream("EncryptedData.txt"));

    out.println("Encrypted text with monoalphabetic subsititution: ");
    out.flush();
    int line = 1;
    for(int i = 0; i<size; i++)
    {

    out.print(newarray);
    out.flush();
    if((i+1)%5==0)
    {
    out.print(" ");

    line = line +1;
    }
    if(line%11 ==0)
    {
    out.println('\n');

    line = line+1;
    }

    }// end for loop



    // frequencies: and it's index of coincidence


    out.println("Frequencies: ");


    this is part of my code, simply the when i try to print out the
    frequencies words, it won't let me, does it have to do with
    out.flush??
    any other way to do this
     
    spidey12345, Feb 8, 2007
    #1
    1. Advertising

  2. spidey12345

    Daniel Pitts Guest

    On Feb 7, 7:35 pm, "spidey12345" <> wrote:
    > PrintWriter out = new PrintWriter(new
    > FileOutputStream("EncryptedData.txt"));
    >
    > out.println("Encrypted text with monoalphabetic subsititution: ");
    > out.flush();
    > int line = 1;
    > for(int i = 0; i<size; i++)
    > {
    >
    > out.print(newarray);
    > out.flush();
    > if((i+1)%5==0)
    > {
    > out.print(" ");
    >
    > line = line +1;
    > }
    > if(line%11 ==0)
    > {
    > out.println('\n');
    >
    > line = line+1;
    > }
    >
    > }// end for loop
    >
    > // frequencies: and it's index of coincidence
    >
    > out.println("Frequencies: ");
    >
    > this is part of my code, simply the when i try to print out the
    > frequencies words, it won't let me, does it have to do with
    > out.flush??
    > any other way to do this


    What do you mean it won't let you? Does it give an exception? Does it
    not output what you expect?

    Its hard for me to tell you whats going on, because your code is out
    of context.

    Try posting an sscce <http://www.physci.org/codes/sscce/>
    This will make it easier for us to help you.

    I don't see where you actually try to print out the frequencies, which
    is exactly what your asking about. Thats like telling the doctor you
    have a rash on your foot, and only showing him your hands.
     
    Daniel Pitts, Feb 8, 2007
    #2
    1. Advertising

  3. spidey12345

    spidey12345 Guest

    On Feb 7, 10:58 pm, "Daniel Pitts" <>
    wrote:
    > On Feb 7, 7:35 pm, "spidey12345" <> wrote:
    >
    >
    >
    >
    >
    > > PrintWriter out = new PrintWriter(new
    > > FileOutputStream("EncryptedData.txt"));

    >
    > > out.println("Encrypted text with monoalphabetic subsititution: ");
    > > out.flush();
    > > int line = 1;
    > > for(int i = 0; i<size; i++)
    > > {

    >
    > > out.print(newarray);
    > > out.flush();
    > > if((i+1)%5==0)
    > > {
    > > out.print(" ");

    >
    > > line = line +1;
    > > }
    > > if(line%11 ==0)
    > > {
    > > out.println('\n');

    >
    > > line = line+1;
    > > }

    >
    > > }// end for loop

    >
    > > // frequencies: and it's index of coincidence

    >
    > > out.println("Frequencies: ");

    >
    > > this is part of my code, simply the when i try to print out the
    > > frequencies words, it won't let me, does it have to do with
    > > out.flush??
    > > any other way to do this

    >
    > What do you mean it won't let you? Does it give an exception? Does it
    > not output what you expect?
    >
    > Its hard for me to tell you whats going on, because your code is out
    > of context.
    >
    > Try posting an sscce <http://www.physci.org/codes/sscce/>
    > This will make it easier for us to help you.
    >
    > I don't see where you actually try to print out the frequencies, which
    > is exactly what your asking about. Thats like telling the doctor you
    > have a rash on your foot, and only showing him your hands.- Hide quoted text -
    >
    > - Show quoted text -


    sorry, i got it to work, i was missing a out.flush() after
    out.println('frequencies");
     
    spidey12345, Feb 8, 2007
    #3
    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. Someonekicked

    flush the stream

    Someonekicked, Oct 22, 2004, in forum: C++
    Replies:
    2
    Views:
    456
    Someonekicked
    Oct 22, 2004
  2. Fernando Arbeiza

    Will reading from stdin() flush output to stdout()?

    Fernando Arbeiza, Feb 4, 2004, in forum: C Programming
    Replies:
    3
    Views:
    635
    Fernando Arbeiza
    Feb 5, 2004
  3. Kashif Ur Rehman
    Replies:
    2
    Views:
    884
    Tom Hawtin
    May 17, 2007
  4. rantingrick
    Replies:
    44
    Views:
    1,266
    Peter Pearson
    Jul 13, 2010
  5. MRAB
    Replies:
    5
    Views:
    265
Loading...

Share This Page