Previously, I had a code such as this:
        Writer writer = new OutputStreamWriter(System.out, "UTF-8");
        generator.stream(writer);
Now, my code looks like this:
            string = new StringBuilder();
            OutputStream output = new OutputStream()
            {
                public String getString()
                {
                    return string.toString();
                }
                @Override
                public void write(int b) throws IOException {
                if ((char)b != '\n')
                {
                    string.append((char) b );
                }
            }
            public String toString(){
                return string.toString();
            }
        };
        Writer writer = new OutputStreamWriter(output, "UTF-8");
        generator.stream(writer);
        writer.close();
        PrintStream ps = new PrintStream(System.out, true, "UTF-8");
        ps.println(string.toString());
The problem with the first code was that it didn't guarantee that the output is in a single row. In the other hand, my new code resolves this issue, however, a new problem has appeared: Instead of 'Á' the output sends 'ᅢチ', which is quite painful, as Hungarian and Polish characters should be supported. For non-Hungarian, non-Polish characters, my current output is correct, but the special characters in the written Hungarian and Polish language are not handled by my new code. How can I overcome this issue?
Thanks.
 
     
     
    