JAVA -写文件

//写文件
	public  void writeFile(String filePath, String sets) throws IOException {  
		try{
			   String encoding = "UTF-8";//设置文件的编码!!
			   OutputStreamWriter outstream = new OutputStreamWriter(new FileOutputStream(filePath), encoding);
			   PrintWriter writer = new PrintWriter(outstream);
			   writer.write(sets);       
			   writer.close();
			}
			catch(IOException e){
			e.printStackTrace();
			}
    }
原文地址:https://www.cnblogs.com/devan/p/5755435.html