public void writeFile(String dir, String filename, String str) {
		FileWriter fw = null;
		try {
			fw = new FileWriter(dir+filename, false); // clear file before writing
			fw.write(str);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (fw != null) {
				try {
					fw.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}		
	}