3 Replies Latest reply: Aug 2, 2010 2:07 PM by 843790 RSS

    Writing special characters to a file

    843790
      I need to write special characters to a file. Currently I'm using PrintWriter:
      String s = "ÿ";
      System.out.println(s);
      PrintWriter p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), "UTF8")));
      p.write(s);
      p.close();
      The character I want to print is a y with 2 dots above it (but I have the same problem with other characters like Ø)
      The character is correctly displayed in my console through system.out, but after I opened my file, I find that my character is show as 2 characters: ÿ

      I added UTF8 as you can see above, because I thought that it might be written as ASCII, but without any luck.

      Any idea how I can do this??