package com.royasoft.mas.model.test;
import java.io.BufferedWriter;
import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.text.SimpleDateFormat; import java.util.Date; public class newFile {
/**
* @param args */ public static void main(String[] args) { SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); File file = new File("c:" + format.format(new Date()) + ".xml"); BufferedWriter bw = null; try { bw = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(file), "UTF-8")); bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); bw.write("<maslog>\r\n"); bw.write("\t<masDate>\r\n"); bw.write("\t\t<masContent>\r\n"); bw.write("\t\t\t\t"+"我要非禮你哈哈!"+"\r\n"); bw.write("\t\t</masContent>\r\n"); bw.write("\t</masDate>\r\n"); bw.write("</maslog>\r\n"); bw.flush(); } catch (Exception e) { e.printStackTrace(); }
}
} |
|
來自: 々心寒々 > 《JAVA基礎(chǔ)知識》