String 2 file

/**
	 * String 2 file
	 * 
	 * @param xml
	 * @param fileName
	 */
	public static void writeStrToFile(String xml, String fileName) {
		try {
			FileOutputStream fos = new FileOutputStream(new File(fileName));
			Writer os = new OutputStreamWriter(fos, "GBK");
			os.write(xml);
			os.flush();
			fos.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

猜你喜欢

转载自blog.csdn.net/xinpz/article/details/87073938