Internationalization tips — I/O operations

I/O Operations

Whenever text is being read from / written to a file, the encoding should be specified. (Preferably as UTF-8 but need to keep in mind the OS / Language / Locale)

try
{
FileOutputStream fos = new FileOutputStream("test.txt");
Writer out = new OutputStreamWriter(fos, "UTF-8");
out.write(strInputString);
out.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.