Java Write file

服用下列的範例, 可以將字串內容寫入文字檔.

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();
}

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *