title: How do I make eclipse print out weird characters in unicode?
body: <p>So I'm trying to make my program output a text file with a list of names. Some of the names have weird characters, such as Åström.</p>
  
  <p>I have grabbed these list of names from a webpage that is encoded in "UTF-8", or at least I'm pretty sure it does because the page source says </p>
  
  <blockquote>
    <p>" meta http-equiv="Content-Type" content="text/html; charset=UTF-8" / "</p>
  </blockquote>
  
  <p>This is what I've tried so far:</p>
  
  <pre><code>public static void write(List&lt;String&gt; list) throws IOException  {
          Writer out = new OutputStreamWriter(new FileOutputStream("test.txt"), "UTF-8");
          try {
              for (int i=0;i&lt;list.size();i++) {
                  try {
                      byte[] utf8Bytes = list.get(i).getBytes("UTF-8");
                      out.write(new String(utf8Bytes, "UTF-8"));
                  } catch (UnsupportedEncodingException e) {
                      e.printStackTrace();
                  }
  
                  out.write(System.getProperty("line.separator"));
  
              }
          }
          finally {
          out.close();
          }
      }
  </code></pre>
  
  <p>and I'm a little confused as to why it's not working. The output I get is "Ã…strÃ¶m", which is very weird.</p>
  
  <p>Can someone please point me in the right direction? Thanks!</p>
  
  <p>And on another unrelated note, is there an easier way to write a new line to a text file besides the clunky</p>
  
  <blockquote>
    <p>out.write(System.getProperty("line.separator"));</p>
  </blockquote>
  
  <p>that I have? I saw that online somewhere and it works, but I was just wondering if there was a cleaner way.</p>