Code example for FileWriter

Methods: close, flush, write

0
			File dir = new File(root.getAbsolutePath() + "/savefiles");
			dir.mkdirs();
			File file = new File(dir, "AlarmLog.txt");
			try 
			{ 
				FileWriter writer = new FileWriter(file, true);
				Date date = new Date();
				writer.write(date.toString() + ":\t" + line + "\n");
				writer.flush();
				writer.close();
			} 
			catch (IOException e)
			{ 
				Log.w("ExternalStorage", "Error writing " + file, e);
			} 
 
		} 
	} 
 
}