facebook

Output a string using BufferedWriter

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #259347 Reply

    anulaibar
    Member

    I am having trouble outputting a string to the console window using Eclipse 3.2. My code is as follows:

    package test;
    
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.OutputStreamWriter;
    import java.io.UnsupportedEncodingException;
    
    public class Test {
    
        public static void main(String args[]) {
            System.out.println("Hello world!");
            BufferedWriter bw;
            try {
                bw = new BufferedWriter(new OutputStreamWriter(System.out,"ISO-8859-1"));
                }
            catch (UnsupportedEncodingException e) {
                            System.out.println("Default encoding.");
                            bw = new BufferedWriter(new OutputStreamWriter(System.out));
            }
            
            // Try to print a test string
            try{
            bw.write("Hello World!");
            }
            catch (IOException e) {
                System.err.println(e.getMessage());
            }
        }
    }
    

    The System.out.println() statement works as expected, but not the write() method of the BufferedWriter class. I would be grateful if someone could point me in the right direction.

    Thank you,
    Olle

    #259380

    Riyad Kalla
    Member

    Moving to OT > Soft Dev.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Output a string using BufferedWriter

You must be logged in to post in the forum log in