Write a file in UTF-8 using FileWriter (Java)?
- by user1280970
I have the following code however, I want it to write as a UTF-8 file to handle foreign characters. Is there a way of doing this, is there some need to have a parameter?
I would really appreciate your help with this. Thanks.
try
{
BufferedReader reader = new BufferedReader(new FileReader("C:/Users/Jess/My Documents/actresses.list"));
writer = new BufferedWriter(new FileWriter("C:/Users/Jess/My Documents/actressesFormatted.csv"));
while( (line = reader.readLine()) != null)
{
//If the line starts with a tab then we just want to add a movie
//using the current actor's name.
if(line.length() == 0)
continue;
else if(line.charAt(0) == '\t')
{
readMovieLine2(0, line, surname.toString(), forename.toString());
}
//Else we've reached a new actor
else
{
readActorName(line);
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
}