服用下列的範例, 可以將字串內容寫入文字檔.
String data;
try
{
FileWriter myWriter = new FileWriter(your_file_path);
myWriter.write(data);
myWriter.close();
System.out.println("Successfully wrote to the file.");
}
catch (IOException e)
{
System.out.println("An error occurred.");
e.printStackTrace();
}