Tag Archives: UTF-8

Writing UTF-8 encoded text to a file

Introduction

UTF-8 I s a variable width character encoding capable of encoding all 1,112,064 valid code points in Unicode using one to four 8-bit bytes. The encoding is defined by the Unicode standard. When you want to write UTF-8 from your Application you can use the code below.

try {
    Writer out = new BufferedWriter(new OutputStreamWriter(
        new FileOutputStream("outfilename"), "UTF8"));
    out.write(aString);
    out.close();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}