code: public static boolean writeFile(String filePath, String fileContent,
  			String encoding) {
  		FileOutputStream fout = null;
  		FileChannel fcout = null;
  		File file = new File(filePath);
  		if (file.exists()) {
  			file.delete();
  		}
  		
  		try {
  			fout = new FileOutputStream(filePath);
  			// 获取输出通道
  			fcout = fout.getChannel();
  			// 创建缓冲区
  			// ByteBuffer buffer = ByteBuffer.allocate(1024);
  			ByteBuffer buffer = ByteBuffer.wrap(fileContent.getBytes(encoding));
  			fcout.write(buffer);
  			fout.flush();
  		} catch (FileNotFoundException e) {
  			LogUtil.writeErrorLog("WriteFile fail", e);
  			return false;
  		} catch (IOException ex) {
  			LogUtil.writeErrorLog("WriteFile fail", ex);
  			return false;
  		} finally {
  			try {
  				if (null != fout)
  					fout.close();
  				if (null != fcout)
  					fcout.close();
  			} catch (IOException ex) {
  				LogUtil.writeErrorLog("Releases any system resources fail", ex);
  				return false;
  			}
  		}
  		return true;
  	}
docs: 写文件方法
  
  @param filePath
  文件路径
  @param fileContent
  文件内容
  @param encoding
  编码
  @return